News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Modal dialog, how?

Started by BytePtr, August 31, 2005, 02:26:08 PM

Previous topic - Next topic

BytePtr

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.

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

BytePtr

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.

PBrennick

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
The GeneSys Project is available from:
The Repository or My crappy website

gabor

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

QvasiModo

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.