I do not want to use a dialog so is there any way I can create a modal window with CreateWindowEx, so the user has to close the popup window before they can use the main window? Could not find any styles to use, maybe have to respond to some WM messages? Any tutorials or sample MASM code to direct me to?

Thanks.
Posted on 2002-10-22 16:21:41 by Gunner
maybe:

WM_CREATE:
EnableWindow(hwndParent, FALSE);

WM_DESTROY:
EnableWindow(hwndParent, TRUE);
SetActiveWindow(hwndParent);

:grin:
Posted on 2002-10-23 04:06:04 by C.Z.
You can simulate a dialog using CreateWindowEx by:

1. Registering a new class (new window procedure)
2. Using CreateWindowEx to make a POPUP window with no parent (so it appears on the taskbar)
3. Then the code enters a message loop which has GetMessage, IsDialogMessage, TranslateMessage and DispatchMessage
4. If GetMessage returns eax=0 (WM_QUIT) the loop exits
5. Causing the class to be unregistered and focus to return to the main window

The main thing which makes it modal is the message loop. This means the main thread only returns to the system by the call to GetMessage, so it can't do anything but get a message for your simulated dialog.

In the window procedure you need to call PostQuitMessage on WM_DESTROY.

You also need to provide a way to close the simulated dialog, maybe with a button.

This is not a complete simulation in that the main window's menu can still be opened. This proves that the system uses another thread for the menu (in W9x anyway). You may be able to stop this happening by intercepting menu messages (I haven't tried this).

Suitable source code appears in
the Testbug help files
Posted on 2002-10-23 11:48:51 by jorgon
Maybe modal was the incorrect term, but whatever it is call when the user has to close my "popup" window before using the main window.. Finally figured it out (a lot of reading in the PSDK!) and am doing it bomb01s' way:

in my popup window proc:
.if uMsg == WM_CREATE
invoke EnableWindow, hMain, FALSE
.
.
.
.elseif uMsg == WM_CLOSE
invoke EnableWindow, hMain, TRUE
invoke DestroyWindow, hWnd
.
.
.

and all seems to work well!

Thanks
Posted on 2002-10-23 16:45:12 by Gunner
Yes, the EnableWindow method does work well.

However if a dialog's normal response to the navigation and command keys (TAB, ARROWS, ENTER etc.) should also be simulated it is still necessary to include IsDialogMessage, this time in the main message loop (using the child window's handle).

In both methods the main window is updated properly when uncovered, and WM_TIMER messages still reach the main window and are processed.

I ought to correct something I said earlier about the system using a different thread to deal with menu messages while in the simulated dialog's message loop. I've been looking at this in the debugger and in fact the simulated dialog's message loop is just regarded by the system as the main message loop for the time being. So if the main window's menu is clicked then GetMessage returns using the main thread in the usual way, with various button down messages and WM_ENTERMENULOOP, WM_INITMENU etc. DespatchMessage sends these to the window they were intended for (either the main window or the simulated dialog window depending on the message). When the simulated dialog is removed, the original message loop takes back control.
Posted on 2002-10-27 10:29:48 by jorgon
I don't know if this is what you want but
CreateWindow has modal dialog window styles that
all start with DS_


Zcoder.....
Posted on 2002-10-30 09:20:24 by Zcoder