[2] | 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 | {
|
---|
[27] | 24 | //#ifdef _QUIET_
|
---|
| 25 | #if 1
|
---|
| 26 | hwndFrame = WinLoadDlg (HWND_OBJECT, NULLHANDLE, NULL, GETMODULE,
|
---|
| 27 | ID_DLG_MAIN, NULL);
|
---|
| 28 | #else
|
---|
[2] | 29 | hwndFrame = WinLoadDlg (HWND_DESKTOP, NULLHANDLE, NULL, GETMODULE,
|
---|
| 30 | ID_DLG_MAIN, NULL);
|
---|
[27] | 31 | #endif
|
---|
[2] | 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 |
|
---|
[27] | 78 | // ** Drag **************************************************************** /*FOLD00*/
|
---|
[2] | 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 |
|
---|
[27] | 118 | // ** FrameProcedure ****************************************************** /*FOLD00*/
|
---|
[2] | 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 |
|
---|
[27] | 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 |
|
---|
[2] | 301 | case WID_PB_SCREEN:
|
---|
| 302 | usCap = CAP_SCREEN;
|
---|
[27] | 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
|
---|
[2] | 310 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
| 311 | break;
|
---|
| 312 |
|
---|
| 313 | case WID_PB_SCREENREGION:
|
---|
| 314 | usCap = CAP_SCREENREGION;
|
---|
[27] | 315 | //#ifdef _Quiet_
|
---|
| 316 | #if 1
|
---|
| 317 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
| 318 | #endif
|
---|
[2] | 319 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
| 320 | break;
|
---|
| 321 |
|
---|
| 322 | case WID_PB_WINDOWINTERIOR:
|
---|
| 323 | usCap = CAP_WINDOWINT;
|
---|
[27] | 324 | //#ifdef _Quiet_
|
---|
| 325 | #if 1
|
---|
| 326 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
| 327 | #endif
|
---|
[2] | 328 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
---|
| 329 | break;
|
---|
| 330 |
|
---|
| 331 | case WID_PB_WINDOW:
|
---|
| 332 | usCap = CAP_WINDOW;
|
---|
[27] | 333 | //#ifdef _Quiet_
|
---|
| 334 | #if 1
|
---|
| 335 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
---|
| 336 | #endif
|
---|
[2] | 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;
|
---|
[27] | 361 |
|
---|
| 362 | if (usCap == CAP_SCREENREGION || usCap == CAP_SCREEN)
|
---|
| 363 | hwndParent = WinQueryFocus(HWND_DESKTOP);
|
---|
| 364 | //#ifndef _QUIET_
|
---|
| 365 | #if 0
|
---|
[2] | 366 | if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW))
|
---|
| 367 | WinShowWindow (WinQueryWindow (hwnd, QW_PARENT), FALSE);
|
---|
| 368 | else
|
---|
[27] | 369 | #endif
|
---|
[2] | 370 | WinSendMsg (hwnd, UM_WINDOWHIDDEN, 0,0);
|
---|
| 371 | return MRESULT (FALSE);
|
---|
| 372 |
|
---|
| 373 | case UM_WINDOWHIDDEN:
|
---|
| 374 | if (usState == STATE_WAITFORHIDE)
|
---|
| 375 | {
|
---|
| 376 | // FIXME
|
---|
| 377 | // I have no idea why this delay is necessary, but CAP_SCREEN with
|
---|
| 378 | // hiding our window does not work without it ...
|
---|
[10] | 379 | DosSleep (100);
|
---|
[2] | 380 | usState = STATE_SELECTWINDOW;
|
---|
| 381 | WinSendMsg (hwnd, UM_SELECTWINDOW, 0,0);
|
---|
| 382 | }
|
---|
| 383 | return MRESULT (FALSE);
|
---|
| 384 |
|
---|
| 385 | case UM_SELECTWINDOW:
|
---|
| 386 | switch (usCap)
|
---|
| 387 | {
|
---|
| 388 | case CAP_SCREEN:
|
---|
| 389 | usState = STATE_WINDOWSELECTED;
|
---|
| 390 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
| 391 | MPFROMHWND (HWND_DESKTOP),
|
---|
| 392 | MPFROMHWND (HWND_DESKTOP));
|
---|
| 393 | break;
|
---|
| 394 |
|
---|
| 395 | case CAP_SCREENREGION:
|
---|
| 396 | if (DoTracking (&rcl))
|
---|
| 397 | {
|
---|
| 398 | usState = STATE_WINDOWSELECTED;
|
---|
[27] | 399 | int rc = saymsg2(1, hwnd, "Capture", "Do you wish to continue?");
|
---|
[28] | 400 |
|
---|
[27] | 401 | if (rc == 1)
|
---|
| 402 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
| 403 | MPFROMHWND (HWND_DESKTOP),
|
---|
| 404 | MPFROMHWND (HWND_DESKTOP));
|
---|
| 405 | if (rc == 2)
|
---|
| 406 | WinSendMsg (hwnd, UM_ABORT, 0,0);
|
---|
| 407 | if (rc == 3) {
|
---|
| 408 | pset->Dialog ();
|
---|
| 409 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
| 410 | MPFROMHWND (HWND_DESKTOP),
|
---|
| 411 | MPFROMHWND (HWND_DESKTOP));
|
---|
| 412 | }
|
---|
[2] | 413 | }
|
---|
| 414 | else
|
---|
| 415 | usState = STATE_IDLE;
|
---|
| 416 | break;
|
---|
| 417 |
|
---|
| 418 | case CAP_WINDOWINT:
|
---|
| 419 | fInterior = TRUE;
|
---|
| 420 | StartSelection (hwnd);
|
---|
| 421 | break;
|
---|
| 422 |
|
---|
| 423 | case CAP_WINDOW:
|
---|
| 424 | fInterior = FALSE;
|
---|
| 425 | StartSelection (hwnd);
|
---|
| 426 | break;
|
---|
| 427 |
|
---|
| 428 | default:
|
---|
| 429 | usState = STATE_IDLE;
|
---|
| 430 | break;
|
---|
| 431 | }
|
---|
| 432 | return MRESULT (FALSE);
|
---|
| 433 |
|
---|
| 434 | case WM_BUTTON1UP:
|
---|
| 435 | if (usState != STATE_SELECTWINDOW)
|
---|
| 436 | return MRESULT (FALSE);
|
---|
| 437 | else
|
---|
| 438 | {
|
---|
| 439 | POINTL ptl;
|
---|
| 440 | WinQueryPointerPos (HWND_DESKTOP, &ptl);
|
---|
| 441 |
|
---|
| 442 | HWND hwndCapture =
|
---|
| 443 | WinWindowFromPoint (HWND_DESKTOP, &ptl, FALSE);
|
---|
| 444 |
|
---|
| 445 | if (hwndCapture && (hwndCapture != HWND_DESKTOP))
|
---|
| 446 | {
|
---|
| 447 | HWND hwndOld = hwndCapture;
|
---|
| 448 |
|
---|
| 449 | if (fInterior)
|
---|
| 450 | if (! (hwndCapture = WinWindowFromID (hwndOld,
|
---|
| 451 | FID_CLIENT)))
|
---|
| 452 | hwndCapture = WinQueryWindow (hwndOld, QW_BOTTOM);
|
---|
| 453 |
|
---|
| 454 | if (hwndCapture && (hwndCapture != HWND_DESKTOP))
|
---|
| 455 | {
|
---|
| 456 | usState = STATE_WINDOWSELECTED;
|
---|
| 457 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
| 458 | MPFROMHWND (hwndCapture),
|
---|
| 459 | MPFROMHWND (hwndOld));
|
---|
| 460 | }
|
---|
| 461 | else
|
---|
| 462 | usState = STATE_IDLE;
|
---|
| 463 | }
|
---|
| 464 | else
|
---|
| 465 | usState = STATE_IDLE;
|
---|
| 466 | }
|
---|
| 467 | return MRESULT (FALSE);
|
---|
| 468 |
|
---|
| 469 | case UM_WINDOWSELECTED:
|
---|
| 470 | if (usState == STATE_WINDOWSELECTED)
|
---|
| 471 | {
|
---|
| 472 | // release the pointing device capture if it is active
|
---|
| 473 | if (WinQueryCapture (HWND_DESKTOP) == hwnd)
|
---|
| 474 | WinSetCapture (HWND_DESKTOP, NULLHANDLE);
|
---|
| 475 |
|
---|
| 476 | // reset the pointer to normal shape
|
---|
| 477 | WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP,
|
---|
| 478 | SPTR_ARROW,
|
---|
| 479 | FALSE));
|
---|
| 480 | hwndCap = HWND (mp1);
|
---|
[27] | 481 | if (usCap != CAP_SCREENREGION && usCap != CAP_SCREEN)
|
---|
| 482 | hwndParent = HWND (mp2);
|
---|
[2] | 483 | if (pset->SerialCapture ())
|
---|
| 484 | {
|
---|
| 485 | ulTimer = WinStartTimer (hab, hwnd, 1, 49);
|
---|
| 486 | ulCountdown = pset->QuerySerialTime ();
|
---|
| 487 | }
|
---|
| 488 | else if (WinQueryButtonCheckstate (hwnd, WID_CB_DELAYEDCAPTURE))
|
---|
| 489 | {
|
---|
| 490 | ulTimer = WinStartTimer (hab, hwnd, 1, 990);
|
---|
| 491 | ulCountdown = pset->QueryDelayTime ();
|
---|
| 492 | }
|
---|
| 493 | else
|
---|
| 494 | {
|
---|
| 495 | usState = STATE_CAPTURE;
|
---|
| 496 | WinPostMsg (hwnd, UM_CAPTURE, 0,0);
|
---|
| 497 | }
|
---|
| 498 | }
|
---|
| 499 | return MRESULT (FALSE);
|
---|
| 500 |
|
---|
| 501 | case WM_TIMER:
|
---|
| 502 | ulCountdown --;
|
---|
| 503 |
|
---|
| 504 | if( ulCountdown % 20 == 0 ) {
|
---|
| 505 | WinSendMsg (hwndSnapshot, UM_COUNTDOWN, MPFROMLONG (ulCountdown), 0);
|
---|
| 506 |
|
---|
| 507 | if (pset->DelayCountdown () && !pset->SerialCapture ())
|
---|
| 508 | DoCountdown (ulCountdown);
|
---|
| 509 | }
|
---|
| 510 |
|
---|
| 511 | if (ulCountdown == 0)
|
---|
| 512 | {
|
---|
| 513 | WinStopTimer (hab, hwnd, ulTimer);
|
---|
| 514 | usState = STATE_CAPTURE;
|
---|
| 515 | WinSendMsg (hwnd, UM_CAPTURE, 0,0);
|
---|
| 516 | }
|
---|
| 517 | return MRESULT (FALSE);
|
---|
| 518 |
|
---|
| 519 | case UM_CAPTURE:
|
---|
| 520 | usState = STATE_WAITFORHIDE2;
|
---|
| 521 | if (pset->SSWHide () && WinIsWindowVisible (hwndSnapshot))
|
---|
| 522 | WinShowWindow (hwndSnapshot, FALSE);
|
---|
| 523 | else
|
---|
| 524 | WinSendMsg (hwnd, UM_CAPTURE2, 0,0);
|
---|
| 525 | return MRESULT (FALSE);
|
---|
| 526 |
|
---|
| 527 | case UM_SSWHIDDEN:
|
---|
| 528 | // FIXME
|
---|
| 529 | // I have no idea why this delay is necessary, but CAP_SCREEN with
|
---|
| 530 | // hiding our window does not work without it ...
|
---|
[10] | 531 | DosSleep (100);
|
---|
[2] | 532 | WinSendMsg (hwnd, UM_CAPTURE2, 0,0);
|
---|
| 533 | return MRESULT (FALSE);
|
---|
| 534 |
|
---|
| 535 | case UM_CAPTURE2:
|
---|
| 536 | if (usState == STATE_WAITFORHIDE2)
|
---|
| 537 | {
|
---|
| 538 | HBITMAP hbm;
|
---|
| 539 |
|
---|
| 540 | WinEnableWindow (hwnd, FALSE);
|
---|
| 541 | // capture the window to a bitmap and save this
|
---|
| 542 | if (usCap == CAP_SCREENREGION)
|
---|
[27] | 543 | hbm = CaptureWindow (hwndCap, hwndParent, &rcl, FALSE);
|
---|
| 544 | else if (usCap == CAP_SCREEN)
|
---|
| 545 | hbm = CaptureWindow (hwndCap, hwndParent, NULL, FALSE);
|
---|
[2] | 546 | else
|
---|
| 547 | hbm = CaptureWindow (hwndCap, hwndParent, NULL, TRUE);
|
---|
| 548 |
|
---|
| 549 | if (pset->SerialCapture ())
|
---|
| 550 | {
|
---|
| 551 | WinStopTimer (hab, hwnd, ulTimer);
|
---|
| 552 | if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
|
---|
| 553 | WinShowWindow (hwndSnapshot, TRUE);
|
---|
| 554 |
|
---|
| 555 | if (hbm)
|
---|
| 556 | {
|
---|
| 557 | usState = STATE_WINDOWSELECTED;
|
---|
| 558 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
---|
| 559 | MPFROMHWND (hwndCap),
|
---|
| 560 | MPFROMHWND (hwndParent));
|
---|
| 561 | }
|
---|
| 562 | else
|
---|
| 563 | WinSendMsg (hwnd, UM_ABORT, 0,0);
|
---|
| 564 | }
|
---|
| 565 | else
|
---|
| 566 | WinSendMsg (hwnd, UM_CLEANUP, 0,0);
|
---|
| 567 | }
|
---|
| 568 | return MRESULT (FALSE);
|
---|
| 569 |
|
---|
| 570 | case UM_ABORT:
|
---|
| 571 | DosBeep (100, 500);
|
---|
| 572 | WinSendMsg (hwnd, UM_CLEANUP, 0,0);
|
---|
| 573 | return MRESULT (FALSE);
|
---|
| 574 |
|
---|
| 575 | case UM_CLEANUP:
|
---|
| 576 | if (WinQueryCapture (HWND_DESKTOP) == hwnd)
|
---|
| 577 | WinSetCapture (HWND_DESKTOP, NULLHANDLE);
|
---|
| 578 |
|
---|
[27] | 579 | pset->Load ();
|
---|
| 580 |
|
---|
[2] | 581 | WinSendMsg (hwndSnapshot, UM_STOPCAPTURE, 0,0);
|
---|
| 582 | WinStopTimer (hab, hwnd, ulTimer);
|
---|
[27] | 583 | //#ifdef _QUIET_
|
---|
| 584 | #if 1
|
---|
| 585 | // ? FIXME to give option to reshow window.
|
---|
| 586 | if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW))
|
---|
| 587 | WinSendMsg (g_hwndSettingsDialog, WM_CLOSE, 0,0);
|
---|
| 588 | else if (WinIsWindow ( hab, g_hwndSettingsDialog) &&
|
---|
| 589 | ! WinIsWindowVisible (g_hwndSettingsDialog))
|
---|
| 590 | WinShowWindow (g_hwndSettingsDialog, TRUE);
|
---|
| 591 | pset->HideWindow (TRUE);
|
---|
| 592 | #else
|
---|
[2] | 593 | // re-show the windows if they are hidden
|
---|
| 594 | // FIXME using global hwndFrame is pretty yukki
|
---|
| 595 | if (! WinIsWindowVisible (hwndFrame))
|
---|
| 596 | WinShowWindow (hwndFrame, TRUE);
|
---|
| 597 | if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
|
---|
| 598 | WinShowWindow (hwndSnapshot, TRUE);
|
---|
[27] | 599 | #endif
|
---|
[2] | 600 | WinEnableWindow (hwnd, TRUE);
|
---|
| 601 | WinSetActiveWindow (HWND_DESKTOP, hwnd);
|
---|
| 602 | usState = STATE_IDLE;
|
---|
| 603 | return MRESULT (FALSE);
|
---|
| 604 | }
|
---|
| 605 |
|
---|
| 606 | #ifdef _DOLOGDEBUG_
|
---|
| 607 | LogDebug( "MainWin:WindowProcedure:WinDefWindowProc->0x%04x", msg );
|
---|
| 608 | #endif
|
---|
| 609 | return WinDefWindowProc (hwnd, msg, mp1, mp2);
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | // ************************************************************************
|
---|