Hi all,
I have a basic win32 app which initialises some global vars then calls
DialogBox() to create a modal dialog (VC7)
When that dialog's showing, I click the [X] in the top right to close the
dialog. My handler code was as follows (nothing complex):
case WM_CLOSE:
{
BOOL bClose = TRUE;
if (s_iViewsOpen > 0) {
int rv = ::MessageBox(hWnd, MSG_ACTIVEVIEWS,
_T("Closing"), MB_YESNO|MB_ICONQUESTION);
if ( IDNO == rv )
bClose = FALSE;
}
if (bClose)
::EndDialog(hWnd, 0);
return 0; // processed
}
If s_iViewsOpen is 0 (no open views), then the application closes; as you'd
expect.
If s_iViewsOpen is greater than 0, the message pops up (MSG_ACTIVEVIEWS is akin
to "views still open... close anyway?").
Click "Yes" and the application closes.
Click "No", however, and the message pops up -again-!
Click "Yes", application exits. Click "No" and nothing further happens (like
you'd expect from clicking "No" the first time!).
Basically, WM_CLOSE seems to be getting sent to the window -twice-?
I altered the WM_CLOSE handler to include a static boolean "bFirstEntry"
variable that's initially set to TRUE. If it's first entry, it does the whole
"are you sure?" bit after setting the variable to FALSE. When the function
re-enters, it simply sets it to TRUE and just returns 0 again.
Personally, I don't see why I should need that hack.
So my questions:
1) Does anyone know why this is happening? Is this standard? (I wouldn't think
so)
2) If it's not standard, anyone have any idea on how I can track down the
problem?
Thanks in advance.
--
TJ Houston
e: [EMAIL PROTECTED]
w: http://myrathi.co.uk/
:
Powered by MTS Professional @ http://myrathi.co.uk/mts-pro/
