source: trunk/mainwin.cpp@ 51

Last change on this file since 51 was 51, checked in by Gregg Young, 7 years ago

Save setting only if OK is selected; Prevent hang where a selected "window" has focus a steals the mouse/keyboard input from Gotcha Quiet; Change the Gotcha Quiet main window from a WINDOW to a DIALOG; Turn off the beep on abort for cases where the user aborted the capture (still beeps if something failed) Dialog proc changes for Gotcha Quiet dialog reorganization.

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