(First, I'm worry about my suck English. If you can understand, could you help me?)
#include <Windows.h>
#include "resource.h"
HINSTANCE hInst;
HWND hDigMain;
BOOL CALLBACK MainDigProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK testProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
hInst = hInstance;
DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), HWND_DESKTOP, MainDigProc);
return 0;
}
BOOL CALLBACK MainDigProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch (iMessage) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDSTART:
if (!IsWindow(hDigMain)) {
hDigMain = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DIALOG2), HWND_DESKTOP, testProc);
ShowWindow(hDigMain, SW_SHOW);
}
return TRUE;
case IDLOAD:
EndDialog(hWnd, IDLOAD);
return TRUE;
case ID_OPTION:
EndDialog(hWnd, ID_OPTION);
return TRUE;
case IDCANCEL:
EndDialog(hWnd, IDLOAD);
return TRUE;
}
break;
}
return FALSE;
}
BOOL CALLBACK testProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
switch (iMessage) {
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDOK:
case IDCANCEL:
EndDialog(hWnd, IDLOAD);
return TRUE;
}
break;
}
return FALSE;
}
I tried popup new window(IDD_DIALOG2) when clicked button ':IDSTART', and close (automatic) old window(IDD_DIALOG1).
What I have tried:
In MainDigProc - WM_COMMAND, EndDialog make close total program. (now I think 'IsWindow' is unnecessary, isn't it?) Did I tried close Parent window, so it make to shut-down program? I'm not sure. Opinion please.