[Win32 api] Can't close dialog window

Hello,

I've come accross this problem several times and I have no idea how to fix this... simply, when I click on "X", the dialog won't close (dialog is my main window)

source code:

http://pastebin.com/2Bs1F0mp

resource:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Generated by ResEdit 1.5.11
// Copyright (C) 2006-2012
// http://www.resedit.net

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>
#include "resource.h"




//
// Menu resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDR_MENU1 MENU
{
    POPUP "File"
    {
        MENUITEM "Save", IDM_SAVE1
        MENUITEM "Load", IDM_LOAD1
        MENUITEM "Exit", IDM_EXIT1
    }
    POPUP "Text"
    {
        MENUITEM "Change Color", IDM_CHANGE_COLOR1
        MENUITEM "Change Scale", IDM_CHANGE_SCALE1
    }
    POPUP "Help"
    {
        MENUITEM "About", IDM_ABOUT1
    }
}



//
// Dialog resources
//
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG1 DIALOG 0, 0, 294, 190
STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_CAPTION | WS_VISIBLE | WS_POPUP | WS_SYSMENU
EXSTYLE WS_EX_WINDOWEDGE
CAPTION "Dream Journal"
MENU IDR_MENU1
CLASS "Window Class"
FONT 8, "Ms Shell Dlg"
{
    CONTROL         "", IDC_TEXT1, RICHEDIT_CLASS, WS_TABSTOP | WS_VSCROLL | WS_BORDER | ES_AUTOVSCROLL | ES_NUMBER | ES_MULTILINE | ES_WANTRETURN, 0, 0, 233, 175
    CONTROL         "", IDC_DATE1, DATETIMEPICK_CLASS, WS_TABSTOP | DTS_RIGHTALIGN, 234, 0, 59, 14
    DEFPUSHBUTTON   "Save Dream", IDC_SAVE1, 239, 22, 50, 14
    PUSHBUTTON      "Load Dream", IDC_LOAD1, 239, 37, 50, 14
}
In your Message Handling loop, after the switch statement, type:
1
2
3
4
case WM_CLOSE:
    EndDialog(hWnd,0); // Use this if you create the dialog via DialogBox function
    PostQuitMessage(0); // Use this if you create the dialog via CreateDialog
    break;
1
2
3
4
5
6
7
8
9
10
11
12
	/*case WM_DESTROY:
		{
			PostQuitMessage(0);
			return 0;
		}
		break;*/
	case WM_CLOSE:
		{
			PostQuitMessage(0);
			return 0;
		}
		break;


not working :(
try..

1
2
3
4
5
6
case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
not working, also I've just got the problem maybe, but I have no idea how to fix it, when I click on that panel where's name and "X" button (don't know how's it called), I'll get dialog in VS with this error

Unhandled exception at 0x74b2723b in DreamJournal.exe: 0xC000041D: An unhandled exception was encountered during a user callback.

+ hWnd 0x002604f4 {unused=0 } HWND__ *

and

lParam 16777983 long

uploading whole project so maybe someone can help me, link will be here in several min

well nvm, virustotal is reporting 2 backdoors, so I'd rather don't upload it
Last edited on
bump? can anyone help me?
closed account (DSLq5Di1)
Stackoverflow @ char szFileName[124000] in your window procedure.. 124k characters for a file path?? use something sane, like the MAX_PATH constant.
finally an answer, thanks! it's working, never thought about this lol :)
Topic archived. No new replies allowed.