I didn't get a reply to this, so I thought I'd try again.

MainDialogA [shows]--> DialogB [shows]--> DialogC

When you click the "OK" button in DialogC, rather than going back to
DialogB as expected, it closes too!

Could this be a limitation of nested dialogs?

Thanks!

Mike Welch

ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
1. In the main dialog WndProc I handle the about button
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
...

BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
lParam)
...
if(wParam == IDC_ABOUT) {
DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), g_hMainWnd,
AboutDlgProc);
break;
}
...

oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
2. The about dialog box handler opens a high score dialog box, also
modal.
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

BOOL WINAPI AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
lParam)
{
switch(msg) {
case WM_INITDIALOG: {
...init stuff
return TRUE;
}

case WM_COMMAND: {
if (wParam == ID_BTN_HIGHSCORE) // clicked high score btn
*---> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HIGHSCORE),
hDlg, HighScoreDlgProc);

if (wParam == IDCANCEL || wParam == IDOK) { // Close button
EndDialog(hDlg, TRUE);
return TRUE;
}
break;
}
} return FALSE; // Pass off to DefDlgProc
}

ooooooooooooooooooooooooooooooooooooooo
3. The high score dialog box handler.
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO

When I call EndDialog below, not only does the high score dialog
close, but the calling About dialog box closes too. Why?

BOOL WINAPI HighScoreDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
LPARAM lParam)
{
switch(msg) {
case WM_INITDIALOG: {
... init stuff
return TRUE; // Message handled
}

// Handle button clicks
case WM_COMMAND: {
if (wParam == ID_BTN_CLEAR_HIGHSCORE)
... code handler snipped
return TRUE;
}

// Close the high score dialog
if (wParam == IDCANCEL || wParam == IDOK) {
*---> EndDialog(hDlg, TRUE); // closes calling dialog too!
return TRUE;
}
break;
}
} return FALSE;
}

Thanks!

Re: What's wrong with this code? by Michael

Michael
Thu Jun 17 07:03:45 CDT 2004

Does DialogB actually close, or is it in the background?

If it actually closes, then set a breakpoint on any calls to EndDialog() and
you should get there.

Also run Remote Spy (eVC Tools menu) to see if somehow it's getting
WM_CLOSE. Does your own code ever post or send that message?

If it goes in the background, the Remote Spy may indicate why. But, to
"fix", just call SetForegroundWindow() when DialogC returns.
--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com



"Mike Welch" <michaelw@techemail.com> wrote in message
news:b3ce3d49.0406170247.4b5a3e8@posting.google.com...
> I didn't get a reply to this, so I thought I'd try again.
>
> MainDialogA [shows]--> DialogB [shows]--> DialogC
>
> When you click the "OK" button in DialogC, rather than going back to
> DialogB as expected, it closes too!
>
> Could this be a limitation of nested dialogs?
>
> Thanks!
>
> Mike Welch
>
> ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> 1. In the main dialog WndProc I handle the about button
> OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> ...
>
> BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> lParam)
> ...
> if(wParam == IDC_ABOUT) {
> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), g_hMainWnd,
> AboutDlgProc);
> break;
> }
> ...
>
> oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> 2. The about dialog box handler opens a high score dialog box, also
> modal.
> OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
>
> BOOL WINAPI AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> lParam)
> {
> switch(msg) {
> case WM_INITDIALOG: {
> ...init stuff
> return TRUE;
> }
>
> case WM_COMMAND: {
> if (wParam == ID_BTN_HIGHSCORE) // clicked high score btn
> *---> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HIGHSCORE),
> hDlg, HighScoreDlgProc);
>
> if (wParam == IDCANCEL || wParam == IDOK) { // Close button
> EndDialog(hDlg, TRUE);
> return TRUE;
> }
> break;
> }
> } return FALSE; // Pass off to DefDlgProc
> }
>
> ooooooooooooooooooooooooooooooooooooooo
> 3. The high score dialog box handler.
> OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
>
> When I call EndDialog below, not only does the high score dialog
> close, but the calling About dialog box closes too. Why?
>
> BOOL WINAPI HighScoreDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
> LPARAM lParam)
> {
> switch(msg) {
> case WM_INITDIALOG: {
> ... init stuff
> return TRUE; // Message handled
> }
>
> // Handle button clicks
> case WM_COMMAND: {
> if (wParam == ID_BTN_CLEAR_HIGHSCORE)
> ... code handler snipped
> return TRUE;
> }
>
> // Close the high score dialog
> if (wParam == IDCANCEL || wParam == IDOK) {
> *---> EndDialog(hDlg, TRUE); // closes calling dialog too!
> return TRUE;
> }
> break;
> }
> } return FALSE;
> }
>
> Thanks!



Re: What's wrong with this code? by michaelw

michaelw
Sat Jun 19 17:52:55 CDT 2004

You make a good point, I didn't think about it just being a focus
thing. I tend to think it's closed though, because my program itself
is a small dialog to begin with (about half the PPC screen volume
wise). I can move it around such that I can see what's behind it, in
other words. It's not just back in the Zorder at least.

I'll check remote spy though. Good idea.

But you didn't see anything that looked wrong and it should be able to
return to DialogB then?

Thanks!

Mike

"Michael J. Salamone [eMVP]" <mikesa#at#entrek#dot#com> wrote in message news:<#Myr#MGVEHA.3944@tk2msftngp13.phx.gbl>...
> Does DialogB actually close, or is it in the background?
>
> If it actually closes, then set a breakpoint on any calls to EndDialog() and
> you should get there.
>
> Also run Remote Spy (eVC Tools menu) to see if somehow it's getting
> WM_CLOSE. Does your own code ever post or send that message?
>
> If it goes in the background, the Remote Spy may indicate why. But, to
> "fix", just call SetForegroundWindow() when DialogC returns.
> --
>
> Michael Salamone [eMVP]
> Entrek Software, Inc.
> www.entrek.com
>
>
>
> "Mike Welch" <michaelw@techemail.com> wrote in message
> news:b3ce3d49.0406170247.4b5a3e8@posting.google.com...
> > I didn't get a reply to this, so I thought I'd try again.
> >
> > MainDialogA [shows]--> DialogB [shows]--> DialogC
> >
> > When you click the "OK" button in DialogC, rather than going back to
> > DialogB as expected, it closes too!
> >
> > Could this be a limitation of nested dialogs?
> >
> > Thanks!
> >
> > Mike Welch
> >
> > ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> > 1. In the main dialog WndProc I handle the about button
> > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > ...
> >
> > BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> > lParam)
> > ...
> > if(wParam == IDC_ABOUT) {
> > DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), g_hMainWnd,
> > AboutDlgProc);
> > break;
> > }
> > ...
> >
> > oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> > 2. The about dialog box handler opens a high score dialog box, also
> > modal.
> > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> >
> > BOOL WINAPI AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> > lParam)
> > {
> > switch(msg) {
> > case WM_INITDIALOG: {
> > ...init stuff
> > return TRUE;
> > }
> >
> > case WM_COMMAND: {
> > if (wParam == ID_BTN_HIGHSCORE) // clicked high score btn
> > *---> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HIGHSCORE),
> > hDlg, HighScoreDlgProc);
> >
> > if (wParam == IDCANCEL || wParam == IDOK) { // Close button
> > EndDialog(hDlg, TRUE);
> > return TRUE;
> > }
> > break;
> > }
> > } return FALSE; // Pass off to DefDlgProc
> > }
> >
> > ooooooooooooooooooooooooooooooooooooooo
> > 3. The high score dialog box handler.
> > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> >
> > When I call EndDialog below, not only does the high score dialog
> > close, but the calling About dialog box closes too. Why?
> >
> > BOOL WINAPI HighScoreDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
> > LPARAM lParam)
> > {
> > switch(msg) {
> > case WM_INITDIALOG: {
> > ... init stuff
> > return TRUE; // Message handled
> > }
> >
> > // Handle button clicks
> > case WM_COMMAND: {
> > if (wParam == ID_BTN_CLEAR_HIGHSCORE)
> > ... code handler snipped
> > return TRUE;
> > }
> >
> > // Close the high score dialog
> > if (wParam == IDCANCEL || wParam == IDOK) {
> > *---> EndDialog(hDlg, TRUE); // closes calling dialog too!
> > return TRUE;
> > }
> > break;
> > }
> > } return FALSE;
> > }
> >
> > Thanks!

Re: What's wrong with this code? by Almon

Almon
Sat Jun 19 18:57:43 CDT 2004


Hi,

Assuming you aren't "bouncing" on the
OK button and hitting it twice,
make sure your ID_BTN_HIGHSCORE
resource id isn't goofed-up (if it is the same
value as IDCANCEL or IDOK, it will close
the dialog.)

As a side note, you might want to use
LOWORD(wParam) when you test for
IDCANCEL and IDOK, because you
might want it to work for a keyboard as
well. I have also seen the ok button
produce a highword of 0x1000--Maybe
it doesn't happen in dialog boxes, but why
not be safe?

Hope this helps...

Almon B. Strowger
KOOK Pocket Software


"Mike Welch" <michaelw@techemail.com> wrote in message
news:b3ce3d49.0406191452.473f9621@posting.google.com...
> You make a good point, I didn't think about it just being a focus
> thing. I tend to think it's closed though, because my program itself
> is a small dialog to begin with (about half the PPC screen volume
> wise). I can move it around such that I can see what's behind it, in
> other words. It's not just back in the Zorder at least.
>
> I'll check remote spy though. Good idea.
>
> But you didn't see anything that looked wrong and it should be able to
> return to DialogB then?
>
> Thanks!
>
> Mike
>
> "Michael J. Salamone [eMVP]" <mikesa#at#entrek#dot#com> wrote in message
news:<#Myr#MGVEHA.3944@tk2msftngp13.phx.gbl>...
> > Does DialogB actually close, or is it in the background?
> >
> > If it actually closes, then set a breakpoint on any calls to EndDialog()
and
> > you should get there.
> >
> > Also run Remote Spy (eVC Tools menu) to see if somehow it's getting
> > WM_CLOSE. Does your own code ever post or send that message?
> >
> > If it goes in the background, the Remote Spy may indicate why. But, to
> > "fix", just call SetForegroundWindow() when DialogC returns.
> > --
> >
> > Michael Salamone [eMVP]
> > Entrek Software, Inc.
> > www.entrek.com
> >
> >
> >
> > "Mike Welch" <michaelw@techemail.com> wrote in message
> > news:b3ce3d49.0406170247.4b5a3e8@posting.google.com...
> > > I didn't get a reply to this, so I thought I'd try again.
> > >
> > > MainDialogA [shows]--> DialogB [shows]--> DialogC
> > >
> > > When you click the "OK" button in DialogC, rather than going back to
> > > DialogB as expected, it closes too!
> > >
> > > Could this be a limitation of nested dialogs?
> > >
> > > Thanks!
> > >
> > > Mike Welch
> > >
> > > ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> > > 1. In the main dialog WndProc I handle the about button
> > > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > > ...
> > >
> > > BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> > > lParam)
> > > ...
> > > if(wParam == IDC_ABOUT) {
> > > DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), g_hMainWnd,
> > > AboutDlgProc);
> > > break;
> > > }
> > > ...
> > >
> > >
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> > > 2. The about dialog box handler opens a high score dialog box, also
> > > modal.
> > >
OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > >
> > > BOOL WINAPI AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> > > lParam)
> > > {
> > > switch(msg) {
> > > case WM_INITDIALOG: {
> > > ...init stuff
> > > return TRUE;
> > > }
> > >
> > > case WM_COMMAND: {
> > > if (wParam == ID_BTN_HIGHSCORE) // clicked high score btn
> > > *---> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HIGHSCORE),
> > > hDlg, HighScoreDlgProc);
> > >
> > > if (wParam == IDCANCEL || wParam == IDOK) { // Close button
> > > EndDialog(hDlg, TRUE);
> > > return TRUE;
> > > }
> > > break;
> > > }
> > > } return FALSE; // Pass off to DefDlgProc
> > > }
> > >
> > > ooooooooooooooooooooooooooooooooooooooo
> > > 3. The high score dialog box handler.
> > > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > >
> > > When I call EndDialog below, not only does the high score dialog
> > > close, but the calling About dialog box closes too. Why?
> > >
> > > BOOL WINAPI HighScoreDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
> > > LPARAM lParam)
> > > {
> > > switch(msg) {
> > > case WM_INITDIALOG: {
> > > ... init stuff
> > > return TRUE; // Message handled
> > > }
> > >
> > > // Handle button clicks
> > > case WM_COMMAND: {
> > > if (wParam == ID_BTN_CLEAR_HIGHSCORE)
> > > ... code handler snipped
> > > return TRUE;
> > > }
> > >
> > > // Close the high score dialog
> > > if (wParam == IDCANCEL || wParam == IDOK) {
> > > *---> EndDialog(hDlg, TRUE); // closes calling dialog too!
> > > return TRUE;
> > > }
> > > break;
> > > }
> > > } return FALSE;
> > > }
> > >
> > > Thanks!



Re: What's wrong with this code? by Michael

Michael
Sat Jun 19 22:33:51 CDT 2004

Besides the possibility of ID_BTN_HIGHSCORE being the same as one of the
others, the other "if" should really be "else if". I.e.

if (wParam == ID_BTN_HIGHSCORE) // clicked high score btn
*---> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HIGHSCORE),
hDlg, HighScoreDlgProc);

ELSE if (wParam == IDCANCEL || wParam == IDOK) { // Close button
EndDialog(hDlg, TRUE);
return TRUE;
}

You can use Remote Spy and/or Remote Process Viewer to determine if the
application is still running after closing Dialog C.
--

Michael Salamone [eMVP]
Entrek Software, Inc.
www.entrek.com



"Almon B. Strowger" <strowger@NOSPAM.kook.com> wrote in message
news:u6Pr0klVEHA.1380@TK2MSFTNGP09.phx.gbl...
>
> Hi,
>
> Assuming you aren't "bouncing" on the
> OK button and hitting it twice,
> make sure your ID_BTN_HIGHSCORE
> resource id isn't goofed-up (if it is the same
> value as IDCANCEL or IDOK, it will close
> the dialog.)
>
> As a side note, you might want to use
> LOWORD(wParam) when you test for
> IDCANCEL and IDOK, because you
> might want it to work for a keyboard as
> well. I have also seen the ok button
> produce a highword of 0x1000--Maybe
> it doesn't happen in dialog boxes, but why
> not be safe?
>
> Hope this helps...
>
> Almon B. Strowger
> KOOK Pocket Software
>
>
> "Mike Welch" <michaelw@techemail.com> wrote in message
> news:b3ce3d49.0406191452.473f9621@posting.google.com...
> > You make a good point, I didn't think about it just being a focus
> > thing. I tend to think it's closed though, because my program itself
> > is a small dialog to begin with (about half the PPC screen volume
> > wise). I can move it around such that I can see what's behind it, in
> > other words. It's not just back in the Zorder at least.
> >
> > I'll check remote spy though. Good idea.
> >
> > But you didn't see anything that looked wrong and it should be able to
> > return to DialogB then?
> >
> > Thanks!
> >
> > Mike
> >
> > "Michael J. Salamone [eMVP]" <mikesa#at#entrek#dot#com> wrote in message
> news:<#Myr#MGVEHA.3944@tk2msftngp13.phx.gbl>...
> > > Does DialogB actually close, or is it in the background?
> > >
> > > If it actually closes, then set a breakpoint on any calls to
EndDialog()
> and
> > > you should get there.
> > >
> > > Also run Remote Spy (eVC Tools menu) to see if somehow it's getting
> > > WM_CLOSE. Does your own code ever post or send that message?
> > >
> > > If it goes in the background, the Remote Spy may indicate why. But,
to
> > > "fix", just call SetForegroundWindow() when DialogC returns.
> > > --
> > >
> > > Michael Salamone [eMVP]
> > > Entrek Software, Inc.
> > > www.entrek.com
> > >
> > >
> > >
> > > "Mike Welch" <michaelw@techemail.com> wrote in message
> > > news:b3ce3d49.0406170247.4b5a3e8@posting.google.com...
> > > > I didn't get a reply to this, so I thought I'd try again.
> > > >
> > > > MainDialogA [shows]--> DialogB [shows]--> DialogC
> > > >
> > > > When you click the "OK" button in DialogC, rather than going back to
> > > > DialogB as expected, it closes too!
> > > >
> > > > Could this be a limitation of nested dialogs?
> > > >
> > > > Thanks!
> > > >
> > > > Mike Welch
> > > >
> > > > ooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> > > > 1. In the main dialog WndProc I handle the about button
> > > > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > > > ...
> > > >
> > > > BOOL WINAPI MainDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> > > > lParam)
> > > > ...
> > > > if(wParam == IDC_ABOUT) {
> > > > DialogBox(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), g_hMainWnd,
> > > > AboutDlgProc);
> > > > break;
> > > > }
> > > > ...
> > > >
> > > >
> oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
> > > > 2. The about dialog box handler opens a high score dialog box, also
> > > > modal.
> > > >
> OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > > >
> > > > BOOL WINAPI AboutDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM
> > > > lParam)
> > > > {
> > > > switch(msg) {
> > > > case WM_INITDIALOG: {
> > > > ...init stuff
> > > > return TRUE;
> > > > }
> > > >
> > > > case WM_COMMAND: {
> > > > if (wParam == ID_BTN_HIGHSCORE) // clicked high score btn
> > > > *---> DialogBox(g_hInst, MAKEINTRESOURCE(IDD_HIGHSCORE),
> > > > hDlg, HighScoreDlgProc);
> > > >
> > > > if (wParam == IDCANCEL || wParam == IDOK) { // Close button
> > > > EndDialog(hDlg, TRUE);
> > > > return TRUE;
> > > > }
> > > > break;
> > > > }
> > > > } return FALSE; // Pass off to DefDlgProc
> > > > }
> > > >
> > > > ooooooooooooooooooooooooooooooooooooooo
> > > > 3. The high score dialog box handler.
> > > > OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
> > > >
> > > > When I call EndDialog below, not only does the high score dialog
> > > > close, but the calling About dialog box closes too. Why?
> > > >
> > > > BOOL WINAPI HighScoreDlgProc(HWND hDlg, UINT msg, WPARAM wParam,
> > > > LPARAM lParam)
> > > > {
> > > > switch(msg) {
> > > > case WM_INITDIALOG: {
> > > > ... init stuff
> > > > return TRUE; // Message handled
> > > > }
> > > >
> > > > // Handle button clicks
> > > > case WM_COMMAND: {
> > > > if (wParam == ID_BTN_CLEAR_HIGHSCORE)
> > > > ... code handler snipped
> > > > return TRUE;
> > > > }
> > > >
> > > > // Close the high score dialog
> > > > if (wParam == IDCANCEL || wParam == IDOK) {
> > > > *---> EndDialog(hDlg, TRUE); // closes calling dialog too!
> > > > return TRUE;
> > > > }
> > > > break;
> > > > }
> > > > } return FALSE;
> > > > }
> > > >
> > > > Thanks!
>
>