Hello everyone

it is 1am, and i am about to go to bed, tomorrow is a public holiday, and i want to be able to enjoy it instead of sleeping through it....

one question before i go though:
i have a dialog, and i want it to be application modal, how exactly do i achieve this? Is it something i do when i load it, or is it something that should be in the resource template? If it helps your answer at all, i am using the resource editor in VC++ 6.0.

Cheers :)
Posted on 2001-10-21 06:53:40 by sluggy
Hi sluggy

To create a modal dialog, use:
invoke DialogBoxParam,hInstance,IDD_DLG1,hWnd,addr DlgProc,0

where hWnd is the handle of your app window.

KetilO
Posted on 2001-10-21 07:43:36 by KetilO

To create a modal dialog, use:
invoke DialogBoxParam,hInstance,IDD_DLG1,hWnd,addr DlgProc,0

where hWnd is the handle of your app window.


Hi KetilO,
i'm doing exactly that, but i can still give focus to the parent window and do stuff on it, even though the dialog stays on top (higher z-order). I would like for the dialog to be dismissed before focus can go back to the main window, do i have to add code to flag when the dialog is dismissed?

Thanks!
Posted on 2001-10-21 23:09:53 by sluggy
when creating a dialog with dialogboxparam(), the owner window will be disabled (with (EnableWindow()). If it is not in your prog, sluggy, you probably enable the owner window by hand?
Posted on 2001-10-22 03:04:05 by japheth
Hi sluggy

You probably need to make some changes to your messageloop.



.while TRUE
invoke GetMessage,addr msg,0,0,0
.break .if !eax
;hDlg is your dialog, set to NULL when dialog is closed.
invoke IsDialogMessage,hDlg,addr msg
.if eax==FALSE
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endif

.endw



KetilO

Edit: Where did my .endw go?:confused:
Posted on 2001-10-22 03:19:49 by KetilO
Okay, got it nailed :)

KetilO, i missed something very important in the doco: CreateDialogBoxParam creates a modeless dialog box, as japheth pointed out, i needed to be using DialogBoxParam for the modal box.

So, the problem is fixed, with a simple function change. But there is a twist....

after using DialogBoxParam, and executing an EndDialog in my dlgProc, my main window was getting the focus back, but i couldn't do anything in it, i had to manually call EnableWindow to give control back to it, i would have thought EndDialog would have done that for me....


Thanks guys :)
Posted on 2001-10-22 21:10:02 by sluggy