Dialog box questions

This is a discussion on Dialog box questions within the Windows Programming forums, part of the Platform Specific Boards category; Hi everyone, I think most of this is down to my lack of knowledge, but anyway... I have a program ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    128

    Dialog box questions

    Hi everyone,

    I think most of this is down to my lack of knowledge, but anyway...

    I have a program with two buttons to open two different dialog boxes. The first one works fine, and all the commands I put in place for the buttons on the first dialog box work. Then, when I add the following code for a close button on the second dialog box, nothing happens:

    Code:
    case IDC_OTHER2: //Pressing an exit button on dialog box 2.
    			EndDialog(hwnd, 0);
    			break;
    The above is placed in the same location as the same command for the close button of the first dialog box, which works fine.

    Also, how do I get a dialog based program to appear on the taskbar at the bottom, and how do I give it an 'X' button in the upper right corner? Here is the code I have for creating the main menu of the program:

    Code:
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    	LPSTR lpCmdLine, int nCmdShow)
    {
    	return DialogBox(hInstance, MAKEINTRESOURCE(IDD_SDTSEL), NULL, ToolDlgProc);
    }
    I put this down to my own general lack of knowledge on the subject, so if anyone could point me in the right direction, it would be much appreciated.

    Thanks.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    I guess you should check that the name of the message/button is in fact IDC_OTHER2.

    The big resource for Windows is MSDN. A DialogBox is modal, which I would guess means you're not in very much control about how the window looks and is also why you don't have a close box (the main program is waiting for the return from the box, so switching to the main window/closing the box is verboten). If it makes sense for you to switch back to the main window or close the box (without clicking cancel or equivalent) then you probably don't want a modal dialog.

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    416
    Code:
    STYLE 0x10CE0804 | WS_MAXIMIZEBOX
    That style will enable all the upper right boxes such as close, maximize, minimize. This is taken from one of my resource files, but you can set the style with SetWindowStyle() or something, look on MSDN for it.

    As for the window not closing on IDC_OTHER2, make sure it is within a WM_COMMAND message and is being switched according to the loword of the wParam. Second thing, instead of having a close procedure for IDC_OTHER2, it should post a close message so that only one close procedure exists in the entire application.

    Code:
    case IDC_OTHER2:
        PostMessage(hwnd, WM_CLOSE, 0, 0);
    break;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dialog box problem keeps haunting me
    By Bleech in forum Windows Programming
    Replies: 2
    Last Post: 08-23-2006, 01:12 AM
  2. Display Dialog Box Then Execute
    By stickman in forum C++ Programming
    Replies: 17
    Last Post: 05-10-2006, 11:02 AM
  3. Two quick questions about open file dialog boxes
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2005, 08:49 AM
  4. Get a string from a modal dialog box
    By axr0284 in forum Windows Programming
    Replies: 1
    Last Post: 03-03-2005, 12:39 PM
  5. Add a dialog box to a tab
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 01-10-2005, 07:38 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21