Focus on Main Window:

Hi fellows outta there... Again, a simple question for you but still a mistery for me :) Ok, I have my main Window that creates different dialog boxed as you select sarazas from the Main Menu. The problem is that when a dialog box opens, if the user clicks on the Main Window he can still get focus on it. Yeah, you know what I mean, I want to avoid this, I mean, when a dialog box opens ovah the main window the user should not get control on the main Window.... Can u tell me how to do this ? I was thinking about opening a messagebox saying: "Please, don't click on the Main Window coz I dunno how to avoid this, so be cooperative and click back in the Dialog Box" .... Hmmm I think there should be a better method ...
PS: Yeah, Larigus, I know I can read Petzold's, but you know, here is 2:00 AM and I wanna go to sleep ...

Thanks a lot in advance good fellows.:tongue:
Posted on 2001-10-15 23:55:33 by magicmac
Ok, I think i can help on this

to avoid user from clicking the main window while a dialog box or a message box is displayed you must call the function with the handle of the window, not the program.
Example:


MessageBox, hWnd, addie b14h, addie t1tl3, 4h OR 20h

there, if you put hInstance instead of hWnd, the user will be able to get focus in main window, because (IMO) hInstance is the handle of the program, not of the main window.

In this case hWnd was taken from the WndProc proc, where hWnd is a LOCAL variable in WndProc procedure:

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM

I hope this helps, I'm a newbie too :grin:

greetings
Posted on 2001-10-16 01:26:46 by Vital Zero
Hi magicmac

I guess what you want is a modal dialogbox.
Use the DialogBox or DialogBoxParam api's.

KetilO
Posted on 2001-10-16 03:05:18 by KetilO
Thanx Vital Zero and Ketil0 ... I'll try that tomorrow and will tel ya... :)

-MagicMac.
Posted on 2001-10-16 23:49:12 by magicmac
Hoi Hoi MagicMac !!
Your problem is that the MAIN window does not OWN the Child one.
When you create the new DialogBox, make sure you pass the Main window's handle as the parent handle to the newly created window.
When you present the user with a child window whose parent is the main window, he cannot go back to the main one unless he closes el hijito.
Comprendiste cabr?n?
hehe
See you tonite amigo!


Latigus
Posted on 2001-10-17 10:25:19 by latigo
Yeah, you were right. Iwas using CreateDialog instead of DialogBox and also wasn't using the previous hWnd of the Owner of the Dialog.
THanks !! :)

-MagicMac.
Posted on 2001-10-17 23:27:54 by magicmac