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