source: trunk/mainwin.cpp@ 94

Last change on this file since 94 was 94, checked in by Gregg Young, 4 years ago

Add unicode support; Add -i switch for AOS install to GQ; Remove language selection from GQ; Remove help file lang selection from Gotcha; Clean up and rework dialogs/strings

  • Property svn:eol-style set to native
File size: 23.4 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 hwndFrame = WinLoadDlg (HWND_OBJECT, NULLHANDLE, NULL, GETMODULE,
26 ID_DLG_MAIN, NULL);
27#else
28 hwndFrame = WinLoadDlg (HWND_DESKTOP, NULLHANDLE, NULL, GETMODULE,
29 ID_DLG_MAIN, NULL);
30#endif
31 OldFrameWP = WinSubclassWindow (hwndFrame, FrameProcedure);
32#ifndef _QUIET_
33 // attach the icon
34 if (HPOINTER hicon = WinLoadPointer (HWND_DESKTOP, GETMODULE, 1))
35 WinSendMsg (hwndFrame, WM_SETICON, MPFROMLONG (hicon), NULL);
36
37 // attach the accelerator table
38 if (HACCEL haccel = WinLoadAccelTable (hab, GETMODULE, 1))
39 WinSetAccelTable (hab, haccel, hwndFrame);
40#endif
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
80VOID 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
120MRESULT 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
146MRESULT 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#ifndef _QUIET_
161 case WM_CREATE:
162#else
163 case WM_INITDLG:
164#endif
165 {
166#ifdef _DOLOGDEBUG_
167 LogDebug( "MainWin:WindowProcedure: WM_CREATE" );
168#endif
169#ifndef _QUIET_
170 USHORT usResID = WinQueryWindowUShort (hwnd, QWS_ID);
171
172 // attach the icon
173 if (HPOINTER hicon = WinLoadPointer (HWND_DESKTOP, GETMODULE, usResID))
174 WinSendMsg (hwnd, WM_SETICON, MPFROMLONG (hicon), MPVOID);
175
176 RECTL rcl;
177 WinQueryWindowRect (hwndFrame, &rcl);
178 WinCalcFrameRect (hwndFrame, &rcl, TRUE);
179 WinSetWindowPos (WinWindowFromID (hwndFrame, FID_CLIENT), HWND_TOP,
180 rcl.xLeft, rcl.yBottom, rcl.xRight - rcl.xLeft,
181 rcl.yTop - rcl.yBottom,
182 SWP_SHOW | SWP_MOVE | SWP_SIZE | SWP_ZORDER);
183 HMQ hmq;
184 BOOL bUniCodeFont;
185 CHAR ucFont[FACESIZE];
186
187 if (pset->GetLangID() == RU) {
188 hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
189 WinSetCp(hmq, 866);
190 bUniCodeFont = TRUE;
191 }
192 else if (pset->GetLangID() == CZ || pset->GetLangID() == PL) {
193 hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
194 WinSetCp(hmq, 852);
195 bUniCodeFont = TRUE;
196 }
197 else {
198 hmq = WinQueryWindowULong( hwnd, QWL_HMQ);
199 WinSetCp(hmq, 850);
200 }
201
202 if (pset->GetLangID() == RU || pset->GetLangID() == CZ || pset->GetLangID() == PL) {
203 strcpy(ucFont, "9.Times New Roman MT 30");
204 WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
205 }
206 else
207 WinRemovePresParam(hwnd, PP_FONTNAMESIZE);
208#endif
209 }
210#ifdef _QUIET_
211 WinSendDlgItemMsg (hwnd, WID_CB_HIDEWINDOW, BM_SETCHECK,
212 MPFROMLONG (TRUE), MPFROMLONG (0));
213 WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
214 MPFROMLONG (pset->DelayedCapture ()),
215 MPFROMLONG (0));
216 WinSetFocus( WinWindowFromID (g_hwndPage0, WID_RB_FILE), FALSE );
217 return MRESULT (FALSE);
218#else
219 break;
220#endif
221
222 case WM_QUIT:
223#ifdef _DOLOGDEBUG_
224 LogDebug( "MainWin:WindowProcedure: WM_QUIT" );
225#endif
226 case WM_SAVEAPPLICATION:
227#ifdef _DOLOGDEBUG_
228 LogDebug( "MainWin:WindowProcedure: WM_SAVEAPPLICATION" );
229#endif
230 case WM_CLOSE:
231#ifdef _DOLOGDEBUG_
232 LogDebug( "MainWin:WindowProcedure: WM_CLOSE" );
233#endif
234 WinSendMsg (hwnd, UM_ADJUSTSETTINGS, 0,0);
235 break;
236
237 case UM_ADJUSTSETTINGS:
238 {
239#ifdef _DOLOGDEBUG_
240 LogDebug( "MainWin:WindowProcedure: UM_ADJUSTSETTINGS" );
241#endif
242 if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_CLIPBOARD),
243 BM_QUERYCHECK, 0,0))
244 pset->SetSaveStyle (SAVESTYLE_CLIPBOARD);
245 else
246 pset->SetSaveStyle (SAVESTYLE_FILE);
247
248 BOOL f = FALSE;
249 f = BOOL (WinSendDlgItemMsg (hwnd, WID_CB_HIDEWINDOW,
250 BM_QUERYCHECK, 0, 0));
251 pset->HideWindow (f);
252#ifndef _QUIET_
253 f = BOOL (WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE,
254 BM_QUERYCHECK, 0, 0));
255 pset->DelayedCapture (f);
256#endif
257 }
258 return MRESULT (FALSE);
259
260 case WM_MOUSEMOVE:
261 // we don't want the mouse pointer to be reset so capture this msg
262 return MRESULT (FALSE);
263
264#ifndef _QUIET_
265 case WM_PAINT:
266 {
267 HPS hps;
268 RECTL rcl;
269 COLOR color = SYSCLR_DIALOGBACKGROUND;
270
271 HWND hwnd2 = WinWindowFromID (hwnd, WID_RB_CLIPBOARD);
272 WinQueryPresParam (hwnd2, PP_BACKGROUNDCOLOR, 0, NULL,
273 sizeof (color), &color, 0L);
274
275 hps = WinBeginPaint (hwnd, NULLHANDLE, &rcl);
276 WinQueryWindowRect (hwnd, &rcl);
277 WinFillRect (hps, &rcl, color);
278 WinEndPaint (hps);
279 }
280 break;
281#endif
282
283 case WM_COMMAND:
284#ifdef _DOLOGDEBUG_
285 LogDebug( "MainWin:WindowProcedure: WM_COMMAND" );
286#endif
287 if (usState != STATE_IDLE)
288 {
289 //Attempt to open settings probably a hang
290 if (SHORT1FROMMP (mp1) == WID_PB_SETTINGS) {
291 WinSendMsg (hwnd, UM_ABORT, 0,0);
292 pset->Dialog ();
293 }
294 // this means ESC was pressed
295 else if (SHORT1FROMMP (mp1) == DID_CANCEL)
296 WinSendMsg (hwnd, UM_ABORT, MPFROMLONG(1),0);
297 return MRESULT (FALSE);
298 }
299#ifndef _QUIET_
300 else
301 // FIXME pretty yukki to do it this way I guess ...
302 WinSendMsg (hwnd, UM_ADJUSTSETTINGS, 0,0);
303#endif
304 switch (SHORT1FROMMP (mp1))
305 {
306 case WID_RB_CLIPBOARD:
307 WinSendDlgItemMsg (hwnd, WID_RB_CLIPBOARD, BM_CLICK,
308 MPFROMSHORT (TRUE), PVOID (0));
309 break;
310 case WID_RB_FILE:
311 WinSendDlgItemMsg (hwnd, WID_RB_FILE, BM_CLICK,
312 MPFROMSHORT (TRUE), PVOID (0));
313 break;
314 case WID_CB_HIDEWINDOW:
315 WinSendDlgItemMsg (hwnd, WID_CB_HIDEWINDOW, BM_CLICK,
316 MPFROMSHORT (TRUE), PVOID (0));
317 break;
318 case WID_CB_DELAYEDCAPTURE:
319 WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE, BM_CLICK,
320 MPFROMSHORT (TRUE), PVOID (0));
321 break;
322
323 case WID_PB_ABOUT:
324 AboutBox (hwnd);
325 break;
326
327 case WID_PB_SETTINGS:
328 pset->Dialog ();
329 break;
330
331 case WID_PB_SETCAPTURETYPE:
332 //int capType;
333 if (LONGFROMMP(mp2) == 1) {
334 pset->SetSaveStyle (SAVESTYLE_CLIPBOARD);
335 }
336
337 switch (pset->QuerySSWCaptureType ())
338 {
339 case CAP_WINDOWINT:
340 WinSendMsg (hwndFrame, WM_COMMAND,
341 MPFROM2SHORT (WID_PB_WINDOWINTERIOR,0), 0);
342 case CAP_SCREENREGION:
343 WinSendMsg (hwndFrame, WM_COMMAND,
344 MPFROM2SHORT (WID_PB_SCREENREGION,0), 0);
345 case CAP_WINDOW:
346 WinSendMsg (hwndFrame, WM_COMMAND,
347 MPFROM2SHORT (WID_PB_WINDOW,0), 0);
348 default:
349 WinSendMsg (hwndFrame, WM_COMMAND,
350 MPFROM2SHORT (WID_PB_SCREEN,0), 0);
351 }
352 break;
353
354 case WID_PB_SCREEN:
355 usCap = CAP_SCREEN;
356#ifdef _QUIET_
357 WinShowWindow (g_hwndSettingsDialog, FALSE);
358 // WinSendMsg (g_hwndSettingsDialog, WM_CLOSE, 0,0); //Needs to go to the setting dialog
359 // Replace current global with pset->GetSettingDialogHwnd () or such
360 // Need for all 4 cases;
361#endif
362 WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
363 break;
364
365 case WID_PB_SCREENREGION:
366 usCap = CAP_SCREENREGION;
367#ifdef _QUIET_
368 WinShowWindow (g_hwndSettingsDialog, FALSE);
369#endif
370 WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
371 break;
372
373 case WID_PB_WINDOWINTERIOR:
374 usCap = CAP_WINDOWINT;
375#ifdef _QUIET_
376 WinShowWindow (g_hwndSettingsDialog, FALSE);
377#endif
378 WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
379 break;
380
381 case WID_PB_WINDOW:
382 usCap = CAP_WINDOW;
383#ifdef _QUIET_
384 WinShowWindow (g_hwndSettingsDialog, FALSE);
385#endif
386 WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
387 break;
388
389 case WID_PB_EXIT:
390 WinSendMsg (WinWindowFromID (hwndFrame, FID_CLIENT),
391 WM_CLOSE, 0,0);
392 break;
393
394 case HM_HELP_CONTENTS: g_phelp->DisplayContents (); break;
395 case HM_HELP_INDEX: g_phelp->DisplayIndex (); break;
396 case HM_KEYS_HELP: g_phelp->DisplayKeysHelp (); break;
397
398 case HM_GENERAL_HELP:
399 g_phelp->DisplayGeneralHelp ();
400 break;
401
402 default:
403 break;
404 }
405 return MRESULT (FALSE);
406
407 case UM_PREPARECAPTURE:
408 WinSendMsg (hwndSnapshot, UM_STARTCAPTURE, 0,0);
409 usState = STATE_WAITFORHIDE;
410
411 if (usCap == CAP_SCREENREGION || usCap == CAP_SCREEN) {
412#ifdef _QUIET_
413 hwndParent = WinQueryFocus(HWND_DESKTOP);
414#else
415 hwndParent = WinQueryWindow(hwndFrame, QW_NEXTTOP );
416#endif
417 }
418 /*else {
419 SWP swp;
420 CHAR ach[32] = {0};
421
422 WinQueryClassName (WinQueryFocus(HWND_DESKTOP), sizeof (ach), ach);
423 if (stricmp (ach, "#4") == 0) {
424 WinSendMsg (hwnd, UM_ABORT, 0,0);
425 if (usCap == CAP_WINDOW)
426 WinSendMsg (hwndFrame, WM_COMMAND,
427 MPFROM2SHORT (WID_PB_WINDOW,0), 0);
428 else
429 WinSendMsg (hwndFrame, WM_COMMAND,
430 MPFROM2SHORT (WID_PB_WINDOWINTERIOR,0), 0);
431 return MRESULT (FALSE);
432 }
433 } */
434#ifndef _QUIET_
435 if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW)) {
436 WinShowWindow (WinQueryWindow (hwnd, QW_PARENT), FALSE);
437 }
438 else
439#endif
440 WinPostMsg (hwnd, UM_WINDOWHIDDEN, 0,0);
441 return MRESULT (FALSE);
442
443 case UM_WINDOWHIDDEN:
444 if (usState == STATE_WAITFORHIDE)
445 {
446 // FIXME
447 // I have no idea why this delay is necessary, but CAP_SCREEN with
448 // hiding our window does not work without it ...
449 DosSleep (100);
450 usState = STATE_SELECTWINDOW;
451 WinSendMsg (hwnd, UM_SELECTWINDOW, 0,0);
452 }
453 return MRESULT (FALSE);
454
455 case UM_SELECTWINDOW:
456 switch (usCap)
457 {
458 case CAP_SCREEN:
459 usState = STATE_WINDOWSELECTED;
460 WinPostMsg (hwnd, UM_WINDOWSELECTED,
461 MPFROMHWND (HWND_DESKTOP),
462 MPFROMHWND (HWND_DESKTOP));
463 break;
464
465 case CAP_SCREENREGION:
466#ifdef _QUIET_
467 WinSetFocus(HWND_DESKTOP, hwnd);
468#endif
469 if (DoTracking (&rcl))
470 {
471 usState = STATE_WINDOWSELECTED;
472
473 /*int rc = saymsg2(1, hwnd, RSTR(IDS_CAPTURE), RSTR(IDS_WISHCONTINUE));
474
475 if (rc == 1)
476 DosSleep(100); // Let the dialog close*/
477 WinPostMsg (hwnd, UM_WINDOWSELECTED,
478 MPFROMHWND (HWND_DESKTOP),
479 MPFROMHWND (HWND_DESKTOP));
480 /*if (rc == 2)
481 WinSendMsg (hwnd, UM_ABORT, MPFROMLONG(1),0);
482 if (rc == 3) {
483 pset->Dialog ();
484 DosSleep(100); // Let the dialogs close
485 WinPostMsg (hwnd, UM_WINDOWSELECTED,
486 MPFROMHWND (HWND_DESKTOP),
487 MPFROMHWND (HWND_DESKTOP));
488 }*/
489 }
490 else
491 usState = STATE_IDLE;
492 break;
493
494 case CAP_WINDOWINT:
495 fInterior = TRUE;
496#ifdef _QUIET_
497 WinSetFocus(HWND_DESKTOP, hwnd);
498#endif
499 StartSelection (hwnd);
500 break;
501
502 case CAP_WINDOW:
503 fInterior = FALSE;
504#ifdef _QUIET_
505 WinSetFocus(HWND_DESKTOP, hwnd);
506#endif
507 StartSelection (hwnd);
508 break;
509
510 default:
511 usState = STATE_IDLE;
512 break;
513 }
514 return MRESULT (FALSE);
515
516 case WM_BUTTON1UP:
517 if (usState != STATE_SELECTWINDOW)
518 return MRESULT (FALSE);
519 else
520 {
521 POINTL ptl;
522 WinQueryPointerPos (HWND_DESKTOP, &ptl);
523 HWND hwndCapture =
524 WinWindowFromPoint (HWND_DESKTOP, &ptl, FALSE);
525
526 if (hwndCapture && (hwndCapture != HWND_DESKTOP))
527 {
528 HWND hwndOld = hwndCapture;
529
530 if (fInterior)
531 if (! (hwndCapture = WinWindowFromID (hwndOld,
532 FID_CLIENT)))
533 hwndCapture = WinQueryWindow (hwndOld, QW_BOTTOM);
534
535 if (hwndCapture && (hwndCapture != HWND_DESKTOP))
536 {
537 usState = STATE_WINDOWSELECTED;
538 WinPostMsg (hwnd, UM_WINDOWSELECTED,
539 MPFROMHWND (hwndCapture),
540 MPFROMHWND (hwndOld));
541 }
542 else
543 usState = STATE_IDLE;
544 }
545 else
546 usState = STATE_IDLE;
547 }
548 return MRESULT (FALSE);
549
550 case UM_WINDOWSELECTED:
551 if (usState == STATE_WINDOWSELECTED)
552 {
553 // release the pointing device capture if it is active
554 if (WinQueryCapture (HWND_DESKTOP) == hwnd)
555 WinSetCapture (HWND_DESKTOP, NULLHANDLE);
556
557 // reset the pointer to normal shape
558 WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,
559 SPTR_ARROW,
560 FALSE));
561 hwndCap = HWND (mp1);
562 if (usCap != CAP_SCREENREGION && usCap != CAP_SCREEN)
563 hwndParent = HWND (mp2);
564 if (pset->SerialCapture ())
565 {
566 ulTimer = WinStartTimer (hab, hwnd, 1, 49);
567 ulCountdown = pset->QuerySerialTime ();
568 }
569 else if (WinQueryButtonCheckstate (hwnd, WID_CB_DELAYEDCAPTURE))
570 {
571 ulTimer = WinStartTimer (hab, hwnd, 1, 990);
572 ulCountdown = pset->QueryDelayTime ();
573 }
574 else
575 {
576 usState = STATE_CAPTURE;
577 WinPostMsg (hwnd, UM_CAPTURE, 0,0);
578 }
579 }
580 return MRESULT (FALSE);
581
582 case WM_TIMER:
583 ulCountdown --;
584
585 if( ulCountdown % 20 == 0 )
586 WinSendMsg (hwndSnapshot, UM_COUNTDOWN,
587 MPFROMLONG (ulCountdown), 0);
588 if (pset->DelayCountdown () && !pset->SerialCapture ())
589 DoCountdown (ulCountdown);
590
591 if (ulCountdown == 0)
592 {
593 WinStopTimer (hab, hwnd, ulTimer);
594 usState = STATE_CAPTURE;
595 WinSendMsg (hwnd, UM_CAPTURE, 0,0);
596 }
597 return MRESULT (FALSE);
598
599 case UM_CAPTURE:
600 usState = STATE_WAITFORHIDE2;
601#ifndef _QUIET_
602 if (pset->SSWHide () && WinIsWindowVisible (hwndSnapshot))
603 WinShowWindow (hwndSnapshot, FALSE);
604 else
605#endif
606 WinSendMsg (hwnd, UM_CAPTURE2, 0,0);
607 return MRESULT (FALSE);
608
609 case UM_SSWHIDDEN:
610 // FIXME
611 // I have no idea why this delay is necessary, but CAP_SCREEN with
612 // hiding our window does not work without it ...
613 DosSleep (100);
614 WinSendMsg (hwnd, UM_CAPTURE2, 0,0);
615 return MRESULT (FALSE);
616
617 case UM_CAPTURE2:
618 if (usState == STATE_WAITFORHIDE2)
619 {
620 HBITMAP hbm;
621
622 WinEnableWindow (hwnd, FALSE);
623 // capture the window to a bitmap and save this
624 if (usCap == CAP_SCREENREGION)
625 hbm = CaptureWindow (hwndCap, hwndParent, &rcl, FALSE);
626 else if (usCap == CAP_SCREEN)
627 hbm = CaptureWindow (hwndCap, hwndParent, NULL, FALSE);
628 else
629 hbm = CaptureWindow (hwndCap, hwndParent, NULL, TRUE);
630
631 if (pset->SerialCapture ())
632 {
633 WinStopTimer (hab, hwnd, ulTimer);
634#ifndef _QUIET_
635 if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
636 WinShowWindow (hwndSnapshot, TRUE);
637#endif
638 if (hbm)
639 {
640 usState = STATE_WINDOWSELECTED;
641 WinPostMsg (hwnd, UM_WINDOWSELECTED,
642 MPFROMHWND (hwndCap),
643 MPFROMHWND (hwndParent));
644 }
645 else
646 WinSendMsg (hwnd, UM_ABORT, 0,0);
647 }
648 else
649 WinSendMsg (hwnd, UM_CLEANUP, 0,0);
650 }
651 return MRESULT (FALSE);
652
653 case UM_ABORT:
654 if (LONGFROMMP(mp1) != 1)
655 DosBeep (75, 200);
656 WinSendMsg (hwnd, UM_CLEANUP, 0,0);
657 return MRESULT (FALSE);
658
659 case UM_CLEANUP:
660 if (WinQueryCapture (HWND_DESKTOP) == hwnd)
661 WinSetCapture (HWND_DESKTOP, NULLHANDLE);
662
663 pset->Load ();
664
665 WinSendMsg (hwndSnapshot, UM_STOPCAPTURE, 0,0);
666 WinStopTimer (hab, hwnd, ulTimer);
667#ifdef _QUIET_
668 // ? FIXME to give option to reshow window.
669 if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW))
670 WinSendMsg (g_hwndSettingsDialog, WM_CLOSE, 0,0);
671 else if (WinIsWindow ( hab, g_hwndSettingsDialog) &&
672 ! WinIsWindowVisible (g_hwndSettingsDialog))
673 WinShowWindow (g_hwndSettingsDialog, TRUE);
674 pset->HideWindow (TRUE);
675#else
676 // re-show the windows if they are hidden
677 // FIXME using global hwndFrame is pretty yukki
678 if (! WinIsWindowVisible (hwndFrame))
679 WinShowWindow (hwndFrame, TRUE);
680 if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
681 WinShowWindow (hwndSnapshot, TRUE);
682#endif
683 WinEnableWindow (hwnd, TRUE);
684 WinSetActiveWindow (HWND_DESKTOP, hwnd);
685 usState = STATE_IDLE;
686 return MRESULT (FALSE);
687 }
688
689#ifdef _DOLOGDEBUG_
690 LogDebug( "MainWin:WindowProcedure:WinDefWindowProc->0x%04x", msg );
691#endif
692 if (hwnd == g_hwndPage0)
693 return WinDefDlgProc (hwnd, msg, mp1, mp2);
694 else
695 return WinDefWindowProc (hwnd, msg, mp1, mp2);
696}
697
698// ************************************************************************
Note: See TracBrowser for help on using the repository browser.