|
G'Day All,
I have created a Dialog application that will manipulate some excel spreadsheets. In my OnInitDialog function (I am using MFC) I perform a test to see if excel is currently running. If it is running I display an interim modeless dialog that politely informs the user to shut excel and waits for them to do so (done with a call to WaitForSingleObject if that is relevant). This is all fine. Once excel is closed then I close this interim dialog and my OnInitDialog function completes and my 'real' dialog is displayed. However my problem is that when my 'real' dialog is displayed it is done so without the focus - it is not the currently active window. I have tried numerous things such as SetActiveWindow(), BringWindowToTop() etc without success. I was wondering if anyone could suggest a way of having my 'real' dialog start with the focus as it normally would if I wasn't mucking around with other windows whilst it was starting.
Much Thanks In Advance
Richard.
|
|
|
|
|
Did you try SetForegroundWindow?
Use in together with SetActiveWindow.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
No, not until 30 seconds after you suggested it Nish
I missed that one. It now works like a charm. Thanks Nish problem solved!
Richard.
|
|
|
|
|
I am coding a networked game in VC++6, and I need to send data and access functions between a server and a client. How do I do this with CSockets?
|
|
|
|
|
Are you comforable with sending raw data across the network with CSockets?
You could use COM and MIDL, then the compiler will generate the proxy stub code for you to make the RPC calls,
or if you want to do it by hand:
What you will need to do is package up the function that you would like to be called into a packet to be sent to the client. You could create a table of functions and each function would be represented by an index.
So in your RPC data packet that you send across, you would reference your RPC function by its index, then you would add the data to be called for its parameters.
On the client side when this data packet is processed, your decode function would look up the RPC id in your table and call the function.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
or, alternatively, use CSocketFile and "serialize" your data across the wire, deserializing it on the receiving end.
|
|
|
|
|
Can anyone provide me information on how to render the font in a dialog edit box in a fixed pitch format as opposed to the normal way that the font normally displays. For example the normal Dialog font is MS San Serif and this is a font with variable width characters and is normally rendered in a variable pitch manner. I need to render the font in a fixed pitch format so that columns of text in edit boxes stacked above one another will line up vertically. I have tried using the Trur Type Courier font....That works until one switches the dialog font to unicode in order to support Japanese, Chinese, Arabic, etc. ANy help out there?
|
|
|
|
|
I dont think you can do that.
But what I would suggest is go for GetTextExtent
and test the width and keep adding spaces until
you get enough for the column width you want to
have.
|
|
|
|
|
Thanks Prem.....But I need individual character columns to line up vertically just as they would with a fixed pitch font.
|
|
|
|
|
I think in order to do this with a TTF that is not mono-spaced you will need to create an owner-drawn version of the edit control.
When you draw the characters, you will first need to scan the font that you are creating and determine the width of the largest character in the font. You can use a function like GetCharWidth32 .
Then when you paint your characters into the edit control, the column width will be at least the width that you calculated for the widest character. You will need to paint one character at a time, one character per column.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanks....your suggestion appears to be exactly what must be done. I have looked at the GetCharWidth32() function and it gives exactly the information I need. I think I may just scan the strings I am trying to display at the given moment and find the widest character from that set and align the multiple stacked edit boxes based upon that width. If the user edits the string(s) again and selects some other wider character the controls repaint anyway and will find the wider character and update accordingly.
Thanks Again !!!
|
|
|
|
|
Doesn't
CFont font;
font.CreateStockObject(OEM_FIXED_FONT);
GetDlgItem(IDC_EDIT)->SetFont(&font);<pre>work?
|
|
|
|
|
I believe that your suggestion will give a result that is similar to my current use of the Courier font. I actually need to find the solution that works with the font that is already set for the dialog. This is becasue that font may have been set to a Unicode font with far eastern characters in it and I need to make sure that font gets used, not one selected by the CreateStockObject().
|
|
|
|
|
My question is: Do you really need it to be a multi-line edit?
Perhaps a simple listbox where you set tab stops would do it, or even a list control? After all, if you want to display columnar data it seems a list control indeed is what you are looking for.
|
|
|
|
|
How do you make a button not visable at runtime in MFC?
What property of CButton should I use? EnableWindow(FALSE)only grays it out I want to hide it.
Thanks!
|
|
|
|
|
You can hide the button using ShowWindow(SW_HIDE). For example:
-----
GetDlgItem (ID_APPLY_NOW)->ShowWindow (SW_HIDE);
-----
Whatever you pass into GetDlgItem(....) is the nID of the item you are interested in.
Kuphryn
|
|
|
|
|
CButton is derived from CWnd and thus you can use CWnd::ShowWindow to show/hide a button. Use SW_SHOW to show it and SW_HIDE to hide it.
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Hi Nish, try this:
MoveWindow(-999, -999, 0, 0);
Maxwell Chen
People say "No news is good news". Then, no code is good code!?
|
|
|
|
|
Why should I?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I want to make a dialog based program that just contains an edit box. Then I want to update that box with information every 30 seconds. Is it possible to do considering that windows hides the looping?
|
|
|
|
|
It is very possible. You can use OnTimer(). You will need to set a time count, etc. Nonetheless, yes it is very possible.
Kuphryn
|
|
|
|
|
I just wanted to say that whether or not the message loop is hidden from you, you still have the ability to process messages with the dialog proc that you create for your dialog. Or if you are using MFC, the messages that you add to the message table.
Like your previous reply stated you can call SetTimer to create a timer that will trigger an WM_TIMER or OnTimer event for whatever tiem interval that you choose.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi out there !
I've just a little beginners-question:
When I create a child Window with the "WS_CHILD | WS_CAPTION | WS_SYSMENU" flags, the child window's
titlebar is always shown with the system defined inactive color. Is there any way (not using MFC) to give it an activated look ?
Thanks in advance for any answers
Jay
|
|
|
|
|
include the style WS_VISIBLE?
|
|
|
|
|
Send it the message WM_NCACTIVATE .
You need to do this manually, as only top-level windows are "active" as far as Windows is concerned.
--------
I am not a connoisseur. --Shog9 --
|
|
|
|