HI,
The only purpose of this application is to show a first dialog, where you can open a 2nd one, then close that and the first one.
But when I call DestroyWindow() (= close) on the 2nd dialog, it closes it, minimizes the other one and completely freezes the whole application. I can re-maximize the 1st dialog, but when I click anywhere it just makes "bing".
Again (what happens):
- open dialog 1
- open dialog 2
- close dialog 2
- gets closed, dialog 1 gets minimized
- i can remaximize it, but the whole thing is frozen (just "bing"-sounds)
It's a very small project, I'd really appreciate it if someone could have a look and tell me wtf could be wrong.
[MSVC Project attached, 4.2 kb] (0.01 secs dowload time)
Source files:
main.cpp
#include "windows.h"
#include "res.h"
//========================
// Functions
//
//=======================
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK DlgProc2(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
//========================
// Main
//
//========================
int WINAPI WinMain( HINSTANCE phInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DialogBox(NULL, MAKEINTRESOURCE(IDD_DLG1), NULL, DlgProc);
return 0;
}
//========================
// Dialog procedure for the
// 1st dialog.
//========================
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_COMMAND:
{
switch (LOWORD(wParam)) {
case IDC_OPEN2:
DialogBox(NULL, MAKEINTRESOURCE(IDD_DLG2), hwndDlg, DlgProc2);
return true;
}
break;
}
case WM_CLOSE:
DestroyWindow(hwndDlg);
return true;
}
return false;
}
//========================
// Dialog procedure for the
// 2nd dialog.
//========================
BOOL CALLBACK DlgProc2(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_COMMAND:
{
switch (LOWORD(wParam)) {
case IDC_CLOSE:
DestroyWindow(hwndDlg);
return true;
}
break;
}
case WM_CLOSE:
DestroyWindow(hwndDlg);
return true;
}
return false;
}
res.h
#define IDD_DLG1 1000
#define IDC_OPEN2 1001
#define IDD_DLG2 1100
#define IDC_CLOSE 1101
res.rc
#include "afxres.h"
#include "res.h"
IDD_DLG1 DIALOGEX 6,6,189,100
CAPTION "Dialog 1"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
CONTROL "OPEN DIALOG 2",IDC_OPEN2,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,18,29,148,44
END
IDD_DLG2 DIALOGEX 6,6,189,100
CAPTION "DIALOG 2"
FONT 8,"MS Sans Serif",0,0,0
STYLE WS_VISIBLE|WS_OVERLAPPEDWINDOW
BEGIN
CONTROL "Close",IDC_CLOSE,"Button",WS_CHILD|WS_VISIBLE|WS_TABSTOP,22,29,130,39
END
THANK YOU!