1 | /***
|
---|
2 | This file belongs to the Gotcha! distribution.
|
---|
3 | Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
|
---|
4 |
|
---|
5 | This program is free software; you can redistribute it and/or modify
|
---|
6 | it under the terms of the GNU General Public License as published by
|
---|
7 | the Free Software Foundation; either version 2 of the License, or
|
---|
8 | (at your option) any later version.
|
---|
9 |
|
---|
10 | This program is distributed in the hope that it will be useful,
|
---|
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
13 | GNU General Public License for more details.
|
---|
14 |
|
---|
15 | You should have received a copy of the GNU General Public License
|
---|
16 | along with this program; if not, write to the Free Software
|
---|
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
18 | ***/
|
---|
19 |
|
---|
20 | // ** CreateMainWindow **************************************************** /*FOLD00*/
|
---|
21 |
|
---|
22 | HWND CreateMainWindow (VOID)
|
---|
23 | {
|
---|
24 | #ifdef _QUIET_
|
---|
25 | //#if 1
|
---|
26 | hwndFrame = WinLoadDlg (HWND_OBJECT, NULLHANDLE, NULL, GETMODULE,
|
---|
27 | ID_DLG_MAIN, NULL);
|
---|
28 | #else
|
---|
29 | hwndFrame = WinLoadDlg (HWND_DESKTOP, NULLHANDLE, NULL, GETMODULE,
|
---|
30 | ID_DLG_MAIN, NULL);
|
---|
31 | #endif
|
---|
32 | OldFrameWP = WinSubclassWindow (hwndFrame, FrameProcedure);
|
---|
33 |
|
---|
34 | // attach the icon
|
---|
35 | if (HPOINTER hicon = WinLoadPointer (HWND_DESKTOP, GETMODULE, 1))
|
---|
36 | WinSendMsg (hwndFrame, WM_SETICON, MPFROMLONG (hicon), NULL);
|
---|
37 |
|
---|
38 | // attach the accelerator table
|
---|
39 | if (HACCEL haccel = WinLoadAccelTable (hab, GETMODULE, 1))
|
---|
40 | WinSetAccelTable (hab, haccel, hwndFrame);
|
---|
41 |
|
---|
42 | // add extensions to system menu
|
---|
43 | static MENUITEM MenuAbout = { MIT_END, MIS_TEXT, 0, WID_PB_ABOUT, 0, 0 };
|
---|
44 | static MENUITEM MenuSettings = { MIT_END, MIS_TEXT, 0, WID_PB_SETTINGS, 0, 0 };
|
---|
45 | static MENUITEM MenuGeneralHelp = { MIT_END, MIS_TEXT, 0, HM_GENERAL_HELP, 0, 0 };
|
---|
46 | static MENUITEM MenuSeparator = { MIT_END, MIS_SEPARATOR, 0, 0, 0, 0 };
|
---|
47 |
|
---|
48 | AddSysMenuItem (hwndFrame, &MenuSeparator, NULL);
|
---|
49 | AddSysMenuItem (hwndFrame, &MenuSettings, RSTR(IDS_SETTINGS));
|
---|
50 | AddSysMenuItem (hwndFrame, &MenuGeneralHelp, RSTR(IDS_GENERALHELP));
|
---|
51 | AddSysMenuItem (hwndFrame, &MenuAbout, RSTR(IDS_PRODUCTINFORMATION));
|
---|
52 |
|
---|
53 | HWND hwnd = WinWindowFromID (hwndFrame, FID_CLIENT);
|
---|
54 |
|
---|
55 | // select the radio button
|
---|
56 | switch (pset->QuerySaveStyle ())
|
---|
57 | {
|
---|
58 | case SAVESTYLE_CLIPBOARD:
|
---|
59 | WinSendDlgItemMsg (hwnd, WID_RB_CLIPBOARD, BM_CLICK,
|
---|
60 | MPFROMSHORT (TRUE), 0); break;
|
---|
61 | default:
|
---|
62 | WinSendDlgItemMsg (hwnd, WID_RB_FILE, BM_CLICK,
|
---|
63 | MPFROMSHORT (TRUE), 0); break;
|
---|
64 | }
|
---|
65 | AdjustSaveTypeButtons (BOOL (pset->QueryFileSaveStyle ()==FSS_FORCEFILE));
|
---|
66 |
|
---|
67 | if (pset->SerialCapture ())
|
---|
68 | WinEnableWindow (WinWindowFromID (hwnd, WID_CB_DELAYEDCAPTURE), FALSE);
|
---|
69 |
|
---|
70 | // adjust the other buttons
|
---|
71 | WinSendDlgItemMsg (hwnd, WID_CB_HIDEWINDOW, BM_SETCHECK,
|
---|
72 | MPFROMLONG (pset->HideWindow ()), MPFROMLONG (0));
|
---|
73 | WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
|
---|
74 | MPFROMLONG (pset->DelayedCapture ()), MPFROMLONG (0));
|
---|
75 | return hwndFrame;
|
---|
76 | }
|
---|
77 |
|
---|
78 | // ** Drag **************************************************************** /*FOLD00*/
|
---|
79 |
|
---|
80 | VOID Drag (HWND hwnd)
|
---|
81 | {
|
---|
82 | // determine the new window position
|
---|
83 | TRACKINFO trackinfo ;
|
---|
84 | memset (&trackinfo, 0, sizeof (trackinfo));
|
---|
85 |
|
---|
86 | trackinfo.cxBorder = 1;
|
---|
87 | trackinfo.cyBorder = 1;
|
---|
88 | trackinfo.cxGrid = 1;
|
---|
89 | trackinfo.cyGrid = 1;
|
---|
90 | trackinfo.cxKeyboard = 8;
|
---|
91 | trackinfo.cyKeyboard = 8;
|
---|
92 |
|
---|
93 | SWP swp;
|
---|
94 | WinQueryWindowPos (hwnd, &swp);
|
---|
95 | trackinfo.rclTrack.xLeft = swp.x;
|
---|
96 | trackinfo.rclTrack.xRight = swp.x + swp.cx;
|
---|
97 | trackinfo.rclTrack.yBottom = swp.y;
|
---|
98 | trackinfo.rclTrack.yTop = swp.y + swp.cy;
|
---|
99 |
|
---|
100 | WinQueryWindowPos (HWND_DESKTOP, &swp);
|
---|
101 | trackinfo.rclBoundary.xLeft = swp.x;
|
---|
102 | trackinfo.rclBoundary.xRight = swp.x + swp.cx;
|
---|
103 | trackinfo.rclBoundary.yBottom = swp.y;
|
---|
104 | trackinfo.rclBoundary.yTop = swp.y + swp.cy;
|
---|
105 |
|
---|
106 | trackinfo.ptlMinTrackSize.x = 0;
|
---|
107 | trackinfo.ptlMinTrackSize.y = 0;
|
---|
108 | trackinfo.ptlMaxTrackSize.x = swp.cx;
|
---|
109 | trackinfo.ptlMaxTrackSize.y = swp.cy;
|
---|
110 |
|
---|
111 | trackinfo.fs = TF_MOVE | TF_STANDARD | TF_ALLINBOUNDARY;
|
---|
112 |
|
---|
113 | if (WinTrackRect (HWND_DESKTOP, 0, &trackinfo))
|
---|
114 | WinSetWindowPos (hwnd, 0, trackinfo.rclTrack.xLeft,
|
---|
115 | trackinfo.rclTrack.yBottom, 0, 0, SWP_MOVE);
|
---|
116 | }
|
---|
117 |
|
---|
118 | // ** FrameProcedure ****************************************************** /*FOLD00*/
|
---|
119 |
|
---|
120 | MRESULT EXPENTRY FrameProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
121 | {
|
---|
122 | // ATTENTION: used by both main & snapshot window!
|
---|
123 |
|
---|
124 | switch (msg)
|
---|
125 | {
|
---|
126 | case WM_QUERYTRACKINFO:
|
---|
127 | {
|
---|
128 | OldFrameWP (hwnd, msg, mp1, mp2);
|
---|
129 | PTRACKINFO pti = PTRACKINFO (mp2);
|
---|
130 | pti->ptlMinTrackSize.x = pti->ptlMinTrackSize.y = 16;
|
---|
131 | }
|
---|
132 | return MRESULT (TRUE);
|
---|
133 |
|
---|
134 | case WM_WINDOWPOSCHANGED:
|
---|
135 | if ((PSWP (mp1)->fl & SWP_HIDE))
|
---|
136 | WinPostMsg (WinWindowFromID (hwnd, FID_CLIENT),
|
---|
137 | UM_WINDOWHIDDEN, 0,0);
|
---|
138 | break;
|
---|
139 | }
|
---|
140 |
|
---|
141 | return OldFrameWP (hwnd, msg, mp1, mp2);
|
---|
142 | }
|
---|
143 |
|
---|
144 | // ** WindowProcedure ***************************************************** /*FOLD00*/
|
---|
145 |
|
---|
146 | MRESULT EXPENTRY WindowProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
147 | {
|
---|
148 | static BOOL fInterior = FALSE;
|
---|
149 | static USHORT usState = STATE_IDLE, usCap;
|
---|
150 | static ULONG ulTimer, ulCountdown;
|
---|
151 | static HWND hwndCap, hwndParent;
|
---|
152 | static RECTL rcl;
|
---|
153 |
|
---|
154 | #ifdef _DOLOGDEBUG_
|
---|
155 | LogDebug( "MainWin:WindowProcedure:Message 0x%04x", msg );
|
---|
156 | #endif
|
---|
157 |
|
---|
158 | switch (msg)
|
---|
159 | {
|
---|
160 | case WM_CREATE:
|
---|
161 | {
|
---|
162 | #ifdef _DOLOGDEBUG_
|
---|
163 | LogDebug( "MainWin:WindowProcedure: WM_CREATE" );
|
---|
164 | #endif
|
---|
165 | USHORT usResID = WinQueryWindowUShort (hwnd, QWS_ID);
|
---|
166 |
|
---|
167 | // attach the icon
|
---|
168 | if (HPOINTER hicon = WinLoadPointer (HWND_DESKTOP, GETMODULE, usResID))
|
---|
169 | WinSendMsg (hwnd, WM_SETICON, MPFROMLONG (hicon), MPVOID);
|
---|
170 |
|
---|
171 | RECTL rcl;
|
---|
172 | WinQueryWindowRect (hwndFrame, &rcl);
|
---|
173 | WinCalcFrameRect (hwndFrame, &rcl, TRUE);
|
---|
174 | WinSetWindowPos (WinWindowFromID (hwndFrame, FID_CLIENT), HWND_TOP,
|
---|
175 | rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft,
|
---|
176 | rcl.yTop - rcl.yBottom,
|
---|
177 | SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER);
|
---|
178 | }
|
---|
179 | break;
|
---|
180 |
|
---|
181 | case WM_QUIT:
|
---|
182 | #ifdef _DOLOGDEBUG_
|
---|
183 | LogDebug( "MainWin:WindowProcedure: WM_QUIT" );
|
---|
184 | #endif
|
---|
185 | case WM_SAVEAPPLICATION:
|
---|
186 | #ifdef _DOLOGDEBUG_
|
---|
187 | LogDebug( "MainWin:WindowProcedure: WM_SAVEAPPLICATION" );
|
---|
188 | #endif
|
---|
189 | case WM_CLOSE:
|
---|
190 | #ifdef _DOLOGDEBUG_
|
---|
191 | LogDebug( "MainWin:WindowProcedure: WM_CLOSE" );
|
---|
192 | #endif
|
---|
193 | WinSendMsg (hwnd, UM_ADJUSTSETTINGS, 0,0);
|
---|
194 | break;
|
---|
195 |
|
---|
196 | case UM_ADJUSTSETTINGS:
|
---|
197 | {
|
---|
198 | #ifdef _DOLOGDEBUG_
|
---|
199 | LogDebug( "MainWin:WindowProcedure: UM_ADJUSTSETTINGS" );
|
---|
200 | #endif
|
---|
201 | if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_CLIPBOARD),
|
---|
202 | BM_QUERYCHECK, 0,0))
|
---|
203 | pset->SetSaveStyle (SAVESTYLE_CLIPBOARD);
|
---|
204 | else
|
---|
205 | pset->SetSaveStyle (SAVESTYLE_FILE);
|
---|
206 |
|
---|
207 | BOOL f = FALSE;
|
---|
208 | f = BOOL (WinSendDlgItemMsg (hwnd, WID_CB_HIDEWINDOW,
|
---|
209 | BM_QUERYCHECK, 0, 0));
|
---|
210 | pset->HideWindow (f);
|
---|
211 |
|
---|
212 | f = BOOL (WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE,
|
---|
213 | BM_QUERYCHECK, 0, 0));
|
---|
214 | pset->DelayedCapture (f);
|
---|
215 | }
|
---|
216 | return MRESULT (FALSE);
|
---|
217 |
|
---|
218 | case WM_MOUSEMOVE:
|
---|
219 | // we don't want the mouse pointer to be reset so capture this msg
|
---|
220 | return MRESULT (FALSE);
|
---|
221 |
|
---|
222 | case WM_PAINT:
|
---|
223 | {
|
---|
224 | HPS hps;
|
---|
225 | RECTL rcl;
|
---|
226 | COLOR color = SYSCLR_DIALOGBACKGROUND;
|
---|
227 |
|
---|
228 | HWND hwnd2 = WinWindowFromID (hwnd, WID_RB_CLIPBOARD);
|
---|
229 | WinQueryPresParam (hwnd2, PP_BACKGROUNDCOLOR, 0, NULL,
|
---|
230 | sizeof (color), &color, 0L);
|
---|
231 |
|
---|
232 | hps = WinBeginPaint (hwnd, NULLHANDLE, &rcl);
|
---|
233 | WinQueryWindowRect (hwnd, &rcl);
|
---|
234 | WinFillRect (hps, &rcl, color);
|
---|
235 | WinEndPaint (hps);
|
---|
236 | }
|
---|
237 | break;
|
---|
238 |
|
---|
239 | case WM_COMMAND:
|
---|
240 | #ifdef _DOLOGDEBUG_
|
---|
241 | LogDebug( "MainWin:WindowProcedure: WM_COMMAND" );
|
---|
242 | #endif
|
---|
243 | if (usState != STATE_IDLE)
|
---|
244 | {
|
---|
245 | // this means ESC was pressed
|
---|
246 | if (SHORT1FROMMP (mp1) == DID_CANCEL)
|
---|
247 | WinSendMsg (hwnd, UM_ABORT, 0,0);
|
---|
248 | return MRESULT (FALSE);
|
---|
249 | }
|
---|
250 | else
|
---|
251 | // FIXME pretty yukki to do it this way I guess ...
|
---|
252 | WinSendMsg (hwnd, UM_ADJUSTSETTINGS, 0,0);
|
---|
253 |
|
---|
254 | switch (SHORT1FROMMP (mp1))
|
---|
255 | {
|
---|
256 | case WID_RB_CLIPBOARD:
|
---|
257 | WinSendDlgItemMsg (hwnd, WID_RB_CLIPBOARD, BM_CLICK,
|
---|
258 | MPFROMSHORT (TRUE), PVOID (0));
|
---|
259 | break;
|
---|
260 | case WID_RB_FILE:
|
---|
261 | WinSendDlgItemMsg (hwnd, WID_RB_FILE, BM_CLICK,
|
---|
262 | MPFROMSHORT (TRUE), PVOID (0));
|
---|
263 | break;
|
---|
264 | case WID_CB_HIDEWINDOW:
|
---|
265 | WinSendDlgItemMsg (hwnd, WID_CB_HIDEWINDOW, BM_CLICK,
|
---|
266 | MPFROMSHORT (TRUE), PVOID (0));
|
---|
267 | break;
|
---|
268 | case WID_CB_DELAYEDCAPTURE:
|
---|
269 | WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE, BM_CLICK,
|
---|
270 | MPFROMSHORT (TRUE), PVOID (0));
|
---|
271 | break;
|
---|
272 |
|
---|
273 | case WID_PB_ABOUT:
|
---|
274 | AboutBox (hwnd);
|
---|
275 | break;
|
---|
276 |
|
---|
277 | case WID_PB_SETTINGS:
|
---|
278 | pset->Dialog ();
|
---|
279 | break;
|
---|
280 |
|
---|
281 | case WID_PB_SETCAPTURETYPE:
|
---|
282 | //int capType;
|
---|
283 |
|
---|
284 | switch (pset->QuerySSWCaptureType ())
|
---|
285 | {
|
---|
286 | case CAP_WINDOWINT:
|
---|
287 | WinSendMsg (hwndFrame, WM_COMMAND,
|
---|
288 | MPFROM2SHORT (WID_PB_WINDOWINTERIOR,0), 0);
|
---|
289 | case CAP_SCREENREGION:
|
---|
290 | WinSendMsg (hwndFrame, WM_COMMAND,
|
---|
291 | MPFROM2SHORT (WID_PB_SCREENREGION,0), 0);
|
---|
292 | case CAP_WINDOW:
|
---|
293 | WinSendMsg (hwndFrame, WM_COMMAND,
|
---|
294 | MPFROM2SHORT (WID_PB_WINDOW,0), 0);
|
---|
295 | default:
|
---|
296 | WinSendMsg (hwndFrame, WM_COMMAND,
|
---|
297 | MPFROM2SHORT (WID_PB_SCREEN,0), 0);
|
---|
298 | }
|
---|
299 | break;
|
---|
300 |
|
---|
301 | case WID_PB_SCREEN:
|
---|
302 | usCap = CAP_SCREEN;
|
---|
303 | #ifdef _QUIET_
|
---|
304 | //#if 1
|
---|
305 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
306 | // WinSendMsg (g_hwndSettingsDialog, WM_CLOSE, 0,0); //Needs to go to the setting dialog
|
---|
307 | // Replace current global with pset->GetSettingDialogHwnd () or such
|
---|
308 | // Need for all 4 cases;
|
---|
309 | #endif
|
---|
310 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
311 | break;
|
---|
312 |
|
---|
313 | case WID_PB_SCREENREGION:
|
---|
314 | usCap = CAP_SCREENREGION;
|
---|
315 | #ifdef _QUIET_
|
---|
316 | //#if 1
|
---|
317 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
318 | #endif
|
---|
319 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
320 | break;
|
---|
321 |
|
---|
322 | case WID_PB_WINDOWINTERIOR:
|
---|
323 | usCap = CAP_WINDOWINT;
|
---|
324 | #ifdef _QUIET_
|
---|
325 | //#if 1
|
---|
326 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
327 | #endif
|
---|
328 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
329 | break;
|
---|
330 |
|
---|
331 | case WID_PB_WINDOW:
|
---|
332 | usCap = CAP_WINDOW;
|
---|
333 | #ifdef _QUIET_
|
---|
334 | //#if 1
|
---|
335 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
336 | #endif
|
---|
337 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
338 | break;
|
---|
339 |
|
---|
340 | case WID_PB_EXIT:
|
---|
341 | WinSendMsg (hwnd, WM_CLOSE, 0,0);
|
---|
342 | break;
|
---|
343 |
|
---|
344 | case HM_HELP_CONTENTS: g_phelp->DisplayContents (); break;
|
---|
345 | case HM_HELP_INDEX: g_phelp->DisplayIndex (); break;
|
---|
346 | case HM_KEYS_HELP: g_phelp->DisplayKeysHelp (); break;
|
---|
347 |
|
---|
348 | case HM_GENERAL_HELP:
|
---|
349 | g_phelp->DisplayGeneralHelp ();
|
---|
350 | break;
|
---|
351 |
|
---|
352 | default:
|
---|
353 | break;
|
---|
354 | }
|
---|
355 | return MRESULT (FALSE);
|
---|
356 |
|
---|
357 | case UM_PREPARECAPTURE:
|
---|
358 | WinSendMsg (hwndSnapshot, UM_STARTCAPTURE, 0,0);
|
---|
359 |
|
---|
360 | usState = STATE_WAITFORHIDE;
|
---|
361 |
|
---|
362 | if (usCap == CAP_SCREENREGION || usCap == CAP_SCREEN) {
|
---|
363 | #ifdef _QUIET_
|
---|
364 | hwndParent = WinQueryFocus(HWND_DESKTOP);
|
---|
365 | #else
|
---|
366 | hwndParent = WinQueryWindow(hwndFrame, QW_NEXTTOP );
|
---|
367 | #endif
|
---|
368 | }
|
---|
369 | #ifndef _QUIET_
|
---|
370 | //#if 0
|
---|
371 | if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW))
|
---|
372 | WinShowWindow (WinQueryWindow (hwnd, QW_PARENT), FALSE);
|
---|
373 | else
|
---|
374 | #endif
|
---|
375 | WinSendMsg (hwnd, UM_WINDOWHIDDEN, 0,0);
|
---|
376 | return MRESULT (FALSE);
|
---|
377 |
|
---|
378 | case UM_WINDOWHIDDEN:
|
---|
379 | if (usState == STATE_WAITFORHIDE)
|
---|
380 | {
|
---|
381 | // FIXME
|
---|
382 | // I have no idea why this delay is necessary, but CAP_SCREEN with
|
---|
383 | // hiding our window does not work without it ...
|
---|
384 | DosSleep (100);
|
---|
385 | usState = STATE_SELECTWINDOW;
|
---|
386 | WinSendMsg (hwnd, UM_SELECTWINDOW, 0,0);
|
---|
387 | }
|
---|
388 | return MRESULT (FALSE);
|
---|
389 |
|
---|
390 | case UM_SELECTWINDOW:
|
---|
391 | switch (usCap)
|
---|
392 | {
|
---|
393 | case CAP_SCREEN:
|
---|
394 | usState = STATE_WINDOWSELECTED;
|
---|
395 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
396 | MPFROMHWND (HWND_DESKTOP),
|
---|
397 | MPFROMHWND (HWND_DESKTOP));
|
---|
398 | break;
|
---|
399 |
|
---|
400 | case CAP_SCREENREGION:
|
---|
401 | if (DoTracking (&rcl))
|
---|
402 | {
|
---|
403 | usState = STATE_WINDOWSELECTED;
|
---|
404 | int rc = saymsg2(1, hwnd, "Capture", "Do you wish to continue?");
|
---|
405 |
|
---|
406 | if (rc == 1)
|
---|
407 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
408 | MPFROMHWND (HWND_DESKTOP),
|
---|
409 | MPFROMHWND (HWND_DESKTOP));
|
---|
410 | if (rc == 2)
|
---|
411 | WinSendMsg (hwnd, UM_ABORT, 0,0);
|
---|
412 | if (rc == 3) {
|
---|
413 | pset->Dialog ();
|
---|
414 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
415 | MPFROMHWND (HWND_DESKTOP),
|
---|
416 | MPFROMHWND (HWND_DESKTOP));
|
---|
417 | }
|
---|
418 | }
|
---|
419 | else
|
---|
420 | usState = STATE_IDLE;
|
---|
421 | break;
|
---|
422 |
|
---|
423 | case CAP_WINDOWINT:
|
---|
424 | fInterior = TRUE;
|
---|
425 | StartSelection (hwnd);
|
---|
426 | break;
|
---|
427 |
|
---|
428 | case CAP_WINDOW:
|
---|
429 | fInterior = FALSE;
|
---|
430 | StartSelection (hwnd);
|
---|
431 | break;
|
---|
432 |
|
---|
433 | default:
|
---|
434 | usState = STATE_IDLE;
|
---|
435 | break;
|
---|
436 | }
|
---|
437 | return MRESULT (FALSE);
|
---|
438 |
|
---|
439 | case WM_BUTTON1UP:
|
---|
440 | if (usState != STATE_SELECTWINDOW)
|
---|
441 | return MRESULT (FALSE);
|
---|
442 | else
|
---|
443 | {
|
---|
444 | POINTL ptl;
|
---|
445 | WinQueryPointerPos (HWND_DESKTOP, &ptl);
|
---|
446 |
|
---|
447 | HWND hwndCapture =
|
---|
448 | WinWindowFromPoint (HWND_DESKTOP, &ptl, FALSE);
|
---|
449 |
|
---|
450 | if (hwndCapture && (hwndCapture != HWND_DESKTOP))
|
---|
451 | {
|
---|
452 | HWND hwndOld = hwndCapture;
|
---|
453 |
|
---|
454 | if (fInterior)
|
---|
455 | if (! (hwndCapture = WinWindowFromID (hwndOld,
|
---|
456 | FID_CLIENT)))
|
---|
457 | hwndCapture = WinQueryWindow (hwndOld, QW_BOTTOM);
|
---|
458 |
|
---|
459 | if (hwndCapture && (hwndCapture != HWND_DESKTOP))
|
---|
460 | {
|
---|
461 | usState = STATE_WINDOWSELECTED;
|
---|
462 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
463 | MPFROMHWND (hwndCapture),
|
---|
464 | MPFROMHWND (hwndOld));
|
---|
465 | }
|
---|
466 | else
|
---|
467 | usState = STATE_IDLE;
|
---|
468 | }
|
---|
469 | else
|
---|
470 | usState = STATE_IDLE;
|
---|
471 | }
|
---|
472 | return MRESULT (FALSE);
|
---|
473 |
|
---|
474 | case UM_WINDOWSELECTED:
|
---|
475 | if (usState == STATE_WINDOWSELECTED)
|
---|
476 | {
|
---|
477 | // release the pointing device capture if it is active
|
---|
478 | if (WinQueryCapture (HWND_DESKTOP) == hwnd)
|
---|
479 | WinSetCapture (HWND_DESKTOP, NULLHANDLE);
|
---|
480 |
|
---|
481 | // reset the pointer to normal shape
|
---|
482 | WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,
|
---|
483 | SPTR_ARROW,
|
---|
484 | FALSE));
|
---|
485 | hwndCap = HWND (mp1);
|
---|
486 | if (usCap != CAP_SCREENREGION && usCap != CAP_SCREEN)
|
---|
487 | hwndParent = HWND (mp2);
|
---|
488 | if (pset->SerialCapture ())
|
---|
489 | {
|
---|
490 | ulTimer = WinStartTimer (hab, hwnd, 1, 49);
|
---|
491 | ulCountdown = pset->QuerySerialTime ();
|
---|
492 | }
|
---|
493 | else if (WinQueryButtonCheckstate (hwnd, WID_CB_DELAYEDCAPTURE))
|
---|
494 | {
|
---|
495 | ulTimer = WinStartTimer (hab, hwnd, 1, 990);
|
---|
496 | ulCountdown = pset->QueryDelayTime ();
|
---|
497 | }
|
---|
498 | else
|
---|
499 | {
|
---|
500 | usState = STATE_CAPTURE;
|
---|
501 | WinPostMsg (hwnd, UM_CAPTURE, 0,0);
|
---|
502 | }
|
---|
503 | }
|
---|
504 | return MRESULT (FALSE);
|
---|
505 |
|
---|
506 | case WM_TIMER:
|
---|
507 | ulCountdown --;
|
---|
508 |
|
---|
509 | if( ulCountdown % 20 == 0 ) {
|
---|
510 | WinSendMsg (hwndSnapshot, UM_COUNTDOWN, MPFROMLONG (ulCountdown), 0);
|
---|
511 |
|
---|
512 | if (pset->DelayCountdown () && !pset->SerialCapture ())
|
---|
513 | DoCountdown (ulCountdown);
|
---|
514 | }
|
---|
515 |
|
---|
516 | if (ulCountdown == 0)
|
---|
517 | {
|
---|
518 | WinStopTimer (hab, hwnd, ulTimer);
|
---|
519 | usState = STATE_CAPTURE;
|
---|
520 | WinSendMsg (hwnd, UM_CAPTURE, 0,0);
|
---|
521 | }
|
---|
522 | return MRESULT (FALSE);
|
---|
523 |
|
---|
524 | case UM_CAPTURE:
|
---|
525 | usState = STATE_WAITFORHIDE2;
|
---|
526 | if (pset->SSWHide () && WinIsWindowVisible (hwndSnapshot))
|
---|
527 | WinShowWindow (hwndSnapshot, FALSE);
|
---|
528 | else
|
---|
529 | WinSendMsg (hwnd, UM_CAPTURE2, 0,0);
|
---|
530 | return MRESULT (FALSE);
|
---|
531 |
|
---|
532 | case UM_SSWHIDDEN:
|
---|
533 | // FIXME
|
---|
534 | // I have no idea why this delay is necessary, but CAP_SCREEN with
|
---|
535 | // hiding our window does not work without it ...
|
---|
536 | DosSleep (100);
|
---|
537 | WinSendMsg (hwnd, UM_CAPTURE2, 0,0);
|
---|
538 | return MRESULT (FALSE);
|
---|
539 |
|
---|
540 | case UM_CAPTURE2:
|
---|
541 | if (usState == STATE_WAITFORHIDE2)
|
---|
542 | {
|
---|
543 | HBITMAP hbm;
|
---|
544 |
|
---|
545 | WinEnableWindow (hwnd, FALSE);
|
---|
546 | // capture the window to a bitmap and save this
|
---|
547 | if (usCap == CAP_SCREENREGION)
|
---|
548 | hbm = CaptureWindow (hwndCap, hwndParent, &rcl, FALSE);
|
---|
549 | else if (usCap == CAP_SCREEN)
|
---|
550 | hbm = CaptureWindow (hwndCap, hwndParent, NULL, FALSE);
|
---|
551 | else
|
---|
552 | hbm = CaptureWindow (hwndCap, hwndParent, NULL, TRUE);
|
---|
553 |
|
---|
554 | if (pset->SerialCapture ())
|
---|
555 | {
|
---|
556 | WinStopTimer (hab, hwnd, ulTimer);
|
---|
557 | if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
|
---|
558 | WinShowWindow (hwndSnapshot, TRUE);
|
---|
559 |
|
---|
560 | if (hbm)
|
---|
561 | {
|
---|
562 | usState = STATE_WINDOWSELECTED;
|
---|
563 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
564 | MPFROMHWND (hwndCap),
|
---|
565 | MPFROMHWND (hwndParent));
|
---|
566 | }
|
---|
567 | else
|
---|
568 | WinSendMsg (hwnd, UM_ABORT, 0,0);
|
---|
569 | }
|
---|
570 | else
|
---|
571 | WinSendMsg (hwnd, UM_CLEANUP, 0,0);
|
---|
572 | }
|
---|
573 | return MRESULT (FALSE);
|
---|
574 |
|
---|
575 | case UM_ABORT:
|
---|
576 | DosBeep (100, 500);
|
---|
577 | WinSendMsg (hwnd, UM_CLEANUP, 0,0);
|
---|
578 | return MRESULT (FALSE);
|
---|
579 |
|
---|
580 | case UM_CLEANUP:
|
---|
581 | if (WinQueryCapture (HWND_DESKTOP) == hwnd)
|
---|
582 | WinSetCapture (HWND_DESKTOP, NULLHANDLE);
|
---|
583 |
|
---|
584 | pset->Load ();
|
---|
585 |
|
---|
586 | WinSendMsg (hwndSnapshot, UM_STOPCAPTURE, 0,0);
|
---|
587 | WinStopTimer (hab, hwnd, ulTimer);
|
---|
588 | #ifdef _QUIET_
|
---|
589 | //#if 1
|
---|
590 | // ? FIXME to give option to reshow window.
|
---|
591 | if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW))
|
---|
592 | WinSendMsg (g_hwndSettingsDialog, WM_CLOSE, 0,0);
|
---|
593 | else if (WinIsWindow ( hab, g_hwndSettingsDialog) &&
|
---|
594 | ! WinIsWindowVisible (g_hwndSettingsDialog))
|
---|
595 | WinShowWindow (g_hwndSettingsDialog, TRUE);
|
---|
596 | pset->HideWindow (TRUE);
|
---|
597 | #else
|
---|
598 | // re-show the windows if they are hidden
|
---|
599 | // FIXME using global hwndFrame is pretty yukki
|
---|
600 | if (! WinIsWindowVisible (hwndFrame))
|
---|
601 | WinShowWindow (hwndFrame, TRUE);
|
---|
602 | if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
|
---|
603 | WinShowWindow (hwndSnapshot, TRUE);
|
---|
604 | #endif
|
---|
605 | WinEnableWindow (hwnd, TRUE);
|
---|
606 | WinSetActiveWindow (HWND_DESKTOP, hwnd);
|
---|
607 | usState = STATE_IDLE;
|
---|
608 | return MRESULT (FALSE);
|
---|
609 | }
|
---|
610 |
|
---|
611 | #ifdef _DOLOGDEBUG_
|
---|
612 | LogDebug( "MainWin:WindowProcedure:WinDefWindowProc->0x%04x", msg );
|
---|
613 | #endif
|
---|
614 | return WinDefWindowProc (hwnd, msg, mp1, mp2);
|
---|
615 | }
|
---|
616 |
|
---|
617 | // ************************************************************************
|
---|