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