Vraag 1: Het probleem met onderstaande code is dat als ik de child window sluit door op het kruisje te drukken de parent ook sluit en dus het hele programma.
Dat zou toch niet zo moeten wezen, want ik heb voor de child window toch een andere window procedure aangegeven.
Vraag 2: Waarom blijft mijn child window inactief?
Ik hoop dat de code duidelijk is.
--code--
Dat zou toch niet zo moeten wezen, want ik heb voor de child window toch een andere window procedure aangegeven.
Vraag 2: Waarom blijft mijn child window inactief?
Ik hoop dat de code duidelijk is.
--code--
C++:
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
| #include <windows.h> const char g_szClassName[] = "myWindowClass"; BOOL RegWinClass(HINSTANCE hInstance, WNDPROC lpfnWndProc) { WNDCLASSEX wc; wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; wc.lpfnWndProc = lpfnWndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hInstance; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wc.lpszMenuName = NULL; wc.lpszClassName = g_szClassName; wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); return RegisterClassEx(&wc); } LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } LRESULT CALLBACK ChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: // PostQuitMessage(0); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG Msg; HWND hwndMain; HWND hwndChild1; //Make main window RegWinClass(hInstance, MainWndProc); hwndMain = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "Main", WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); ShowWindow(hwndMain, nCmdShow); UpdateWindow(hwndMain); //Make child1 window RegWinClass(hInstance, ChildWndProc); hwndChild1 = CreateWindowEx( WS_EX_CLIENTEDGE, g_szClassName, "Child1", WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MAXIMIZEBOX, 0, 0, 100, 100, hwndMain, NULL, hInstance, NULL); ShowWindow(hwndChild1, nCmdShow); UpdateWindow(hwndChild1); //Messageloop while(GetMessage(&Msg, NULL, 0, 0) > 0) { TranslateMessage(&Msg); DispatchMessage(&Msg); } return Msg.wParam; } |
[ Voor 2% gewijzigd door .oisyn op 06-03-2003 17:42 ]