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