| 1 | /***
|
|---|
| 2 | This file belongs to the Gotcha! distribution.
|
|---|
| 3 | Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
|
|---|
| 4 |
|
|---|
| 5 | This program is free software; you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 18 | ***/
|
|---|
| 19 |
|
|---|
| 20 | // ** CreateMainWindow **************************************************** /*FOLD00*/
|
|---|
| 21 |
|
|---|
| 22 | HWND CreateMainWindow (VOID)
|
|---|
| 23 | {
|
|---|
| 24 | #ifdef _QUIET_
|
|---|
| 25 | hwndFrame = WinLoadDlg (HWND_OBJECT, NULLHANDLE, NULL, GETMODULE,
|
|---|
| 26 | ID_DLG_MAIN, NULL);
|
|---|
| 27 | #else
|
|---|
| 28 | hwndFrame = WinLoadDlg (HWND_DESKTOP, NULLHANDLE, NULL, GETMODULE,
|
|---|
| 29 | ID_DLG_MAIN, NULL);
|
|---|
| 30 | #endif
|
|---|
| 31 | OldFrameWP = WinSubclassWindow (hwndFrame, FrameProcedure);
|
|---|
| 32 | #ifndef _QUIET_
|
|---|
| 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);
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | // add extensions to system menu
|
|---|
| 43 | /* static MENUITEM MenuAbout = { MIT_END, MIS_TEXT, 0, WID_PB_ABOUT, 0, 0 };
|
|---|
| 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));
|
|---|
| 51 | AddSysMenuItem (hwndFrame, &MenuAbout, RSTR(IDS_PRODUCTINFORMATION));*/
|
|---|
| 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 |
|
|---|
| 78 | // ** Drag **************************************************************** /*FOLD00*/
|
|---|
| 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 |
|
|---|
| 118 | // ** FrameProcedure ****************************************************** /*FOLD00*/
|
|---|
| 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 | {
|
|---|
| 160 | #ifndef _QUIET_
|
|---|
| 161 | case WM_CREATE:
|
|---|
| 162 | #else
|
|---|
| 163 | case WM_INITDLG:
|
|---|
| 164 | #endif
|
|---|
| 165 | {
|
|---|
| 166 | #ifdef _DOLOGDEBUG_
|
|---|
| 167 | LogDebug( "MainWin:WindowProcedure: WM_CREATE" );
|
|---|
| 168 | #endif
|
|---|
| 169 | #ifndef _QUIET_
|
|---|
| 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);
|
|---|
| 183 | #endif
|
|---|
| 184 | HMQ hmq;
|
|---|
| 185 | BOOL bUniCodeFont = FALSE;
|
|---|
| 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 | }
|
|---|
| 207 | else {
|
|---|
| 208 | strcpy(ucFont, "9.WarpSans");
|
|---|
| 209 | WinSetPresParam(hwnd, PP_FONTNAMESIZE, strlen(ucFont) + 1, ucFont);
|
|---|
| 210 | }
|
|---|
| 211 | }
|
|---|
| 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
|
|---|
| 221 | break;
|
|---|
| 222 | #endif
|
|---|
| 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);
|
|---|
| 254 | #ifndef _QUIET_
|
|---|
| 255 | f = BOOL (WinSendDlgItemMsg (hwnd, WID_CB_DELAYEDCAPTURE,
|
|---|
| 256 | BM_QUERYCHECK, 0, 0));
|
|---|
| 257 | pset->DelayedCapture (f);
|
|---|
| 258 | #endif
|
|---|
| 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 |
|
|---|
| 266 | #ifndef _QUIET_
|
|---|
| 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;
|
|---|
| 283 | #endif
|
|---|
| 284 |
|
|---|
| 285 | case WM_COMMAND:
|
|---|
| 286 | #ifdef _DOLOGDEBUG_
|
|---|
| 287 | LogDebug( "MainWin:WindowProcedure: WM_COMMAND" );
|
|---|
| 288 | #endif
|
|---|
| 289 | if (usState != STATE_IDLE)
|
|---|
| 290 | {
|
|---|
| 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 | }
|
|---|
| 296 | // this means ESC was pressed
|
|---|
| 297 | else if (SHORT1FROMMP (mp1) == DID_CANCEL)
|
|---|
| 298 | WinSendMsg (hwnd, UM_ABORT, MPFROMLONG(1),0);
|
|---|
| 299 | return MRESULT (FALSE);
|
|---|
| 300 | }
|
|---|
| 301 | #ifndef _QUIET_
|
|---|
| 302 | else
|
|---|
| 303 | // FIXME pretty yukki to do it this way I guess ...
|
|---|
| 304 | WinSendMsg (hwnd, UM_ADJUSTSETTINGS, 0,0);
|
|---|
| 305 | #endif
|
|---|
| 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 |
|
|---|
| 333 | case WID_PB_SETCAPTURETYPE:
|
|---|
| 334 | //int capType;
|
|---|
| 335 | if (LONGFROMMP(mp2) == 1) {
|
|---|
| 336 | pset->SetSaveStyle (SAVESTYLE_CLIPBOARD);
|
|---|
| 337 | }
|
|---|
| 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 |
|
|---|
| 356 | case WID_PB_SCREEN:
|
|---|
| 357 | usCap = CAP_SCREEN;
|
|---|
| 358 | #ifdef _QUIET_
|
|---|
| 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
|
|---|
| 364 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
|---|
| 365 | break;
|
|---|
| 366 |
|
|---|
| 367 | case WID_PB_SCREENREGION:
|
|---|
| 368 | usCap = CAP_SCREENREGION;
|
|---|
| 369 | #ifdef _QUIET_
|
|---|
| 370 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
|---|
| 371 | #endif
|
|---|
| 372 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
|---|
| 373 | break;
|
|---|
| 374 |
|
|---|
| 375 | case WID_PB_WINDOWINTERIOR:
|
|---|
| 376 | usCap = CAP_WINDOWINT;
|
|---|
| 377 | #ifdef _QUIET_
|
|---|
| 378 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
|---|
| 379 | #endif
|
|---|
| 380 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
|---|
| 381 | break;
|
|---|
| 382 |
|
|---|
| 383 | case WID_PB_WINDOW:
|
|---|
| 384 | usCap = CAP_WINDOW;
|
|---|
| 385 | #ifdef _QUIET_
|
|---|
| 386 | WinShowWindow (g_hwndSettingsDialog, FALSE);
|
|---|
| 387 | #endif
|
|---|
| 388 | WinSendMsg (hwnd, UM_PREPARECAPTURE, 0,0);
|
|---|
| 389 | break;
|
|---|
| 390 |
|
|---|
| 391 | case WID_PB_EXIT:
|
|---|
| 392 | WinSendMsg (WinWindowFromID (hwndFrame, FID_CLIENT),
|
|---|
| 393 | WM_CLOSE, 0,0);
|
|---|
| 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;
|
|---|
| 412 |
|
|---|
| 413 | if (usCap == CAP_SCREENREGION || usCap == CAP_SCREEN) {
|
|---|
| 414 | #ifdef _QUIET_
|
|---|
| 415 | hwndParent = WinQueryFocus(HWND_DESKTOP);
|
|---|
| 416 | #else
|
|---|
| 417 | hwndParent = WinQueryWindow(hwndFrame, QW_NEXTTOP );
|
|---|
| 418 | #endif
|
|---|
| 419 | }
|
|---|
| 420 | /*else {
|
|---|
| 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 | }
|
|---|
| 435 | } */
|
|---|
| 436 | #ifndef _QUIET_
|
|---|
| 437 | if (WinQueryButtonCheckstate (hwnd, WID_CB_HIDEWINDOW)) {
|
|---|
| 438 | WinShowWindow (WinQueryWindow (hwnd, QW_PARENT), FALSE);
|
|---|
| 439 | }
|
|---|
| 440 | else
|
|---|
| 441 | #endif
|
|---|
| 442 | WinPostMsg (hwnd, UM_WINDOWHIDDEN, 0,0);
|
|---|
| 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 ...
|
|---|
| 451 | DosSleep (100);
|
|---|
| 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:
|
|---|
| 468 | #ifdef _QUIET_
|
|---|
| 469 | WinSetFocus(HWND_DESKTOP, hwnd);
|
|---|
| 470 | #endif
|
|---|
| 471 | if (DoTracking (&rcl))
|
|---|
| 472 | {
|
|---|
| 473 | usState = STATE_WINDOWSELECTED;
|
|---|
| 474 |
|
|---|
| 475 | /*int rc = saymsg2(1, hwnd, RSTR(IDS_CAPTURE), RSTR(IDS_WISHCONTINUE));
|
|---|
| 476 |
|
|---|
| 477 | if (rc == 1)
|
|---|
| 478 | DosSleep(100); // Let the dialog close*/
|
|---|
| 479 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
|---|
| 480 | MPFROMHWND (HWND_DESKTOP),
|
|---|
| 481 | MPFROMHWND (HWND_DESKTOP));
|
|---|
| 482 | /*if (rc == 2)
|
|---|
| 483 | WinSendMsg (hwnd, UM_ABORT, MPFROMLONG(1),0);
|
|---|
| 484 | if (rc == 3) {
|
|---|
| 485 | pset->Dialog ();
|
|---|
| 486 | DosSleep(100); // Let the dialogs close
|
|---|
| 487 | WinPostMsg (hwnd, UM_WINDOWSELECTED,
|
|---|
| 488 | MPFROMHWND (HWND_DESKTOP),
|
|---|
| 489 | MPFROMHWND (HWND_DESKTOP));
|
|---|
| 490 | }*/
|
|---|
| 491 | }
|
|---|
| 492 | else
|
|---|
| 493 | usState = STATE_IDLE;
|
|---|
| 494 | break;
|
|---|
| 495 |
|
|---|
| 496 | case CAP_WINDOWINT:
|
|---|
| 497 | fInterior = TRUE;
|
|---|
| 498 | #ifdef _QUIET_
|
|---|
| 499 | WinSetFocus(HWND_DESKTOP, hwnd);
|
|---|
| 500 | #endif
|
|---|
| 501 | StartSelection (hwnd);
|
|---|
| 502 | break;
|
|---|
| 503 |
|
|---|
| 504 | case CAP_WINDOW:
|
|---|
| 505 | fInterior = FALSE;
|
|---|
| 506 | #ifdef _QUIET_
|
|---|
| 507 | WinSetFocus(HWND_DESKTOP, hwnd);
|
|---|
| 508 | #endif
|
|---|
| 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);
|
|---|
| 564 | if (usCap != CAP_SCREENREGION && usCap != CAP_SCREEN)
|
|---|
| 565 | hwndParent = HWND (mp2);
|
|---|
| 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 --;
|
|---|
| 586 |
|
|---|
| 587 | if( ulCountdown % 20 == 0 )
|
|---|
| 588 | WinSendMsg (hwndSnapshot, UM_COUNTDOWN,
|
|---|
| 589 | MPFROMLONG (ulCountdown), 0);
|
|---|
| 590 | if (pset->DelayCountdown () && !pset->SerialCapture ())
|
|---|
| 591 | DoCountdown (ulCountdown);
|
|---|
| 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;
|
|---|
| 603 | #ifndef _QUIET_
|
|---|
| 604 | if (pset->SSWHide () && WinIsWindowVisible (hwndSnapshot))
|
|---|
| 605 | WinShowWindow (hwndSnapshot, FALSE);
|
|---|
| 606 | else
|
|---|
| 607 | #endif
|
|---|
| 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 ...
|
|---|
| 615 | DosSleep (100);
|
|---|
| 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)
|
|---|
| 627 | hbm = CaptureWindow (hwndCap, hwndParent, &rcl, FALSE);
|
|---|
| 628 | else if (usCap == CAP_SCREEN)
|
|---|
| 629 | hbm = CaptureWindow (hwndCap, hwndParent, NULL, FALSE);
|
|---|
| 630 | else
|
|---|
| 631 | hbm = CaptureWindow (hwndCap, hwndParent, NULL, TRUE);
|
|---|
| 632 |
|
|---|
| 633 | if (pset->SerialCapture ())
|
|---|
| 634 | {
|
|---|
| 635 | WinStopTimer (hab, hwnd, ulTimer);
|
|---|
| 636 | #ifndef _QUIET_
|
|---|
| 637 | if (! WinIsWindowVisible (hwndSnapshot) && pset->SnapshotWindow ())
|
|---|
| 638 | WinShowWindow (hwndSnapshot, TRUE);
|
|---|
| 639 | #endif
|
|---|
| 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:
|
|---|
| 656 | if (LONGFROMMP(mp1) != 1)
|
|---|
| 657 | DosBeep (75, 200);
|
|---|
| 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 |
|
|---|
| 665 | pset->Load ();
|
|---|
| 666 |
|
|---|
| 667 | WinSendMsg (hwndSnapshot, UM_STOPCAPTURE, 0,0);
|
|---|
| 668 | WinStopTimer (hab, hwnd, ulTimer);
|
|---|
| 669 | #ifdef _QUIET_
|
|---|
| 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
|
|---|
| 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);
|
|---|
| 684 | #endif
|
|---|
| 685 | WinEnableWindow (hwnd, TRUE);
|
|---|
| 686 | WinSetActiveWindow (HWND_DESKTOP, hwnd);
|
|---|
| 687 | usState = STATE_IDLE;
|
|---|
| 688 | WinSetFocus(HWND_DESKTOP, hwndParent);
|
|---|
| 689 | return MRESULT (FALSE);
|
|---|
| 690 | }
|
|---|
| 691 |
|
|---|
| 692 | #ifdef _DOLOGDEBUG_
|
|---|
| 693 | LogDebug( "MainWin:WindowProcedure:WinDefWindowProc->0x%04x", msg );
|
|---|
| 694 | #endif
|
|---|
| 695 | if (hwnd == g_hwndPage0)
|
|---|
| 696 | return WinDefDlgProc (hwnd, msg, mp1, mp2);
|
|---|
| 697 | else
|
|---|
| 698 | return WinDefWindowProc (hwnd, msg, mp1, mp2);
|
|---|
| 699 | }
|
|---|
| 700 |
|
|---|
| 701 | // ************************************************************************
|
|---|