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