The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: BytePtr on August 31, 2005, 02:26:08 PM

Title: Modal dialog, how?
Post by: BytePtr on August 31, 2005, 02:26:08 PM
Hi.

I created DialogApp in RadASM. Main window of my app is ready but i want to create about box dialog now from resource script.
I displays fine with code like this:

invoke DialogBoxParam,hInstance,IDD_ABOUT,NULL,addr DlgProc,NULL

But i need that this aboutbox must be modal, i tried to set dialog property Border to ModalFrame but anyway it's not modal it hides itself behind main dialog when i click on main dialog.

How to make it modal?
Any ideas? Code snippets, searched here and in Google, nothing, only hints when i create window with winapi only.

Thx in advance.
Title: Re: Modal dialog, how?
Post by: PBrennick on August 31, 2005, 02:38:00 PM
HuMaX,
You do this in the resource script by setting the style something like this:

STYLE       DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU

I use the above line in all the dialog boxes used by my editor.  If you need to see my sources, just say so.

Paul
Title: Re: Modal dialog, how?
Post by: BytePtr on August 31, 2005, 03:15:06 PM
Solved:

INVOKE DialogBoxParam, hInstance, IDD_DLG1, hWin, ADDR DlgProc, 0

hWin solved the problem coz i used NULL there before.  :8)
Very important thing that i and not only me must remember.
Thank you.
Title: Re: Modal dialog, how?
Post by: PBrennick on August 31, 2005, 03:41:50 PM
HuMaX,
It is not done in the CreateDialogParam function, it is done in the resource script.  There is a way to create dialog boxes directly in the assembly and if that is what you are doing, it is probably a problem.  If you are seeing two windows in the taskbar, this is not correct.  It means you are somehow creating a window and not a dialog.  Either post your entire project here or please email it to me and I can then determine what needs to be done.

Paul
Title: Re: Modal dialog, how?
Post by: gabor on September 02, 2005, 06:38:06 AM
Hi!

Quote
hWin solved the problem coz i used NULL there before.  :8)

I read in win32 api, that if you assign ws_popup to a dialog box it will turn into a modeless dialog box. The style of the border does not affect anything.
When you create a modal dialog box and assign NULL as its parent window it is still a modal dialog, but does not behave as one.
Maybe I misunderstood something, but to me it seems like the only difference in creation between the two types is this ws_popup style. Of course there are many other differences in behavior, like communicating with those dialogs, hiding, destroying them and so on.

Greets, Gábor
Title: Re: Modal dialog, how?
Post by: QvasiModo on September 02, 2005, 03:01:41 PM
Modal dialog boxes disable their parent, that's why if you pass NULL there is no window to disable. There are still some differences: the message loop is located outside your application, messages are processed a bit differently, etc. In general it's not a good idea not to pass the parent window handle to DialogBoxParam, unless it's your main window of course.