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