diff options
Diffstat (limited to 'CPP/Windows/Control/Dialog.cpp')
-rw-r--r-- | CPP/Windows/Control/Dialog.cpp | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/CPP/Windows/Control/Dialog.cpp b/CPP/Windows/Control/Dialog.cpp index 9ddd234..c8f1bd2 100644 --- a/CPP/Windows/Control/Dialog.cpp +++ b/CPP/Windows/Control/Dialog.cpp | |||
@@ -18,7 +18,14 @@ extern bool g_IsNT; | |||
18 | namespace NWindows { | 18 | namespace NWindows { |
19 | namespace NControl { | 19 | namespace NControl { |
20 | 20 | ||
21 | static INT_PTR APIENTRY DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam) | 21 | static |
22 | #ifdef Z7_OLD_WIN_SDK | ||
23 | BOOL | ||
24 | #else | ||
25 | INT_PTR | ||
26 | #endif | ||
27 | APIENTRY | ||
28 | DialogProcedure(HWND dialogHWND, UINT message, WPARAM wParam, LPARAM lParam) | ||
22 | { | 29 | { |
23 | CWindow tempDialog(dialogHWND); | 30 | CWindow tempDialog(dialogHWND); |
24 | if (message == WM_INITDIALOG) | 31 | if (message == WM_INITDIALOG) |
@@ -45,7 +52,7 @@ bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) | |||
45 | switch (message) | 52 | switch (message) |
46 | { | 53 | { |
47 | case WM_INITDIALOG: return OnInit(); | 54 | case WM_INITDIALOG: return OnInit(); |
48 | case WM_COMMAND: return OnCommand(wParam, lParam); | 55 | case WM_COMMAND: return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam); |
49 | case WM_NOTIFY: return OnNotify((UINT)wParam, (LPNMHDR) lParam); | 56 | case WM_NOTIFY: return OnNotify((UINT)wParam, (LPNMHDR) lParam); |
50 | case WM_TIMER: return OnTimer(wParam, lParam); | 57 | case WM_TIMER: return OnTimer(wParam, lParam); |
51 | case WM_SIZE: return OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); | 58 | case WM_SIZE: return OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); |
@@ -65,19 +72,21 @@ bool CDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) | |||
65 | } | 72 | } |
66 | } | 73 | } |
67 | 74 | ||
68 | bool CDialog::OnCommand(WPARAM wParam, LPARAM lParam) | 75 | /* |
76 | bool CDialog::OnCommand2(WPARAM wParam, LPARAM lParam) | ||
69 | { | 77 | { |
70 | return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam); | 78 | return OnCommand(HIWORD(wParam), LOWORD(wParam), lParam); |
71 | } | 79 | } |
80 | */ | ||
72 | 81 | ||
73 | bool CDialog::OnCommand(int code, int itemID, LPARAM lParam) | 82 | bool CDialog::OnCommand(unsigned code, unsigned itemID, LPARAM lParam) |
74 | { | 83 | { |
75 | if (code == BN_CLICKED) | 84 | if (code == BN_CLICKED) |
76 | return OnButtonClicked(itemID, (HWND)lParam); | 85 | return OnButtonClicked(itemID, (HWND)lParam); |
77 | return false; | 86 | return false; |
78 | } | 87 | } |
79 | 88 | ||
80 | bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */) | 89 | bool CDialog::OnButtonClicked(unsigned buttonID, HWND /* buttonHWND */) |
81 | { | 90 | { |
82 | switch (buttonID) | 91 | switch (buttonID) |
83 | { | 92 | { |
@@ -90,6 +99,28 @@ bool CDialog::OnButtonClicked(int buttonID, HWND /* buttonHWND */) | |||
90 | return true; | 99 | return true; |
91 | } | 100 | } |
92 | 101 | ||
102 | #ifndef UNDER_CE | ||
103 | /* in win2000/win98 : monitor functions are supported. | ||
104 | We need dynamic linking, if we want nt4/win95 support in program. | ||
105 | Even if we compile the code with low (WINVER) value, we still | ||
106 | want to use monitor functions. So we declare missing functions here */ | ||
107 | // #if (WINVER < 0x0500) | ||
108 | #ifndef MONITOR_DEFAULTTOPRIMARY | ||
109 | extern "C" { | ||
110 | DECLARE_HANDLE(HMONITOR); | ||
111 | #define MONITOR_DEFAULTTOPRIMARY 0x00000001 | ||
112 | typedef struct tagMONITORINFO | ||
113 | { | ||
114 | DWORD cbSize; | ||
115 | RECT rcMonitor; | ||
116 | RECT rcWork; | ||
117 | DWORD dwFlags; | ||
118 | } MONITORINFO, *LPMONITORINFO; | ||
119 | WINUSERAPI HMONITOR WINAPI MonitorFromWindow(HWND hwnd, DWORD dwFlags); | ||
120 | WINUSERAPI BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpmi); | ||
121 | } | ||
122 | #endif | ||
123 | #endif | ||
93 | 124 | ||
94 | static bool GetWorkAreaRect(RECT *rect, HWND hwnd) | 125 | static bool GetWorkAreaRect(RECT *rect, HWND hwnd) |
95 | { | 126 | { |
@@ -172,7 +203,7 @@ int CDialog::Units_To_Pixels_X(int units) | |||
172 | return rect.right - rect.left; | 203 | return rect.right - rect.left; |
173 | } | 204 | } |
174 | 205 | ||
175 | bool CDialog::GetItemSizes(int id, int &x, int &y) | 206 | bool CDialog::GetItemSizes(unsigned id, int &x, int &y) |
176 | { | 207 | { |
177 | RECT rect; | 208 | RECT rect; |
178 | if (!::GetWindowRect(GetItem(id), &rect)) | 209 | if (!::GetWindowRect(GetItem(id), &rect)) |
@@ -182,13 +213,13 @@ bool CDialog::GetItemSizes(int id, int &x, int &y) | |||
182 | return true; | 213 | return true; |
183 | } | 214 | } |
184 | 215 | ||
185 | void CDialog::GetClientRectOfItem(int id, RECT &rect) | 216 | void CDialog::GetClientRectOfItem(unsigned id, RECT &rect) |
186 | { | 217 | { |
187 | ::GetWindowRect(GetItem(id), &rect); | 218 | ::GetWindowRect(GetItem(id), &rect); |
188 | ScreenToClient(&rect); | 219 | ScreenToClient(&rect); |
189 | } | 220 | } |
190 | 221 | ||
191 | bool CDialog::MoveItem(int id, int x, int y, int width, int height, bool repaint) | 222 | bool CDialog::MoveItem(unsigned id, int x, int y, int width, int height, bool repaint) |
192 | { | 223 | { |
193 | return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint))); | 224 | return BOOLToBool(::MoveWindow(GetItem(id), x, y, width, height, BoolToBOOL(repaint))); |
194 | } | 225 | } |
@@ -356,8 +387,8 @@ void CDialog::NormalizePosition() | |||
356 | 387 | ||
357 | bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow) | 388 | bool CModelessDialog::Create(LPCTSTR templateName, HWND parentWindow) |
358 | { | 389 | { |
359 | HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this); | 390 | const HWND aHWND = CreateDialogParam(g_hInstance, templateName, parentWindow, DialogProcedure, (LPARAM)this); |
360 | if (aHWND == 0) | 391 | if (!aHWND) |
361 | return false; | 392 | return false; |
362 | Attach(aHWND); | 393 | Attach(aHWND); |
363 | return true; | 394 | return true; |