Archived

This topic is now archived and is closed to further replies.

Win32 closing Modeless dialogs

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I have created a simple win32 app, it opens a dialog box and is modeless, but im having some trouble with closing the dialog box, this is the message handaler for it,
BOOL CALLBACK Deck1DlgProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
HWND g_hToolbar = NULL;
    switch(Message)
    {
        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
	            case WM_CLOSE:
			EndDialog(g_hToolbar,0);
		    return 0;

		    case WM_DESTROY:
		        EndDialog(g_hToolbar,0);
			PostQuitMessage(0);
	            break;
            }
        break;
        default:
            return FALSE;

			
    }
    return TRUE;
}
 
all i want it to do is to return back to my main window, once the x is clicked in the top right hand corner i though this could be achived by

case WM_CLOSE:
     EndDialog(g_hToolbar,0);
return 0;

cheers for any help. [edited by - Emexus on June 5, 2003 11:47:35 AM]

Share this post


Link to post
Share on other sites
Try handling a WM_SYSCOMMAND message with a wParam value of SC_CLOSE.

WM_CLOSE and WM_DESTROY are messages in their own right, not a sub-message of WM_COMMAND. WM_CLOSE is sent when the window/application should terminate, to allow for the application to create a confirmation/save/etc prompt. WM_DESTROY is sent when the window is being destroyed.

Skizz

[edited by - Skizz on June 5, 2003 12:34:09 PM]

Share this post


Link to post
Share on other sites
Cheers for the reply, ive just tried that, and it dosent seem to work, at least not for me, nothing will happen when i click the x,

cheers,

Share this post


Link to post
Share on other sites
While EndDialog seems to have worked for me in general on modaless dialogs, it is stated in the MSDN that modaless dialogs should instead use DestroyWindow to close the window. EndDialog is intended for use exclusively on modal dialogs only. Go figure.

If that doesn''t help you out then maybe we can figure something else out.

Share this post


Link to post
Share on other sites