Thread: Dialog will not close

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    450

    Unhappy Dialog will not close

    My dialog will not close here is the msg handler and the resource.
    Code:
    // FUNCTIONS //////////////////////////////////////////////
    BOOL CALLBACK PeerToPeerDialogProc(HWND hDlg,UINT msg,WPARAM wparam,LPARAM lparam)
    {
    	switch (msg)
    	{
    		case WM_INITDIALOG:
    			return TRUE;
    		case WM_COMMAND:
                switch( LOWORD(wparam) )
                {
                    case IDOK:
    					break;
                    case IDCANCEL:
                        EndDialog( hDlg, 0 );
                        return TRUE;
                }
    			break;
    	}
    	return FALSE;
    
    }
    Excerpt from the resource:
    Code:
    IDD_DIALOGPEERTOPEER DIALOG DISCARDABLE  0, 0, 356, 196
    STYLE WS_CHILD | WS_CAPTION
    FONT 8, "MS Sans Serif"
    BEGIN
        LTEXT           "Peer to Peer Connection Dialog",IDC_STATIC,126,4,100,8
        LTEXT           "Resource Dialog Test",IDC_STATIC,25,20,73,12
        DEFPUSHBUTTON   "Button1",IDCANCEL,255,140,70,15
    END
    Finally the call to the dialog
    Code:
    if (KEY_DOWN(VK_BACK) || keyboard_state[DIK_BACK])
    	{
    	//ShowWindow(main_window_handle, SW_HIDE);
    		DialogBox(main_instance,MAKEINTRESOURCE(IDD_DIALOGPEERTOPEER),main_window_handle,PeerToPeerDialogProc);
    	//ShowWindow(main_window_handle, SW_SHOW);
    	}

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    IDOK certainly will not close. You aren't calling EndDialog() in it. Is that what you mean?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    since the BUTTON has IDCANCEL won't it send this message to the dialog when pressed or does it send IDOK?

    Anyhow doesn't hitting escape send IDCANCEL to the dialog procedure.

    Both these attempts do not close the dialog.

    In fact it doesn't respond to pressing the button at all.
    Last edited by curlious; 10-20-2003 at 01:15 PM.

  4. #4
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    oh, you don't have an OK button. I see. Well then you should probably remove the case.

    I don't see a problem off hand. Have you debugged? Set a break point at the IDCANCEL location and see if you hit it.
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  5. #5
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    I think I need the IDOK because when you hit enter the defaultbutton issues IDOK if it has focus and if you hit esc it isuues IDCANCEL according to Petzold (unless I misunderstood).

    Anyhow I don't know how to use the debugger and just spent the last hour trying.

    The program appears to freeze after displaying the dialog, no response, the button doesn't depress. I think I need to upload the code and provide a link, but I am feeling to lazy to look up the info about my isp webspace. Is there any free hosting for source code problems like this available?

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    Hurray!!!!!!!!!!!!!!!!!!!!
    I changed the style of the dialog box from child to overlapped, now everything seems to be working and I can continue on.

    Does anybody know what the style child for a dialogbox entails. I thought it just meant child window or somthing. Whatever it was it was causing my program to hang.

    Shwew and I was consider giving up, while still in the learning phase.

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    450
    My app allows you to set a flag for full screen/windowed.
    The windowed app is overlapped with an overlapped dialog.
    The full screen is popup with overlapped dialog.

    I am experiencing near the same problem with the full screen as as I was having with the child dialog.

    This time after the dialog closes and I show the hidden full screen pop up window it doesn't seem to have focus, no input nothing.

    I think this is due to it being popup because the other version(windowed not full screen) works fine.

    Any remarks? If it is focus how do I regain focus to my full screen window?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Dialog box determined to close!!!
    By mhandlon in forum Windows Programming
    Replies: 1
    Last Post: 01-18-2006, 09:33 AM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. Ghost in the CD Drive
    By Natase in forum A Brief History of Cprogramming.com
    Replies: 17
    Last Post: 10-12-2001, 05:38 PM