114 |
DeleteObject(hMenu); |
DeleteObject(hMenu); |
115 |
|
|
116 |
switch (cmd) { |
switch (cmd) { |
117 |
case ID_WMEXIT: |
case ID_WMEXIT: { |
|
{ |
|
118 |
PostQuitMessage(0); |
PostQuitMessage(0); |
119 |
break; |
break; |
120 |
} |
} |
121 |
case ID_WMABOUT: |
case ID_WMABOUT: { |
|
{ |
|
122 |
AboutDlg(); |
AboutDlg(); |
123 |
break; |
break; |
124 |
} |
} |
131 |
LONG WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
LONG WINAPI MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
132 |
{ |
{ |
133 |
switch (uMsg) { |
switch (uMsg) { |
134 |
case WM_DESTROY: |
case WM_DESTROY: { |
|
{ |
|
135 |
PostQuitMessage(0); |
PostQuitMessage(0); |
136 |
return 0; |
return 0; |
137 |
} |
} |
138 |
case WM_TRAY_NOTIFY: |
case WM_TRAY_NOTIFY: { |
|
{ |
|
139 |
if (lParam == WM_RBUTTONDOWN) |
if (lParam == WM_RBUTTONDOWN) |
140 |
DoContextMenu(); |
DoContextMenu(); |
141 |
return 0; |
return 0; |
168 |
return false; |
return false; |
169 |
} |
} |
170 |
|
|
171 |
// create the frame |
// create the frame |
172 |
ghWnd = CreateWindow(szAppName, szAppName, |
ghWnd = CreateWindow(szAppName, szAppName, |
173 |
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | |
WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | |
174 |
WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 640, |
WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 640, |
191 |
// try to load WTSWinClipper.dll |
// try to load WTSWinClipper.dll |
192 |
if (!WTSWinClipper::Init()) { |
if (!WTSWinClipper::Init()) { |
193 |
Message |
Message |
194 |
("Application not installed correctly: Unable to init hookdll.dll."); |
("Application not installed correctly: Unable to init hookdll.dll."); |
195 |
return false; |
return false; |
196 |
} |
} |
197 |
|
|
200 |
// hook in |
// hook in |
201 |
WTSWinClipper::SetCbtHook(); |
WTSWinClipper::SetCbtHook(); |
202 |
return true; |
return true; |
203 |
} |
} else { |
|
else { |
|
204 |
// already hooked |
// already hooked |
205 |
return false; |
return false; |
206 |
} |
} |
207 |
} |
} |
208 |
|
|
209 |
// |
// |
210 |
// our main loop |
// our main loop |
211 |
// |
// |
212 |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, |
224 |
// shell. We do this by calling SystemParametersInfo. If we don't do this, we won't get the WH_SHELL notifications. |
// shell. We do this by calling SystemParametersInfo. If we don't do this, we won't get the WH_SHELL notifications. |
225 |
|
|
226 |
// From MSDN: |
// From MSDN: |
227 |
// Note that custom shell applications do not receive WH_SHELL messages. Therefore, any application that |
// Note that custom shell applications do not receive WH_SHELL messages. Therefore, any application that |
228 |
// registers itself as the default shell must call the SystemParametersInfo function with SPI_SETMINIMIZEDMETRICS |
// registers itself as the default shell must call the SystemParametersInfo function with SPI_SETMINIMIZEDMETRICS |
229 |
// before it (or any other application) can receive WH_SHELL messages. |
// before it (or any other application) can receive WH_SHELL messages. |
230 |
|
|
231 |
MINIMIZEDMETRICS mmm; |
MINIMIZEDMETRICS mmm; |
250 |
&startupInfo, &procInfo); |
&startupInfo, &procInfo); |
251 |
|
|
252 |
if (m_create != false) { |
if (m_create != false) { |
253 |
// A loop to watch the process. |
// A loop to watch the process. |
254 |
GetExitCodeProcess(procInfo.hProcess, &dwExitCode); |
GetExitCodeProcess(procInfo.hProcess, &dwExitCode); |
255 |
|
|
256 |
while (dwExitCode == STILL_ACTIVE) { |
while (dwExitCode == STILL_ACTIVE) { |
261 |
// Release handles |
// Release handles |
262 |
CloseHandle(procInfo.hProcess); |
CloseHandle(procInfo.hProcess); |
263 |
CloseHandle(procInfo.hThread); |
CloseHandle(procInfo.hThread); |
264 |
} |
} else { |
|
else { |
|
265 |
// CreateProcess failed. |
// CreateProcess failed. |
266 |
Message("Unable to launch the requested application"); |
Message("Unable to launch the requested application"); |
267 |
} |
} |
268 |
} |
} else |
|
else |
|
269 |
// we are launching without an app, therefore we will show the system tray app and wait for the user to close it |
// we are launching without an app, therefore we will show the system tray app and wait for the user to close it |
270 |
{ |
{ |
271 |
// create a dummy window to receive WM_QUIT message |
// create a dummy window to receive WM_QUIT message |