Thread: Dialog Boxes

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    32

    Angry Dialog Boxes

    Okay I created a dialog box in my windows program and everytime I close the dialog it closes my entire program. I checked it and for some reason I am recieving the WM_DESTROY message after I close the dialog!

    Here is a bit of the code:

    Code:
    // processed by the WM_COMMAND in my MainWndProc
    case IDM_ADCHAR:
    					adchar = DialogBox(g_hInst, IDD_ADCHAR, NULL, ADCharDlgProc);
    					break;
    
    BOOL CALLBACK ADCharDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    
    	switch(message)
    	{
    		case WM_INITDIALOG:
    			return(TRUE);
    
    		case WM_COMMAND:
    
    			switch(LOWORD(wParam))
    			{
    				case IDD_ADCHAR_OK:
    					EndDialog(hwnd, IDD_ADCHAR_OK);
    					return(TRUE);
    					
    				case IDD_ADCHAR_CANCEL:
    					EndDialog(hwnd, IDD_ADCHAR_CANCEL);
    					return(TRUE);
    
    				default:
    					return(TRUE);
    			}
    			return(TRUE);
    			break;
    	}
    
    	return(FALSE);
    
    }
    Thats the only code that deals with the dialog. If you need anymore I can post more, but I'm just wondering why I'm recieving the WM_DESTROY message after closing the dialog box?

    Thanks in advance!

  2. #2
    Registered User sean345's Avatar
    Join Date
    Mar 2002
    Posts
    346
    This is my best guess: It might be sending the WM_DESTROY message for the dialog Handle and not the main window. You need to check which handle is being destroyed.

    - Sean
    If cities were built like software is built, the first woodpecker to come along would level civilization.
    Black Frog Studios

  3. #3
    cerion_
    Guest
    My problem is that I KNOW that my main window is being destroyed. I see it happen. I click "okay" or "cancel" on my dialog and it closes my entire program. I did a check and I made it so then if my main window gets a WM_DESTROY message it will inform me via a message box. And I get that message box everytime I close the dialog.

    Any other suggestions?

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    can you zip up the source and attach to the thread?! you haven't given enough info.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  5. #5
    cerion_
    Guest
    Well I have figured out the problem on my own, thanks anyways.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Common Dialog boxes GetOpenFileName()
    By A10 in forum Windows Programming
    Replies: 3
    Last Post: 09-02-2008, 08:56 PM
  2. Dialog Boxes
    By Thantos in forum Windows Programming
    Replies: 7
    Last Post: 08-26-2003, 12:49 PM
  3. Dialog Boxes and Sliders
    By AtomRiot in forum Windows Programming
    Replies: 4
    Last Post: 01-29-2003, 08:36 AM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM