Dialog box questions
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:
The above is placed in the same location as the same command for the close button of the first dialog box, which works fine.
case IDC_OTHER2: //Pressing an exit button on dialog box 2.
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:
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.
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_SDTSEL), NULL, ToolDlgProc);
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.
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.
STYLE 0x10CE0804 | WS_MAXIMIZEBOX
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.
PostMessage(hwnd, WM_CLOSE, 0, 0);