| 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 | #include <direct.h>
 | 
|---|
| 20 | #include "settings.h"
 | 
|---|
| 21 | #include "ctype.h"
 | 
|---|
| 22 | 
 | 
|---|
| 23 | #include "./settings/thth_settings.cpp"
 | 
|---|
| 24 | 
 | 
|---|
| 25 | PSZ SETTINGS::pszPageTab[COUNT_PAGES]; /* = {
 | 
|---|
| 26 |     "Saving", "Snapshot window", "Misc", "Language" };
 | 
|---|
| 27 |     // FIXME nls*/
 | 
|---|
| 28 | 
 | 
|---|
| 29 | bool saveum = FALSE;
 | 
|---|
| 30 | SWP swpDef = { 0,0,0, 98,66, 0,0,0,0 };
 | 
|---|
| 31 | SWP swpDefSSW = { 0,0,0, 10,10, 0,0,0,0 };
 | 
|---|
| 32 | USHORT ausDef[7] = { 0 };
 | 
|---|
| 33 | USHORT ausDefSSW[7] = { 0 };
 | 
|---|
| 34 | 
 | 
|---|
| 35 | ImageFormatInfo Settings::ifi[BMF_INVALID] =
 | 
|---|
| 36 | {
 | 
|---|
| 37 |     { TRUE, BMF_JPG,   "JPEG Interchange File Format (jpg)", "jpg", "JPG" },
 | 
|---|
| 38 |     { TRUE, BMF_PNG,   "Portable Network Graphics (png)", "png", "PNG" },
 | 
|---|
| 39 |     { TRUE, BMF_OS20,  "OS/2 Bitmap 2.0 (bmp)", "bmp", "Bitmap" },
 | 
|---|
| 40 |     { TRUE, BMF_TIF,   "Microsoft/Aldus Tagged Image File Format (tif)", "tif", "TIFF" },
 | 
|---|
| 41 |     { TRUE, BMF_TGA,   "Truevision Targa/Vista (tga)", "tga", "Targa" },
 | 
|---|
| 42 |     { TRUE, BMF_PCX,   "ZSoft PC Paintbrush Image Format (pcx)", "pcx", "PCX" },
 | 
|---|
| 43 |     { TRUE, BMF_GIF,   "Portable Anymap (pnm)", "pnm", "PNM" },
 | 
|---|
| 44 |     { TRUE, BMF_PBM,   "Portable Pixel-map (ppm)", "ppm", "PPM" },
 | 
|---|
| 45 |     { TRUE, BMF_JP2,   "Jpeg 2000 (provided by the Open Source OpenJPEG library) (jp2)", "jp2", "JP2" },
 | 
|---|
| 46 |     { TRUE, BMF_DIB,   "Device Independent Bitmap (dib)", "dib", "DIB" }
 | 
|---|
| 47 | };
 | 
|---|
| 48 | 
 | 
|---|
| 49 | 
 | 
|---|
| 50 | PTHTH_SE apse[] =
 | 
|---|
| 51 | {
 | 
|---|
| 52 |     new THTH_SES (SEI_SAVEFILE, "Save", "Filename", "gotcha.png"),
 | 
|---|
| 53 |     new THTH_SES (SEI_FORCESAVEFILE, "Save", "ForceSaveFilename", "force.png"),
 | 
|---|
| 54 |     new THTH_SEL (SEI_SAVESTYLE, "Save", "Style", SAVESTYLE_FILE),
 | 
|---|
| 55 |     new THTH_SEL (SEI_FILEFORMAT, "Save", "FileFormat", BMF_PNG),
 | 
|---|
| 56 |     new THTH_SEL (SEI_FILESAVESTYLE, "Save", "FileSaveStyle", FSS_PROMPT),
 | 
|---|
| 57 | 
 | 
|---|
| 58 |     new THTH_SES (SEI_NUMSAVEDIR, "Save", "NumSaveDir", ""),
 | 
|---|
| 59 |     new THTH_SEF (SEI_HIDEWINDOW, "Extras", "HideWindow", TRUE),
 | 
|---|
| 60 |     new THTH_SEF (SEI_AUTOADDEXTENSION, "Extras", "AutoaddExtension", TRUE),
 | 
|---|
| 61 |     new THTH_SEF (SEI_CONFIRMOVERWRITE, "Extras", "ConfirmOverwrite", TRUE),
 | 
|---|
| 62 |     new THTH_SEF (SEI_DOSOUND, "Extras", "DoSound", TRUE),
 | 
|---|
| 63 | 
 | 
|---|
| 64 |     new THTH_SEF (SEI_DELAYEDCAPTURE, "Extras", "DelayedCapture", FALSE),
 | 
|---|
| 65 |     new THTH_SEF (SEI_DELAYCOUNTDOWN, "Extras", "DelayCountdown", FALSE),
 | 
|---|
| 66 |     new THTH_SEL (SEI_DELAYTIME, "Extras", "DelayTime", 5),
 | 
|---|
| 67 |     new THTH_SEF (SEI_SERIALCAPTURE, "Extras", "SerialCapture", FALSE),
 | 
|---|
| 68 |     new THTH_SEL (SEI_SERIALTIME, "Extras", "SerialTime", 10),
 | 
|---|
| 69 | 
 | 
|---|
| 70 |     new THTH_SEF (SEI_SNAPSHOTWINDOW, "Snapshot", "Enable", FALSE),
 | 
|---|
| 71 |     new THTH_SEL (SEI_SSWCAPTURETYPE, "Snapshot", "CaptureType", CAP_SCREEN),
 | 
|---|
| 72 |     new THTH_SEF (SEI_SSWHIDE, "Snapshot", "Hide", TRUE),
 | 
|---|
| 73 |     new THTH_SEF (SEI_SSWALWAYSONTOP, "Snapshot", "AlwaysOnTop", TRUE),
 | 
|---|
| 74 | 
 | 
|---|
| 75 |     new THTH_SEF (SEI_IDLEPRIORITY, "Extras", "IdlePriority", FALSE),
 | 
|---|
| 76 | 
 | 
|---|
| 77 |     new THTH_SEB (SEI_SWP, "Window", "SWP", &swpDef, sizeof (swpDef)),
 | 
|---|
| 78 |     new THTH_SEB (SEI_US, "Window", "US", &ausDef, sizeof (ausDef)),
 | 
|---|
| 79 | 
 | 
|---|
| 80 |     new THTH_SEB (SEI_SWPSSW, "Snapshot", "SWP", &swpDefSSW, sizeof (swpDefSSW)),
 | 
|---|
| 81 |     new THTH_SEB (SEI_USSSW, "Snapshot", "US", &ausDefSSW, sizeof (ausDefSSW)),
 | 
|---|
| 82 | 
 | 
|---|
| 83 |     new THTH_SES (SEI_LANGUAGE,     "Language", "Program", PSZ_DEFAULTLANGUAGEMOD),
 | 
|---|
| 84 |     new THTH_SES (SEI_LANGUAGEHELP, "Language", "Help", PSZ_DEFAULTLANGUAGEHELP),
 | 
|---|
| 85 | 
 | 
|---|
| 86 |     new THTH_SEF (SEI_UPDATE178DONE, "Extras", "Update178Done", FALSE),
 | 
|---|
| 87 | 
 | 
|---|
| 88 |     NULL,
 | 
|---|
| 89 | };
 | 
|---|
| 90 | 
 | 
|---|
| 91 | // ** Settings ************************************************************ /*FOLD00*/
 | 
|---|
| 92 | 
 | 
|---|
| 93 | Settings :: Settings (VOID) :
 | 
|---|
| 94 | #ifdef _QUIET_
 | 
|---|
| 95 | //#if 1
 | 
|---|
| 96 |     ththSettings(apse, "gotchaq.ini", L_PROFILEVERSION)
 | 
|---|
| 97 | #else
 | 
|---|
| 98 |     ththSettings(apse, "gotcha.ini", L_PROFILEVERSION)
 | 
|---|
| 99 | #endif
 | 
|---|
| 100 | {
 | 
|---|
| 101 |     if( ! QueryFlag( SEI_UPDATE178DONE ) ) {
 | 
|---|
| 102 |         //DisplayError( "Updated", "false" );
 | 
|---|
| 103 |         SetLong( SEI_SERIALTIME, QueryLong( SEI_SERIALTIME ) * 20 );
 | 
|---|
| 104 |         SetFlag( SEI_UPDATE178DONE );
 | 
|---|
| 105 |     } else {
 | 
|---|
| 106 |         //DisplayError( "NOT Updated", "true" );
 | 
|---|
| 107 |     }
 | 
|---|
| 108 | 
 | 
|---|
| 109 |     // to get the error msgs in default language
 | 
|---|
| 110 |     ReloadResources (QueryString(SEI_LANGUAGE));
 | 
|---|
| 111 | 
 | 
|---|
| 112 |     if (Error () == 1)
 | 
|---|
| 113 |     {
 | 
|---|
| 114 |         FileNotOpenError ();
 | 
|---|
| 115 |         ReloadResources (QueryString(SEI_LANGUAGE));
 | 
|---|
| 116 |     }
 | 
|---|
| 117 |     else if (Error () == 2)
 | 
|---|
| 118 |     {
 | 
|---|
| 119 |         VersionError ();
 | 
|---|
| 120 |         ReloadResources (QueryString(SEI_LANGUAGE));
 | 
|---|
| 121 |     }
 | 
|---|
| 122 | }
 | 
|---|
| 123 | 
 | 
|---|
| 124 | // ** VersionError ********************************************************
 | 
|---|
| 125 | 
 | 
|---|
| 126 | USHORT SETTINGS :: VersionError (VOID)
 | 
|---|
| 127 | {
 | 
|---|
| 128 |     DisplayError (RSTR(IDS_HEADER_WARNING), RSTR(IDS_ERROR_INIFILEWRONGVERSION),
 | 
|---|
| 129 |                   QueryProfileName ());
 | 
|---|
| 130 |     SelectLanguage();
 | 
|---|
| 131 |     return 0;
 | 
|---|
| 132 | }
 | 
|---|
| 133 | 
 | 
|---|
| 134 | // ** FileNotOpenError **************************************************** /*fold00*/
 | 
|---|
| 135 | 
 | 
|---|
| 136 | USHORT SETTINGS :: FileNotOpenError (VOID)
 | 
|---|
| 137 | {
 | 
|---|
| 138 |     DisplayError (RSTR(IDS_HEADER_ERROR), RSTR(IDS_ERROR_INIFILENOTOPEN),
 | 
|---|
| 139 |                   QueryProfileName ());
 | 
|---|
| 140 |     SelectLanguage();
 | 
|---|
| 141 |     return 0;
 | 
|---|
| 142 | }
 | 
|---|
| 143 | 
 | 
|---|
| 144 | // ** Dialog ************************************************************** /*FOLD00*/
 | 
|---|
| 145 | 
 | 
|---|
| 146 | // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
 | 
|---|
| 147 | HWND g_hwndSettingsDialog = NULL;
 | 
|---|
| 148 | HWND g_hwndPage0 = NULL;
 | 
|---|
| 149 | 
 | 
|---|
| 150 | BOOL SETTINGS :: Dialog (BOOL fOnlyLanguage)
 | 
|---|
| 151 | {
 | 
|---|
| 152 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 153 |     LogDebug( "Dialog: checkpoint 1" );
 | 
|---|
| 154 | #endif
 | 
|---|
| 155 |     fAutoLanguage = fOnlyLanguage;
 | 
|---|
| 156 | 
 | 
|---|
| 157 |     // load the main dialog window
 | 
|---|
| 158 |     hwndDlg = WinLoadDlg (HWND_DESKTOP, hwndFrame, PFNWP (DialogProcedure),
 | 
|---|
| 159 |                           GETMODULE, ID_DLG_SETTINGS, this);
 | 
|---|
| 160 |     // FIXME YUKKI! YUKKI!! YUKKI!!! But I'm too lazy to do it better now :-)
 | 
|---|
| 161 |     g_hwndSettingsDialog = hwndDlg;
 | 
|---|
| 162 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 163 |     LogDebug( "Dialog: checkpoint 2" );
 | 
|---|
| 164 | #endif
 | 
|---|
| 165 | 
 | 
|---|
| 166 |     // disable this two buttons if only language select
 | 
|---|
| 167 |     if (fAutoLanguage)
 | 
|---|
| 168 |     {
 | 
|---|
| 169 |         WinEnableWindow (WinWindowFromID (hwndDlg, WID_PB_HELP), FALSE);
 | 
|---|
| 170 |         WinEnableWindow (WinWindowFromID (hwndDlg, WID_PB_UNDO), FALSE);
 | 
|---|
| 171 |     }
 | 
|---|
| 172 | 
 | 
|---|
| 173 |     HWND   hwndNB = WinWindowFromID (hwndDlg, WID_NB_SETTINGS);
 | 
|---|
| 174 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 175 |     LogDebug( "Dialog: checkpoint 3" );
 | 
|---|
| 176 | #endif
 | 
|---|
| 177 | 
 | 
|---|
| 178 |     // set notebook background color
 | 
|---|
| 179 |     WinSendMsg (hwndNB, BKM_SETNOTEBOOKCOLORS,
 | 
|---|
| 180 |                 MPFROMLONG (SYSCLR_DIALOGBACKGROUND),
 | 
|---|
| 181 |                 MPFROMSHORT (BKA_BACKGROUNDPAGECOLORINDEX));
 | 
|---|
| 182 | 
 | 
|---|
| 183 |     // set tab dimensions
 | 
|---|
| 184 |     WinSendMsg (hwndNB, BKM_SETDIMENSIONS,
 | 
|---|
| 185 |                 MPFROM2SHORT (80, 25), MPFROMSHORT (BKA_MAJORTAB));
 | 
|---|
| 186 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 187 |     LogDebug( "Dialog: checkpoint 4" );
 | 
|---|
| 188 | #endif
 | 
|---|
| 189 | 
 | 
|---|
| 190 |     ULONG   idPage[COUNT_PAGES];
 | 
|---|
| 191 |     USHORT  i, cPages;
 | 
|---|
| 192 | 
 | 
|---|
| 193 |     if (fOnlyLanguage)
 | 
|---|
| 194 |     {
 | 
|---|
| 195 |         cPages = 1;
 | 
|---|
| 196 | 
 | 
|---|
| 197 |         idPage[0] = (ULONG)
 | 
|---|
| 198 |             WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L,
 | 
|---|
| 199 |                         MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
 | 
|---|
| 200 |                                       BKA_LAST));
 | 
|---|
| 201 |         WinSendMsg (hwndNB, BKM_SETTABTEXT, MPFROMLONG (idPage[0]),
 | 
|---|
| 202 |                     MPFROMP (pszPageTab[COUNT_PAGES-1]));
 | 
|---|
| 203 |         hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure,
 | 
|---|
| 204 |                                   GETMODULE, ID_DLG_SETTINGSPAGE4, this);
 | 
|---|
| 205 |     }
 | 
|---|
| 206 |     else
 | 
|---|
| 207 |     {
 | 
|---|
| 208 |         cPages = COUNT_PAGES;
 | 
|---|
| 209 | 
 | 
|---|
| 210 |         // insert empty pages
 | 
|---|
| 211 |         for (i = 0; i < cPages; i++)
 | 
|---|
| 212 |         {
 | 
|---|
| 213 |             idPage[i] = (ULONG)
 | 
|---|
| 214 |                 WinSendMsg (hwndNB, BKM_INSERTPAGE, 0L,
 | 
|---|
| 215 |                             MPFROM2SHORT (BKA_MAJOR | BKA_AUTOPAGESIZE,
 | 
|---|
| 216 |                                           BKA_LAST));
 | 
|---|
| 217 |             WinSendMsg (hwndNB, BKM_SETTABTEXT,
 | 
|---|
| 218 |                         MPFROMLONG (idPage[i]), MPFROMP (pszPageTab[i]));
 | 
|---|
| 219 |         }
 | 
|---|
| 220 | #ifndef _QUIET_
 | 
|---|
| 221 |         // open and assign dialogs to pages
 | 
|---|
| 222 |         hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page1Procedure,
 | 
|---|
| 223 |                                   GETMODULE, ID_DLG_SETTINGSPAGE1, this);
 | 
|---|
| 224 |         hwndPage[1] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page2Procedure,
 | 
|---|
| 225 |                                   GETMODULE, ID_DLG_SETTINGSPAGE2, this);
 | 
|---|
| 226 |         hwndPage[2] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page3Procedure,
 | 
|---|
| 227 |                                   GETMODULE, ID_DLG_SETTINGSPAGE3, this);
 | 
|---|
| 228 |         hwndPage[3] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure,
 | 
|---|
| 229 |                                   GETMODULE, ID_DLG_SETTINGSPAGE4, this);
 | 
|---|
| 230 | #else
 | 
|---|
| 231 |         hwndPage[0] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) WindowProcedure,
 | 
|---|
| 232 |                                   GETMODULE, ID_DLG_SETTINGSPAGE0, this);
 | 
|---|
| 233 |         hwndPage[1] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page2Procedure,
 | 
|---|
| 234 |                                   GETMODULE, ID_DLG_SETTINGSPAGE2, this);
 | 
|---|
| 235 |         hwndPage[2] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page1Procedure,
 | 
|---|
| 236 |                                   GETMODULE, ID_DLG_SETTINGSPAGE1, this);
 | 
|---|
| 237 |         hwndPage[3] = WinLoadDlg (hwndNB, hwndNB, (PFNWP) Page4Procedure,
 | 
|---|
| 238 |                                   GETMODULE, ID_DLG_SETTINGSPAGE4, this);
 | 
|---|
| 239 |         g_hwndPage0 = hwndPage[0];
 | 
|---|
| 240 |         
 | 
|---|
| 241 | #endif
 | 
|---|
| 242 |     }
 | 
|---|
| 243 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 244 |     LogDebug( "Dialog: checkpoint 5" );
 | 
|---|
| 245 | #endif
 | 
|---|
| 246 | 
 | 
|---|
| 247 |     // combine dlg-handle and page ids
 | 
|---|
| 248 |     for (i = 0; i < cPages; i++)
 | 
|---|
| 249 |         WinSendMsg (hwndNB, BKM_SETPAGEWINDOWHWND,
 | 
|---|
| 250 |                     MPFROMLONG (idPage[i]), MPFROMHWND (hwndPage[i]));
 | 
|---|
| 251 | 
 | 
|---|
| 252 | /*    if (fAutoLanguage)
 | 
|---|
| 253 |         WinSendMsg (hwndNB, BKM_TURNTOPAGE, MPFROMLONG (idPage[0]), 0L);
 | 
|---|
| 254 | #if (COUNT_PAGES != 4)
 | 
|---|
| 255 | #warning FIXME settings.cpp 264 or so ...
 | 
|---|
| 256 | #endif */
 | 
|---|
| 257 |     for (i = 0; i < cPages; i++)
 | 
|---|
| 258 |         WinSendMsg (hwndPage[i], UM_SETTINGS2DIALOG, 0,0);
 | 
|---|
| 259 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 260 |     LogDebug( "Dialog: checkpoint 6" );
 | 
|---|
| 261 | #endif
 | 
|---|
| 262 |     WinSendDlgItemMsg (g_hwndPage0, WID_RB_FILE, BM_CLICK,
 | 
|---|
| 263 |                        MPFROMSHORT (TRUE), 0);
 | 
|---|
| 264 |     //WinSendDlgItemMsg (g_hwndPage0, WID_CB_HIDEWINDOW, BM_SETCHECK,
 | 
|---|
| 265 |     //                   MPFROMLONG (TRUE), MPFROMLONG (0));
 | 
|---|
| 266 |     //WinSetFocus (WinWindowFromID (hwndDlg, WID_PB_OK), TRUE);
 | 
|---|
| 267 |     //WinSetFocus( hwndPage[0], FALSE );
 | 
|---|
| 268 | #ifdef _QUIET_
 | 
|---|
| 269 |     if (HACCEL haccel = WinLoadAccelTable (hab, GETMODULE, 1)) {
 | 
|---|
| 270 |         int rc = WinSetAccelTable (hab, haccel, hwndDlg);
 | 
|---|
| 271 |     }
 | 
|---|
| 272 | #endif
 | 
|---|
| 273 |     WinSetActiveWindow( HWND_DESKTOP, hwndDlg );
 | 
|---|
| 274 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 275 |     LogDebug( "Dialog: checkpoint 7" );
 | 
|---|
| 276 | #endif
 | 
|---|
| 277 | 
 | 
|---|
| 278 |     WinProcessDlg (hwndDlg);
 | 
|---|
| 279 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 280 |     LogDebug( "Dialog: checkpoint 7.5" );
 | 
|---|
| 281 | #endif
 | 
|---|
| 282 |     WinDestroyWindow (hwndDlg);
 | 
|---|
| 283 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 284 |     LogDebug( "Dialog: checkpoint 8" );
 | 
|---|
| 285 | #endif
 | 
|---|
| 286 | #ifndef _QUIET_
 | 
|---|
| 287 |     // it ain't the best way to do it, but ...
 | 
|---|
| 288 |     SetIdlePriority(QueryFlag(SEI_IDLEPRIORITY));
 | 
|---|
| 289 | #endif
 | 
|---|
| 290 |     for (i = 0; i < COUNT_PAGES; i++)
 | 
|---|
| 291 |         hwndPage[i] = NULL;
 | 
|---|
| 292 | 
 | 
|---|
| 293 |     hwndDlg = NULLHANDLE;
 | 
|---|
| 294 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 295 |     LogDebug( "Dialog: checkpoint 9" );
 | 
|---|
| 296 | #endif
 | 
|---|
| 297 |     return TRUE;
 | 
|---|
| 298 | }
 | 
|---|
| 299 | 
 | 
|---|
| 300 | // ** DialogProcedure ***************************************************** /*FOLD00*/
 | 
|---|
| 301 | 
 | 
|---|
| 302 | MRESULT EXPENTRY
 | 
|---|
| 303 | SETTINGS :: DialogProcedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 304 | {
 | 
|---|
| 305 |     static PSETTINGS   pset = NULL;
 | 
|---|
| 306 | 
 | 
|---|
| 307 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 308 |     LogDebug( "DialogProcedure:Message 0x%04x", msg );
 | 
|---|
| 309 | #endif
 | 
|---|
| 310 | 
 | 
|---|
| 311 |     switch (msg)
 | 
|---|
| 312 |     {
 | 
|---|
| 313 |     case WM_INITDLG:
 | 
|---|
| 314 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 315 |         LogDebug( "DialogProcedure: start WM_INITDLG" );
 | 
|---|
| 316 | #endif
 | 
|---|
| 317 |         pset = PSETTINGS (mp2);
 | 
|---|
| 318 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 319 |         LogDebug( "DialogProcedure: end WM_INITDLG" );
 | 
|---|
| 320 | #endif
 | 
|---|
| 321 |         return MRESULT (FALSE);
 | 
|---|
| 322 | 
 | 
|---|
| 323 |     case WM_COMMAND:
 | 
|---|
| 324 |         switch (SHORT1FROMMP (mp1))
 | 
|---|
| 325 |         {
 | 
|---|
| 326 |         case WID_PB_OK:
 | 
|---|
| 327 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 328 |             LogDebug( "DialogProcedure: start WID_PB_OK" );
 | 
|---|
| 329 | #endif
 | 
|---|
| 330 |             saveum = TRUE;
 | 
|---|
| 331 |             WinSendMsg (hwnd, WM_CLOSE, 0,0);
 | 
|---|
| 332 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 333 |             LogDebug( "DialogProcedure: end WID_PB_OK" );
 | 
|---|
| 334 | #endif
 | 
|---|
| 335 |             break;
 | 
|---|
| 336 |             
 | 
|---|
| 337 |         case WID_PB_UNDO:
 | 
|---|
| 338 |             {
 | 
|---|
| 339 |                 ULONG  id = (ULONG)
 | 
|---|
| 340 |                     WinSendDlgItemMsg (hwnd, WID_NB_SETTINGS,
 | 
|---|
| 341 |                                        BKM_QUERYPAGEID, 0,
 | 
|---|
| 342 |                                        MPFROM2SHORT (BKA_TOP, 0));
 | 
|---|
| 343 |                 if (id)
 | 
|---|
| 344 |                 {
 | 
|---|
| 345 |                     HWND   hwndPage = (HWND)
 | 
|---|
| 346 |                         WinSendDlgItemMsg (hwnd, WID_NB_SETTINGS,
 | 
|---|
| 347 |                                            BKM_QUERYPAGEWINDOWHWND,
 | 
|---|
| 348 |                                            MPFROMLONG (id), 0);
 | 
|---|
| 349 |                 // Make mp1 1 for default use it to select setting on pages
 | 
|---|
| 350 |                     WinSendMsg (hwndPage, UM_SETTINGS2DIALOG, 0,0);
 | 
|---|
| 351 |                 }
 | 
|---|
| 352 |             }
 | 
|---|
| 353 |             break;
 | 
|---|
| 354 | 
 | 
|---|
| 355 |         case WID_PB_ABOUT:
 | 
|---|
| 356 |             AboutBox (hwnd);
 | 
|---|
| 357 |             break;
 | 
|---|
| 358 | 
 | 
|---|
| 359 |         case DID_CANCEL:
 | 
|---|
| 360 |             {
 | 
|---|
| 361 |                 // Undo stuff on all notebook pages:
 | 
|---|
| 362 |                 HWND hwndPage;
 | 
|---|
| 363 | 
 | 
|---|
| 364 |                 // Get ID of first notebook page.
 | 
|---|
| 365 |                 ULONG id =
 | 
|---|
| 366 |                     ULONG( WinSendDlgItemMsg( hwnd, WID_NB_SETTINGS,
 | 
|---|
| 367 |                                               BKM_QUERYPAGEID, 0,
 | 
|---|
| 368 |                                               MPFROM2SHORT( BKA_FIRST, 0 ) ) );
 | 
|---|
| 369 |                 if( id ) {
 | 
|---|
| 370 |                     hwndPage =
 | 
|---|
| 371 |                         HWND( WinSendDlgItemMsg( hwnd, WID_NB_SETTINGS,
 | 
|---|
| 372 |                                                  BKM_QUERYPAGEWINDOWHWND,
 | 
|---|
| 373 |                                                  MPFROMLONG( id ), 0 ) );
 | 
|---|
| 374 |                     WinSendMsg( hwndPage, UM_SETTINGS2DIALOG, 0,0 );
 | 
|---|
| 375 |                 }
 | 
|---|
| 376 | 
 | 
|---|
| 377 |                 while( id ) {
 | 
|---|
| 378 |                     // Get ID of next notebook page.
 | 
|---|
| 379 |                     if( ( id =
 | 
|---|
| 380 |                           ULONG( WinSendDlgItemMsg( hwnd, WID_NB_SETTINGS,
 | 
|---|
| 381 |                                                     BKM_QUERYPAGEID,
 | 
|---|
| 382 |                                                     MPFROMLONG( id ),
 | 
|---|
| 383 |                                                     MPFROM2SHORT( BKA_NEXT, 0 )
 | 
|---|
| 384 |                                                   ) ) ) ) {
 | 
|---|
| 385 |                         hwndPage =
 | 
|---|
| 386 |                             HWND( WinSendDlgItemMsg( hwnd, WID_NB_SETTINGS,
 | 
|---|
| 387 |                                                      BKM_QUERYPAGEWINDOWHWND,
 | 
|---|
| 388 |                                                      MPFROMLONG( id ), 0 ) );
 | 
|---|
| 389 |                         WinSendMsg( hwndPage, UM_SETTINGS2DIALOG, 0,0 );
 | 
|---|
| 390 |                     }
 | 
|---|
| 391 |                 }
 | 
|---|
| 392 |                 WinSendMsg( hwnd, WM_CLOSE, 0,0 );
 | 
|---|
| 393 |             }
 | 
|---|
| 394 |             break;
 | 
|---|
| 395 |         }
 | 
|---|
| 396 |         return MRESULT (FALSE);
 | 
|---|
| 397 | 
 | 
|---|
| 398 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 399 |     case WM_DESTROY:
 | 
|---|
| 400 |         LogDebug( "DialogProcedure: WM_DESTROY" );
 | 
|---|
| 401 |         return MRESULT (FALSE);
 | 
|---|
| 402 | #endif
 | 
|---|
| 403 | 
 | 
|---|
| 404 |     case WM_CLOSE:
 | 
|---|
| 405 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 406 |         LogDebug( "DialogProcedure: WM_CLOSE" );
 | 
|---|
| 407 | #endif
 | 
|---|
| 408 |     case WM_QUIT:
 | 
|---|
| 409 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 410 |         LogDebug( "DialogProcedure: WM_QUIT" );
 | 
|---|
| 411 | #endif
 | 
|---|
| 412 |     case WM_SAVEAPPLICATION:
 | 
|---|
| 413 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 414 |         LogDebug( "DialogProcedure: WM_SAVEAPPLICATION" );
 | 
|---|
| 415 | #endif
 | 
|---|
| 416 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 417 |         LogDebug( "DialogProcedure: start WM_CLOSE (or WM_QUIT, WM_SAVEAPPLICATION)" );
 | 
|---|
| 418 | #endif
 | 
|---|
| 419 |         for (USHORT i = 0; i < COUNT_PAGES; i++)
 | 
|---|
| 420 |             WinSendMsg (pset->hwndPage[i], UM_ADJUST, 0,0);
 | 
|---|
| 421 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 422 |         LogDebug( "DialogProcedure: end WM_CLOSE (or WM_QUIT, WM_SAVEAPPLICATION)" );
 | 
|---|
| 423 | #endif
 | 
|---|
| 424 |         WinDismissDlg( hwnd, 0L );
 | 
|---|
| 425 |         return MRESULT (FALSE);
 | 
|---|
| 426 |     }
 | 
|---|
| 427 | 
 | 
|---|
| 428 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 429 |     LogDebug( "DialogProcedure:WinDefDlgProc->0x%04x", msg );
 | 
|---|
| 430 | #endif
 | 
|---|
| 431 |     return WinDefDlgProc (hwnd, msg, mp1, mp2);
 | 
|---|
| 432 | }
 | 
|---|
| 433 | 
 | 
|---|
| 434 | // ** Page1Procedure ****************************************************** /*FOLD00*/
 | 
|---|
| 435 | 
 | 
|---|
| 436 | MRESULT EXPENTRY
 | 
|---|
| 437 | SETTINGS :: Page1Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 438 | {
 | 
|---|
| 439 |     static PSETTINGS   pset = NULL;
 | 
|---|
| 440 | 
 | 
|---|
| 441 |     switch (msg)
 | 
|---|
| 442 |     {
 | 
|---|
| 443 |     case WM_INITDLG: {
 | 
|---|
| 444 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 445 |         LogDebug( "Page1Procedure: start WM_INITDLG" );
 | 
|---|
| 446 | #endif
 | 
|---|
| 447 |         ULONG ul;
 | 
|---|
| 448 |         pset = PSETTINGS (mp2);
 | 
|---|
| 449 |         for( int i = 0; i < BMF_INVALID; i++ ) {
 | 
|---|
| 450 |             if( pset->ifi[ i ].available ) {
 | 
|---|
| 451 |                 ul = WinInsertLboxItem( WinWindowFromID( hwnd, WID_LB_FILEFORMAT ),
 | 
|---|
| 452 |                                         LIT_END, pset->ifi[ i ].label );
 | 
|---|
| 453 |                 WinSendMsg( WinWindowFromID( hwnd, WID_LB_FILEFORMAT ),
 | 
|---|
| 454 |                             LM_SETITEMHANDLE, MPFROMLONG(ul), MPFROMP( i ) );
 | 
|---|
| 455 |             }
 | 
|---|
| 456 |         }
 | 
|---|
| 457 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 458 |         LogDebug( "Page1Procedure: end WM_INITDLG" );
 | 
|---|
| 459 | #endif
 | 
|---|
| 460 |         return MRESULT (FALSE);
 | 
|---|
| 461 |     }
 | 
|---|
| 462 | 
 | 
|---|
| 463 |     case WM_COMMAND:
 | 
|---|
| 464 |         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
 | 
|---|
| 465 |             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
 | 
|---|
| 466 |         return MRESULT( FALSE );
 | 
|---|
| 467 | 
 | 
|---|
| 468 |     case UM_SETTINGS2DIALOG: {
 | 
|---|
| 469 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 470 |         LogDebug( "Page1Procedure: start UM_SETTINGS2DIALOG" );
 | 
|---|
| 471 | #endif
 | 
|---|
| 472 |         // set num save dir name
 | 
|---|
| 473 |         WinSendDlgItemMsg (hwnd, WID_E_NUMSAVEDIR, EM_SETTEXTLIMIT,
 | 
|---|
| 474 |                            MPARAM (_MAX_PATH-1), (MPARAM)0);
 | 
|---|
| 475 |         WinSetDlgItemText (hwnd, WID_E_NUMSAVEDIR,
 | 
|---|
| 476 |                            pset->QueryNumSaveDir ());
 | 
|---|
| 477 |         WinSendDlgItemMsg (hwnd, WID_E_NUMSAVEDIR, EM_SETSEL,
 | 
|---|
| 478 |                            MPFROM2SHORT (0, _MAX_PATH), (MPARAM)0);
 | 
|---|
| 479 | 
 | 
|---|
| 480 |         // set force file name
 | 
|---|
| 481 |         WinSendDlgItemMsg (hwnd, WID_E_FORCESAVEFILE, EM_SETTEXTLIMIT,
 | 
|---|
| 482 |                            MPARAM (_MAX_PATH-1), (MPARAM)0);
 | 
|---|
| 483 |         WinSetDlgItemText (hwnd, WID_E_FORCESAVEFILE,
 | 
|---|
| 484 |                            pset->QueryForceSaveFile ());
 | 
|---|
| 485 |         WinSendDlgItemMsg (hwnd, WID_E_FORCESAVEFILE, EM_SETSEL,
 | 
|---|
| 486 |                            MPFROM2SHORT (0, _MAX_PATH), (MPARAM)0);
 | 
|---|
| 487 | 
 | 
|---|
| 488 |         // Select the appropriate entry in the fileformat-listbox.
 | 
|---|
| 489 |         HWND     hwndLB = WinWindowFromID( hwnd, WID_LB_FILEFORMAT );
 | 
|---|
| 490 |         ULONG    c, i;
 | 
|---|
| 491 | 
 | 
|---|
| 492 |         c = WinQueryLboxCount( hwndLB );
 | 
|---|
| 493 |         for( i = 0; i < c; i++ )
 | 
|---|
| 494 |         {
 | 
|---|
| 495 |             ULONG type = ULONG( WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT,
 | 
|---|
| 496 |                                                    LM_QUERYITEMHANDLE,
 | 
|---|
| 497 |                                                    MPFROMLONG(i), NULL ) );
 | 
|---|
| 498 |             if( type == ULONG( pset->QueryFileFormat() ) )
 | 
|---|
| 499 |                 break;
 | 
|---|
| 500 |         }
 | 
|---|
| 501 |         if( i < c )
 | 
|---|
| 502 |             WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_SELECTITEM,
 | 
|---|
| 503 |                                MPFROMSHORT(i), MPFROMSHORT(TRUE) );
 | 
|---|
| 504 |         else
 | 
|---|
| 505 |             WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT, LM_SELECTITEM,
 | 
|---|
| 506 |                                MPFROMSHORT(0), MPFROMSHORT(TRUE) );
 | 
|---|
| 507 | #ifdef _QUIET_
 | 
|---|
| 508 | //#if 1
 | 
|---|
| 509 |         // set play sound button
 | 
|---|
| 510 |         pset->AdjustButton (hwnd, WID_CB_DOSOUND,
 | 
|---|
| 511 |                             pset->DoSound ());
 | 
|---|
| 512 | #endif
 | 
|---|
| 513 |         // Select appropriate radiobutton for save style.
 | 
|---|
| 514 |         switch (pset->QueryFileSaveStyle ())
 | 
|---|
| 515 |         {
 | 
|---|
| 516 |         case FSS_NUMFILES:
 | 
|---|
| 517 |             WinSendDlgItemMsg (hwnd, WID_RB_FSSNUMFILES, BM_CLICK,
 | 
|---|
| 518 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 519 |             AdjustSaveTypeButtons (FALSE);
 | 
|---|
| 520 |             break;
 | 
|---|
| 521 | 
 | 
|---|
| 522 |         case FSS_FORCEFILE:
 | 
|---|
| 523 |             WinSendDlgItemMsg (hwnd, WID_RB_FSSFORCEFILE, BM_CLICK,
 | 
|---|
| 524 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 525 |             AdjustSaveTypeButtons (TRUE);
 | 
|---|
| 526 |             break;
 | 
|---|
| 527 | 
 | 
|---|
| 528 |         default:
 | 
|---|
| 529 |             WinSendDlgItemMsg (hwnd, WID_RB_FSSPROMPT, BM_CLICK,
 | 
|---|
| 530 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 531 |             AdjustSaveTypeButtons (FALSE);
 | 
|---|
| 532 |             break;
 | 
|---|
| 533 |         }
 | 
|---|
| 534 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 535 |         LogDebug( "Page1Procedure: end UM_SETTINGS2DIALOG" );
 | 
|---|
| 536 | #endif
 | 
|---|
| 537 |         return MRESULT (FALSE);
 | 
|---|
| 538 |     }
 | 
|---|
| 539 | 
 | 
|---|
| 540 |     case UM_ADJUST:
 | 
|---|
| 541 |         {
 | 
|---|
| 542 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 543 |             LogDebug( "Page1Procedure: start UM_ADJUST" );
 | 
|---|
| 544 | #endif
 | 
|---|
| 545 |             // get file save style
 | 
|---|
| 546 |             if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_FSSNUMFILES),
 | 
|---|
| 547 |                             BM_QUERYCHECK, 0,0))
 | 
|---|
| 548 |                 pset->SetFileSaveStyle (FSS_NUMFILES);
 | 
|---|
| 549 |             else if (WinSendMsg (WinWindowFromID (hwnd, WID_RB_FSSFORCEFILE),
 | 
|---|
| 550 |                                  BM_QUERYCHECK, 0,0))
 | 
|---|
| 551 |                 pset->SetFileSaveStyle (FSS_FORCEFILE);
 | 
|---|
| 552 |             else
 | 
|---|
| 553 |                 pset->SetFileSaveStyle (FSS_PROMPT);
 | 
|---|
| 554 | #ifdef _QUIET_
 | 
|---|
| 555 | //#if 1
 | 
|---|
| 556 |             pset->DoSound(WinQueryButtonCheckstate
 | 
|---|
| 557 |                           (hwnd, WID_CB_DOSOUND));
 | 
|---|
| 558 | #endif
 | 
|---|
| 559 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 560 |             LogDebug( "Page1Procedure: checkpoint 1" );
 | 
|---|
| 561 | #endif
 | 
|---|
| 562 | 
 | 
|---|
| 563 |             // Get file format.
 | 
|---|
| 564 |             ULONG ul = USHORT( WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT,
 | 
|---|
| 565 |                                                   LM_QUERYSELECTION,
 | 
|---|
| 566 |                                                   MPFROMLONG( LIT_FIRST ),
 | 
|---|
| 567 |                                                   0L ) );
 | 
|---|
| 568 |             ul = ULONG( WinSendDlgItemMsg( hwnd, WID_LB_FILEFORMAT,
 | 
|---|
| 569 |                                            LM_QUERYITEMHANDLE,
 | 
|---|
| 570 |                                            MPFROMLONG( ul ), NULL ) );
 | 
|---|
| 571 |             pset->SetFileFormat( SHORT( ul ) );
 | 
|---|
| 572 | 
 | 
|---|
| 573 |             pset->SetSaveFile(AddExtensionToFilename(pset->QuerySaveFile()));
 | 
|---|
| 574 | 
 | 
|---|
| 575 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 576 |             LogDebug( "Page1Procedure: checkpoint 2" );
 | 
|---|
| 577 | #endif
 | 
|---|
| 578 | 
 | 
|---|
| 579 |             // num save dir file name
 | 
|---|
| 580 |             CHAR   psz[_MAX_PATH];
 | 
|---|
| 581 |             WinQueryDlgItemText (hwnd, WID_E_NUMSAVEDIR, _MAX_PATH, psz);
 | 
|---|
| 582 |             pset->SetNumSaveDir (psz);
 | 
|---|
| 583 | 
 | 
|---|
| 584 |             // force file name
 | 
|---|
| 585 |             WinQueryDlgItemText (hwnd, WID_E_FORCESAVEFILE, _MAX_PATH, psz);
 | 
|---|
| 586 |             pset->SetForceSaveFile (psz);
 | 
|---|
| 587 | 
 | 
|---|
| 588 |             AdjustSaveTypeButtons
 | 
|---|
| 589 |                 (BOOL (pset->QueryFileSaveStyle () == FSS_FORCEFILE));
 | 
|---|
| 590 |             pset->saveStyle = pset->QuerySaveStyle ();
 | 
|---|
| 591 |             pset->pNumSaveDir = pset->QueryNumSaveDir ();
 | 
|---|
| 592 |             pset->pForceSaveFile = pset->QueryForceSaveFile();
 | 
|---|
| 593 | 
 | 
|---|
| 594 |             if (saveum)
 | 
|---|
| 595 |                 pset->Save ();
 | 
|---|
| 596 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 597 |             LogDebug( "Page1Procedure: end UM_ADJUST" );
 | 
|---|
| 598 | #endif
 | 
|---|
| 599 |         }
 | 
|---|
| 600 |         break;
 | 
|---|
| 601 | 
 | 
|---|
| 602 |     case WM_CONTROL:
 | 
|---|
| 603 |         switch (SHORT1FROMMP (mp1))
 | 
|---|
| 604 |         {
 | 
|---|
| 605 |         case WID_RB_FSSFORCEFILE:
 | 
|---|
| 606 |             AdjustSaveTypeButtons (TRUE);
 | 
|---|
| 607 |             break;
 | 
|---|
| 608 | 
 | 
|---|
| 609 |         case WID_RB_FSSPROMPT:
 | 
|---|
| 610 |         case WID_RB_FSSNUMFILES:
 | 
|---|
| 611 |             AdjustSaveTypeButtons (FALSE);
 | 
|---|
| 612 |             break;
 | 
|---|
| 613 |         }
 | 
|---|
| 614 |         return MRESULT (FALSE);
 | 
|---|
| 615 |     }
 | 
|---|
| 616 | 
 | 
|---|
| 617 |     return WinDefDlgProc (hwnd, msg, mp1, mp2);
 | 
|---|
| 618 | }
 | 
|---|
| 619 | 
 | 
|---|
| 620 | // ** Page2Procedure ****************************************************** /*FOLD00*/
 | 
|---|
| 621 | 
 | 
|---|
| 622 | MRESULT EXPENTRY
 | 
|---|
| 623 | SETTINGS :: Page2Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 624 | {
 | 
|---|
| 625 |     static PSETTINGS   pset = NULL;
 | 
|---|
| 626 | 
 | 
|---|
| 627 |     switch (msg)
 | 
|---|
| 628 |     {
 | 
|---|
| 629 |     case WM_INITDLG:
 | 
|---|
| 630 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 631 |         LogDebug( "Page1Procedure: start WM_INITDLG" );
 | 
|---|
| 632 | #endif
 | 
|---|
| 633 |         pset = PSETTINGS (mp2);
 | 
|---|
| 634 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 635 |         LogDebug( "Page1Procedure: end WM_INITDLG" );
 | 
|---|
| 636 | #endif
 | 
|---|
| 637 |         return MRESULT (FALSE);
 | 
|---|
| 638 | 
 | 
|---|
| 639 |     case WM_COMMAND:
 | 
|---|
| 640 | 
 | 
|---|
| 641 |         if( SHORT1FROMMP( mp1 ) == WID_PB_OK) {
 | 
|---|
| 642 |             saveum = TRUE;
 | 
|---|
| 643 |             WinSendMsg ( g_hwndSettingsDialog, WM_CLOSE, 0,0);
 | 
|---|
| 644 |         }
 | 
|---|
| 645 |         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
 | 
|---|
| 646 |             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
 | 
|---|
| 647 |         return MRESULT( FALSE );
 | 
|---|
| 648 | 
 | 
|---|
| 649 |     case UM_SETTINGS2DIALOG:
 | 
|---|
| 650 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 651 |         LogDebug( "Page2Procedure: start UM_SETTINGS2DIALOG" );
 | 
|---|
| 652 | #endif
 | 
|---|
| 653 |         // set state of checkbuttons
 | 
|---|
| 654 |         pset->AdjustButton (hwnd, WID_CB_SSWENABLE,
 | 
|---|
| 655 |                             pset->SnapshotWindow ());
 | 
|---|
| 656 |         pset->AdjustButton (hwnd, WID_CB_SSWHIDE,
 | 
|---|
| 657 |                             pset->SSWHide ());
 | 
|---|
| 658 |         pset->AdjustButton (hwnd, WID_CB_SSWALWAYSONTOP,
 | 
|---|
| 659 |                             pset->SSWAlwaysOnTop ());
 | 
|---|
| 660 | #ifdef _QUIET_
 | 
|---|
| 661 | //#if 1
 | 
|---|
| 662 |         pset->AdjustButton (hwnd, WID_CB_SERIALCAPTURE,
 | 
|---|
| 663 |                             pset->SerialCapture ());
 | 
|---|
| 664 |         pset->AdjustButton (hwnd, WID_CB_DELAYCOUNTDOWN,
 | 
|---|
| 665 |                             pset->DelayCountdown ());
 | 
|---|
| 666 |         pset->AdjustButton (hwnd, WID_CB_DELAYEDCAPTURE,
 | 
|---|
| 667 |                             pset->DelayedCapture ());
 | 
|---|
| 668 | 
 | 
|---|
| 669 |         // init delay time sb
 | 
|---|
| 670 |         WinSendDlgItemMsg (hwnd, WID_SB_DELAYTIME, SPBM_SETLIMITS,
 | 
|---|
| 671 |                            MPFROMLONG (65536), MPFROMLONG (1));
 | 
|---|
| 672 |         WinSendDlgItemMsg (hwnd, WID_SB_DELAYTIME, SPBM_SETCURRENTVALUE,
 | 
|---|
| 673 |                            MPFROMLONG (pset->QueryDelayTime ()), 0);
 | 
|---|
| 674 | 
 | 
|---|
| 675 |         // init serial time sb
 | 
|---|
| 676 |         WinSendDlgItemMsg (hwnd, WID_SB_SERIALTIME, SPBM_SETLIMITS,
 | 
|---|
| 677 |                            MPFROMLONG (65536), MPFROMLONG (1));
 | 
|---|
| 678 |         WinSendDlgItemMsg (hwnd, WID_SB_SERIALTIME, SPBM_SETCURRENTVALUE,
 | 
|---|
| 679 |                            MPFROMLONG (pset->QuerySerialTime ()), 0);
 | 
|---|
| 680 | #endif
 | 
|---|
| 681 |         switch (pset->QuerySSWCaptureType ())
 | 
|---|
| 682 |         {
 | 
|---|
| 683 |         case CAP_WINDOWINT:
 | 
|---|
| 684 |             WinSendDlgItemMsg (hwnd, WID_SSWWINDOWINT, BM_CLICK,
 | 
|---|
| 685 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 686 |             break;
 | 
|---|
| 687 |         case CAP_SCREENREGION:
 | 
|---|
| 688 |             WinSendDlgItemMsg (hwnd, WID_SSWSCREENREGION, BM_CLICK,
 | 
|---|
| 689 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 690 |             break;
 | 
|---|
| 691 |         case CAP_WINDOW:
 | 
|---|
| 692 |             WinSendDlgItemMsg (hwnd, WID_SSWWINDOW, BM_CLICK,
 | 
|---|
| 693 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 694 |             break;
 | 
|---|
| 695 |         default:
 | 
|---|
| 696 |             WinSendDlgItemMsg (hwnd, WID_SSWSCREEN, BM_CLICK,
 | 
|---|
| 697 |                                MPFROMSHORT(TRUE), 0);
 | 
|---|
| 698 |             break;
 | 
|---|
| 699 |         }
 | 
|---|
| 700 | 
 | 
|---|
| 701 |         // show or hide snapshot window
 | 
|---|
| 702 |         if (! WinSendDlgItemMsg (hwnd, WID_CB_SSWENABLE,
 | 
|---|
| 703 |                                  BM_QUERYCHECK, 0, 0))
 | 
|---|
| 704 |             WinShowWindow (hwndSnapshot, FALSE);
 | 
|---|
| 705 |         else
 | 
|---|
| 706 |             WinShowWindow (hwndSnapshot, TRUE);
 | 
|---|
| 707 | 
 | 
|---|
| 708 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 709 |         LogDebug( "Page1Procedure: end UM_SETTINGS2DIALOG" );
 | 
|---|
| 710 | #endif
 | 
|---|
| 711 |         return MRESULT (FALSE);
 | 
|---|
| 712 | 
 | 
|---|
| 713 |     case UM_ADJUST:
 | 
|---|
| 714 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 715 |             LogDebug( "Page2Procedure: start UM_ADJUST" );
 | 
|---|
| 716 | #endif
 | 
|---|
| 717 | #ifndef _QUIET_
 | 
|---|
| 718 | //#if 0
 | 
|---|
| 719 |         // query state of checkbuttons and set flags
 | 
|---|
| 720 |         pset->SSWHide(WinQueryButtonCheckstate(hwnd, WID_CB_SSWHIDE));
 | 
|---|
| 721 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 722 |             LogDebug( "Page2Procedure: checkpoint 1" );
 | 
|---|
| 723 | #endif
 | 
|---|
| 724 |         pset->SnapshotWindow(WinQueryButtonCheckstate(hwnd, WID_CB_SSWENABLE));
 | 
|---|
| 725 |         pset->SSWAlwaysOnTop(WinQueryButtonCheckstate(hwnd,
 | 
|---|
| 726 |                                                       WID_CB_SSWALWAYSONTOP));
 | 
|---|
| 727 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 728 |             LogDebug( "Page2Procedure: checkpoint 2" );
 | 
|---|
| 729 | #endif
 | 
|---|
| 730 | #else
 | 
|---|
| 731 |             // query state of checkbuttons and set flags
 | 
|---|
| 732 |             pset->SerialCapture(WinQueryButtonCheckstate
 | 
|---|
| 733 |                                 (hwnd, WID_CB_SERIALCAPTURE));
 | 
|---|
| 734 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 735 |             LogDebug( "Page3Procedure: checkpoint 1" );
 | 
|---|
| 736 | #endif
 | 
|---|
| 737 |             pset->DelayCountdown(WinQueryButtonCheckstate
 | 
|---|
| 738 |                                  (hwnd, WID_CB_DELAYCOUNTDOWN));
 | 
|---|
| 739 |             pset->DelayedCapture (WinQueryButtonCheckstate
 | 
|---|
| 740 |                                   (hwnd,WID_CB_DELAYEDCAPTURE));
 | 
|---|
| 741 | #endif
 | 
|---|
| 742 |         // get ssw capture type
 | 
|---|
| 743 |         if (WinSendMsg (WinWindowFromID (hwnd, WID_SSWSCREENREGION),
 | 
|---|
| 744 |                         BM_QUERYCHECK, 0,0))
 | 
|---|
| 745 |             pset->SetSSWCaptureType (CAP_SCREENREGION);
 | 
|---|
| 746 |         else if (WinSendMsg (WinWindowFromID (hwnd, WID_SSWWINDOW),
 | 
|---|
| 747 |                              BM_QUERYCHECK, 0,0))
 | 
|---|
| 748 |             pset->SetSSWCaptureType (CAP_WINDOW);
 | 
|---|
| 749 |         else if (WinSendMsg (WinWindowFromID (hwnd, WID_SSWWINDOWINT),
 | 
|---|
| 750 |                              BM_QUERYCHECK, 0,0))
 | 
|---|
| 751 |             pset->SetSSWCaptureType (CAP_WINDOWINT);
 | 
|---|
| 752 |         else
 | 
|---|
| 753 |             pset->SetSSWCaptureType (CAP_SCREEN);
 | 
|---|
| 754 | #ifdef _QUIET_
 | 
|---|
| 755 | //#if 1
 | 
|---|
| 756 |         // delay time
 | 
|---|
| 757 |         ULONG   ul;
 | 
|---|
| 758 |         if (! BOOL (WinSendDlgItemMsg (hwnd, WID_SB_DELAYTIME,
 | 
|---|
| 759 |                                        SPBM_QUERYVALUE,
 | 
|---|
| 760 |                                        MPFROMP (&ul),
 | 
|---|
| 761 |                                        MPFROM2SHORT (0, 0))))
 | 
|---|
| 762 |             ul = 5L;
 | 
|---|
| 763 |         pset->SetDelayTime (ul);
 | 
|---|
| 764 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 765 |         LogDebug( "Page3Procedure: checkpoint 3" );
 | 
|---|
| 766 | #endif
 | 
|---|
| 767 | 
 | 
|---|
| 768 |         // serial time
 | 
|---|
| 769 |         if (! BOOL (WinSendDlgItemMsg (hwnd, WID_SB_SERIALTIME,
 | 
|---|
| 770 |                                        SPBM_QUERYVALUE,
 | 
|---|
| 771 |                                        MPFROMP (&ul),
 | 
|---|
| 772 |                                        MPFROM2SHORT (0, 0))))
 | 
|---|
| 773 |             ul = 10L;
 | 
|---|
| 774 |         pset->SetSerialTime (ul);
 | 
|---|
| 775 |         pset->bSerialCapture = pset->SerialCapture ();
 | 
|---|
| 776 | #endif
 | 
|---|
| 777 |         if (saveum)
 | 
|---|
| 778 |             pset->Save ();
 | 
|---|
| 779 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 780 |         LogDebug( "Page2Procedure: end UM_ADJUST" );
 | 
|---|
| 781 | #endif
 | 
|---|
| 782 |         break;
 | 
|---|
| 783 | 
 | 
|---|
| 784 |     case WM_CONTROL:
 | 
|---|
| 785 |         switch (SHORT1FROMMP (mp1))
 | 
|---|
| 786 |         {
 | 
|---|
| 787 |         case WID_CB_SSWENABLE:
 | 
|---|
| 788 |             if (! WinSendDlgItemMsg (hwnd, WID_CB_SSWENABLE,
 | 
|---|
| 789 |                                      BM_QUERYCHECK, 0, 0))
 | 
|---|
| 790 |                 WinShowWindow (hwndSnapshot, FALSE);
 | 
|---|
| 791 |             else
 | 
|---|
| 792 |                 WinShowWindow (hwndSnapshot, TRUE);
 | 
|---|
| 793 |             break;
 | 
|---|
| 794 |         case WID_CB_DELAYEDCAPTURE:
 | 
|---|
| 795 | 
 | 
|---|
| 796 |             WinSendDlgItemMsg (g_hwndPage0, WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
 | 
|---|
| 797 |                                MPFROMLONG (WinQueryButtonCheckstate
 | 
|---|
| 798 |                                            (hwnd,WID_CB_DELAYEDCAPTURE)),
 | 
|---|
| 799 |                                MPFROMLONG (0));
 | 
|---|
| 800 |             WinSendDlgItemMsg (WinWindowFromID(hwndFrame, FID_CLIENT),
 | 
|---|
| 801 |                                WID_CB_DELAYEDCAPTURE, BM_SETCHECK,
 | 
|---|
| 802 |                                MPFROMLONG (WinQueryButtonCheckstate
 | 
|---|
| 803 |                                            (hwnd,WID_CB_DELAYEDCAPTURE)),
 | 
|---|
| 804 |                                MPFROMLONG (0));
 | 
|---|
| 805 |             break;
 | 
|---|
| 806 |         }
 | 
|---|
| 807 |         return MRESULT (FALSE);
 | 
|---|
| 808 |     }
 | 
|---|
| 809 | 
 | 
|---|
| 810 |     return WinDefDlgProc (hwnd, msg, mp1, mp2);
 | 
|---|
| 811 | }
 | 
|---|
| 812 | 
 | 
|---|
| 813 | // ** Page3Procedure ****************************************************** /*FOLD00*/
 | 
|---|
| 814 | 
 | 
|---|
| 815 | MRESULT EXPENTRY
 | 
|---|
| 816 | SETTINGS :: Page3Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 817 | {
 | 
|---|
| 818 |     static PSETTINGS   pset = NULL;
 | 
|---|
| 819 | 
 | 
|---|
| 820 |     switch (msg)
 | 
|---|
| 821 |     {
 | 
|---|
| 822 |     case WM_INITDLG:
 | 
|---|
| 823 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 824 |         LogDebug( "Page3Procedure: start WM_INITDLG" );
 | 
|---|
| 825 | #endif
 | 
|---|
| 826 |         pset = PSETTINGS (mp2);
 | 
|---|
| 827 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 828 |         LogDebug( "Page3Procedure: end WM_INITDLG" );
 | 
|---|
| 829 | #endif
 | 
|---|
| 830 |         return MRESULT (FALSE);
 | 
|---|
| 831 | 
 | 
|---|
| 832 |     case WM_COMMAND:
 | 
|---|
| 833 |         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
 | 
|---|
| 834 |             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
 | 
|---|
| 835 |         return MRESULT( FALSE );
 | 
|---|
| 836 | 
 | 
|---|
| 837 |     case UM_SETTINGS2DIALOG:
 | 
|---|
| 838 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 839 |         LogDebug( "Page3Procedure: start UM_SETTINGS2DIALOG" );
 | 
|---|
| 840 | #endif
 | 
|---|
| 841 |         // set state of checkbuttons
 | 
|---|
| 842 |         pset->AdjustButton (hwnd, WID_CB_SERIALCAPTURE,
 | 
|---|
| 843 |                             pset->SerialCapture ());
 | 
|---|
| 844 |         pset->AdjustButton (hwnd, WID_CB_DELAYCOUNTDOWN,
 | 
|---|
| 845 |                             pset->DelayCountdown ());
 | 
|---|
| 846 |         pset->AdjustButton (hwnd, WID_CB_DOSOUND,
 | 
|---|
| 847 |                             pset->DoSound ());
 | 
|---|
| 848 |         pset->AdjustButton (hwnd, WID_CB_IDLEPRIORITY,
 | 
|---|
| 849 |                             pset->QueryFlag(SEI_IDLEPRIORITY));
 | 
|---|
| 850 | 
 | 
|---|
| 851 |         // init delay time sb
 | 
|---|
| 852 |         WinSendDlgItemMsg (hwnd, WID_SB_DELAYTIME, SPBM_SETLIMITS,
 | 
|---|
| 853 |                            MPFROMLONG (65536), MPFROMLONG (1));
 | 
|---|
| 854 |         WinSendDlgItemMsg (hwnd, WID_SB_DELAYTIME, SPBM_SETCURRENTVALUE,
 | 
|---|
| 855 |                            MPFROMLONG (pset->QueryDelayTime ()), 0);
 | 
|---|
| 856 | 
 | 
|---|
| 857 |         // init serial time sb
 | 
|---|
| 858 |         WinSendDlgItemMsg (hwnd, WID_SB_SERIALTIME, SPBM_SETLIMITS,
 | 
|---|
| 859 |                            MPFROMLONG (65536), MPFROMLONG (1));
 | 
|---|
| 860 |         WinSendDlgItemMsg (hwnd, WID_SB_SERIALTIME, SPBM_SETCURRENTVALUE,
 | 
|---|
| 861 |                            MPFROMLONG (pset->QuerySerialTime ()), 0);
 | 
|---|
| 862 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 863 |         LogDebug( "Page3Procedure: end UM_SETTINGS2DIALOG" );
 | 
|---|
| 864 | #endif
 | 
|---|
| 865 |         return MRESULT (FALSE);
 | 
|---|
| 866 | 
 | 
|---|
| 867 |     case UM_ADJUST:
 | 
|---|
| 868 |         {
 | 
|---|
| 869 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 870 |             LogDebug( "Page3Procedure: start UM_ADJUST" );
 | 
|---|
| 871 | #endif
 | 
|---|
| 872 |             // query state of checkbuttons and set flags
 | 
|---|
| 873 |             pset->SerialCapture(WinQueryButtonCheckstate
 | 
|---|
| 874 |                                 (hwnd, WID_CB_SERIALCAPTURE));
 | 
|---|
| 875 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 876 |             LogDebug( "Page3Procedure: checkpoint 1" );
 | 
|---|
| 877 | #endif
 | 
|---|
| 878 |             pset->DelayCountdown(WinQueryButtonCheckstate
 | 
|---|
| 879 |                                  (hwnd, WID_CB_DELAYCOUNTDOWN));
 | 
|---|
| 880 |             pset->DoSound(WinQueryButtonCheckstate
 | 
|---|
| 881 |                           (hwnd, WID_CB_DOSOUND));
 | 
|---|
| 882 |             pset->SetFlag(SEI_IDLEPRIORITY, WinQueryButtonCheckstate
 | 
|---|
| 883 |                           (hwnd, WID_CB_IDLEPRIORITY));
 | 
|---|
| 884 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 885 |             LogDebug( "Page3Procedure: checkpoint 2" );
 | 
|---|
| 886 | #endif
 | 
|---|
| 887 | 
 | 
|---|
| 888 |             // delay time
 | 
|---|
| 889 |             ULONG   ul;
 | 
|---|
| 890 |             if (! BOOL (WinSendDlgItemMsg (hwnd, WID_SB_DELAYTIME,
 | 
|---|
| 891 |                                            SPBM_QUERYVALUE,
 | 
|---|
| 892 |                                            MPFROMP (&ul),
 | 
|---|
| 893 |                                            MPFROM2SHORT (0, 0))))
 | 
|---|
| 894 |                 ul = 5L;
 | 
|---|
| 895 |             pset->SetDelayTime (ul);
 | 
|---|
| 896 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 897 |             LogDebug( "Page3Procedure: checkpoint 3" );
 | 
|---|
| 898 | #endif
 | 
|---|
| 899 | 
 | 
|---|
| 900 |             // serial time
 | 
|---|
| 901 |             if (! BOOL (WinSendDlgItemMsg (hwnd, WID_SB_SERIALTIME,
 | 
|---|
| 902 |                                            SPBM_QUERYVALUE,
 | 
|---|
| 903 |                                            MPFROMP (&ul),
 | 
|---|
| 904 |                                            MPFROM2SHORT (0, 0))))
 | 
|---|
| 905 |                 ul = 10L;
 | 
|---|
| 906 |             pset->SetSerialTime (ul);
 | 
|---|
| 907 |             pset->bSerialCapture = pset->SerialCapture ();
 | 
|---|
| 908 |             pset->idleSetInIni = pset->QueryFlag(SEI_IDLEPRIORITY);
 | 
|---|
| 909 | 
 | 
|---|
| 910 |             if (saveum)
 | 
|---|
| 911 |                 pset->Save ();
 | 
|---|
| 912 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 913 |             LogDebug( "Page3Procedure: end UM_ADJUST" );
 | 
|---|
| 914 | #endif
 | 
|---|
| 915 |         }
 | 
|---|
| 916 |         break;
 | 
|---|
| 917 | 
 | 
|---|
| 918 |     case WM_CONTROL:
 | 
|---|
| 919 |         switch (SHORT1FROMMP (mp1))
 | 
|---|
| 920 |         {
 | 
|---|
| 921 |         case WID_CB_SERIALCAPTURE:
 | 
|---|
| 922 |             {
 | 
|---|
| 923 |                 HWND hwndButton =
 | 
|---|
| 924 |                     WinWindowFromID (WinWindowFromID (hwndFrame, FID_CLIENT),
 | 
|---|
| 925 |                                      WID_CB_DELAYEDCAPTURE);
 | 
|---|
| 926 |                 if (! WinSendDlgItemMsg (hwnd, WID_CB_SERIALCAPTURE,
 | 
|---|
| 927 |                                          BM_QUERYCHECK, 0, 0))
 | 
|---|
| 928 |                     WinEnableWindow (hwndButton, TRUE);
 | 
|---|
| 929 |                 else
 | 
|---|
| 930 |                     WinEnableWindow (hwndButton, FALSE);
 | 
|---|
| 931 |             }
 | 
|---|
| 932 |             break;
 | 
|---|
| 933 |         }
 | 
|---|
| 934 |         return MRESULT (FALSE);
 | 
|---|
| 935 |     }
 | 
|---|
| 936 | 
 | 
|---|
| 937 |     return WinDefDlgProc (hwnd, msg, mp1, mp2);
 | 
|---|
| 938 | }
 | 
|---|
| 939 | 
 | 
|---|
| 940 | // ** Page4Procedure ****************************************************** /*FOLD00*/
 | 
|---|
| 941 | 
 | 
|---|
| 942 | MRESULT EXPENTRY
 | 
|---|
| 943 | SETTINGS :: Page4Procedure (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 944 | {
 | 
|---|
| 945 |     static PSETTINGS   pset = NULL;
 | 
|---|
| 946 | 
 | 
|---|
| 947 |     switch (msg)
 | 
|---|
| 948 |     {
 | 
|---|
| 949 |     case WM_INITDLG:
 | 
|---|
| 950 |         {
 | 
|---|
| 951 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 952 |             LogDebug( "Page4Procedure: start WM_INITDLG" );
 | 
|---|
| 953 | #endif
 | 
|---|
| 954 |             pset = PSETTINGS (mp2);
 | 
|---|
| 955 | 
 | 
|---|
| 956 |             pset->GetLanguages(WinWindowFromID (hwnd, WID_LB_LANGUAGES));
 | 
|---|
| 957 | 
 | 
|---|
| 958 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 959 |             LogDebug( "Page4Procedure: WM_INITDLG: after GetLanguages()" );
 | 
|---|
| 960 | #endif
 | 
|---|
| 961 |             HDIR          hdir;
 | 
|---|
| 962 |             ULONG         c, fl;
 | 
|---|
| 963 |             FILEFINDBUF3  findbuf;
 | 
|---|
| 964 |             APIRET        rc;
 | 
|---|
| 965 |             PSZ           psz;
 | 
|---|
| 966 | 
 | 
|---|
| 967 |             // find all hlps and add the names to the language list
 | 
|---|
| 968 |             fl   = FILE_NORMAL;
 | 
|---|
| 969 |             hdir = HDIR_CREATE;
 | 
|---|
| 970 |             c    = 1;
 | 
|---|
| 971 |             rc   = DosFindFirst ("*.hlp", &hdir, fl, &findbuf,
 | 
|---|
| 972 |                                  sizeof (findbuf), &c, FIL_STANDARD);
 | 
|---|
| 973 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 974 |             LogDebug( "Page4Procedure: WM_INITDLG: Entering help file loop ..." );
 | 
|---|
| 975 | #endif
 | 
|---|
| 976 |             while (!rc)
 | 
|---|
| 977 |             {
 | 
|---|
| 978 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 979 |                 LogDebug( "Page4Procedure: WM_INITDLG: Doing '%s' ...", findbuf.achName );
 | 
|---|
| 980 | #endif
 | 
|---|
| 981 |                 if ((psz = strchr (findbuf.achName, '.')))
 | 
|---|
| 982 |                     *psz = '\0';
 | 
|---|
| 983 |                 findbuf.achName[0] = toupper (findbuf.achName[0]);
 | 
|---|
| 984 |                 WinInsertLboxItem (WinWindowFromID (hwnd, WID_LB_LANGUAGESHELP),
 | 
|---|
| 985 |                                    LIT_END, findbuf.achName);
 | 
|---|
| 986 |                 c = 1;
 | 
|---|
| 987 |                 rc = DosFindNext (hdir, &findbuf, sizeof (findbuf), &c);
 | 
|---|
| 988 |             }
 | 
|---|
| 989 |             DosFindClose (hdir);
 | 
|---|
| 990 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 991 |             LogDebug( "Page4Procedure: WM_INITDLG: help file loop done." );
 | 
|---|
| 992 | #endif
 | 
|---|
| 993 | 
 | 
|---|
| 994 |             WinSendMsg (hwnd, UM_SETTINGS2DIALOG, 0,0);
 | 
|---|
| 995 | 
 | 
|---|
| 996 |             if (pset->fAutoLanguage)
 | 
|---|
| 997 |                 WinEnableWindow (WinWindowFromID (hwnd, WID_ST_LANGNOTE),
 | 
|---|
| 998 |                                  FALSE);
 | 
|---|
| 999 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1000 |             LogDebug( "Page4Procedure: end WM_INITDLG" );
 | 
|---|
| 1001 | #endif
 | 
|---|
| 1002 |         }
 | 
|---|
| 1003 |         return MRESULT (FALSE);
 | 
|---|
| 1004 | 
 | 
|---|
| 1005 |     case WM_COMMAND:
 | 
|---|
| 1006 |         if( SHORT1FROMMP( mp1 ) == DID_CANCEL )
 | 
|---|
| 1007 |             WinPostMsg( g_hwndSettingsDialog, msg, mp1, mp2 );
 | 
|---|
| 1008 |         return MRESULT( FALSE );
 | 
|---|
| 1009 | 
 | 
|---|
| 1010 |     case UM_SETTINGS2DIALOG:
 | 
|---|
| 1011 |         {
 | 
|---|
| 1012 | 
 | 
|---|
| 1013 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1014 |             LogDebug( "Page4Procedure: start UM_SETTINGS2DIALOG" );
 | 
|---|
| 1015 | #endif
 | 
|---|
| 1016 |             // select the appropriate entry in the language-listbox
 | 
|---|
| 1017 |             CHAR     ach[_MAX_FNAME];
 | 
|---|
| 1018 |             HWND     hwndLB = WinWindowFromID (hwnd, WID_LB_LANGUAGES);
 | 
|---|
| 1019 |             ULONG    c, i;
 | 
|---|
| 1020 | 
 | 
|---|
| 1021 |             c = WinQueryLboxCount (hwndLB);
 | 
|---|
| 1022 | 
 | 
|---|
| 1023 |             for (i = 0; i < c; i++)
 | 
|---|
| 1024 |             {
 | 
|---|
| 1025 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1026 |                 LogDebug( "Page4Procedure: UM_SETTINGS2DIALOG: i.1 = %d", i );
 | 
|---|
| 1027 | #endif
 | 
|---|
| 1028 |                 PSZ psz = PSZ(WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES,
 | 
|---|
| 1029 |                                                  LM_QUERYITEMHANDLE,
 | 
|---|
| 1030 |                                                  MPFROMLONG(i), NULL));
 | 
|---|
| 1031 | //                WinQueryLboxItemText (hwndLB, i, ach, sizeof (ach));
 | 
|---|
| 1032 |                 if (stricmp (pset->QueryString(SEI_LANGUAGE), psz) == 0)
 | 
|---|
| 1033 |                     break;
 | 
|---|
| 1034 |             }
 | 
|---|
| 1035 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1036 |             LogDebug( "Page4Procedure: UM_SETTINGS2DIALOG: after loop 1" );
 | 
|---|
| 1037 | #endif
 | 
|---|
| 1038 |             if (i < c)
 | 
|---|
| 1039 |                 WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES, LM_SELECTITEM,
 | 
|---|
| 1040 |                                    MPFROMSHORT (i), MPFROMSHORT (TRUE));
 | 
|---|
| 1041 |             else
 | 
|---|
| 1042 |                 WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES, LM_SELECTITEM,
 | 
|---|
| 1043 |                                    MPFROMSHORT (0), MPFROMSHORT (TRUE));
 | 
|---|
| 1044 |             hwndLB = WinWindowFromID (hwnd, WID_LB_LANGUAGESHELP);
 | 
|---|
| 1045 |             c = WinQueryLboxCount (hwndLB);
 | 
|---|
| 1046 | 
 | 
|---|
| 1047 |             for (i = 0; i < c; i++)
 | 
|---|
| 1048 |             {
 | 
|---|
| 1049 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1050 |                 LogDebug( "Page4Procedure: UM_SETTINGS2DIALOG: i.2 = %d", i );
 | 
|---|
| 1051 | #endif
 | 
|---|
| 1052 |                 WinQueryLboxItemText (hwndLB, i, ach, sizeof (ach));
 | 
|---|
| 1053 |                 if (stricmp (pset->QueryString (SEI_LANGUAGEHELP), ach) == 0)
 | 
|---|
| 1054 |                     break;
 | 
|---|
| 1055 |             }
 | 
|---|
| 1056 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1057 |             LogDebug( "Page4Procedure: UM_SETTINGS2DIALOG: after loop 2" );
 | 
|---|
| 1058 | #endif
 | 
|---|
| 1059 |             if (i < c)
 | 
|---|
| 1060 |                 WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, LM_SELECTITEM,
 | 
|---|
| 1061 |                                    MPFROMSHORT (i), MPFROMSHORT (TRUE));
 | 
|---|
| 1062 |             else
 | 
|---|
| 1063 |                 WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, LM_SELECTITEM,
 | 
|---|
| 1064 |                                    MPFROMSHORT (0), MPFROMSHORT (TRUE));
 | 
|---|
| 1065 | #ifdef _DOLOGDEBUG_
 | 
|---|
| 1066 |             LogDebug( "Page4Procedure: end UM_SETTINGS2DIALOG" );
 | 
|---|
| 1067 | #endif
 | 
|---|
| 1068 |         }
 | 
|---|
| 1069 |         return MRESULT (FALSE);
 | 
|---|
| 1070 | 
 | 
|---|
| 1071 |     case WM_DESTROY:
 | 
|---|
| 1072 |         {
 | 
|---|
| 1073 |             CHAR   ach[_MAX_FNAME];
 | 
|---|
| 1074 | 
 | 
|---|
| 1075 |             ULONG ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES,
 | 
|---|
| 1076 |                                                   LM_QUERYSELECTION,
 | 
|---|
| 1077 |                                                   MPFROMLONG (LIT_FIRST), 0L));
 | 
|---|
| 1078 |             PSZ psz = PSZ(WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGES,
 | 
|---|
| 1079 |                                              LM_QUERYITEMHANDLE,
 | 
|---|
| 1080 |                                              MPFROMLONG(ul), NULL));
 | 
|---|
| 1081 |             pset->SetString(SEI_LANGUAGE, psz);
 | 
|---|
| 1082 | 
 | 
|---|
| 1083 |             ul = USHORT (WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP,
 | 
|---|
| 1084 |                                             LM_QUERYSELECTION,
 | 
|---|
| 1085 |                                             MPFROMLONG (LIT_FIRST), 0L));
 | 
|---|
| 1086 |             WinSendDlgItemMsg (hwnd, WID_LB_LANGUAGESHELP, LM_QUERYITEMTEXT,
 | 
|---|
| 1087 |                                MPFROM2SHORT (ul, sizeof (ach)), MPFROMP (ach));
 | 
|---|
| 1088 |             pset->SetString (SEI_LANGUAGEHELP, ach);
 | 
|---|
| 1089 | 
 | 
|---|
| 1090 |             if (saveum)
 | 
|---|
| 1091 |                 pset->Save ();
 | 
|---|
| 1092 |         }
 | 
|---|
| 1093 |         return MRESULT (FALSE);
 | 
|---|
| 1094 |     }
 | 
|---|
| 1095 | 
 | 
|---|
| 1096 |     return WinDefDlgProc (hwnd, msg, mp1, mp2);
 | 
|---|
| 1097 | }
 | 
|---|
| 1098 | 
 | 
|---|
| 1099 | // ** AdjustSaveTypeButtons *********************************************** /*FOLD00*/
 | 
|---|
| 1100 | 
 | 
|---|
| 1101 | VOID AdjustSaveTypeButtons (BOOL f)
 | 
|---|
| 1102 | {
 | 
|---|
| 1103 |     HWND   hwndClient = WinWindowFromID (hwndFrame, FID_CLIENT);
 | 
|---|
| 1104 | 
 | 
|---|
| 1105 |     // FIXME um, em, global variables :-$
 | 
|---|
| 1106 |     WinEnableWindow (WinWindowFromID (hwndClient, WID_RB_CLIPBOARD), !f);
 | 
|---|
| 1107 |     WinEnableWindow (WinWindowFromID (hwndClient, WID_RB_FILE), !f);
 | 
|---|
| 1108 | }
 | 
|---|
| 1109 | 
 | 
|---|
| 1110 | // ** QueryWindowData ***************************************************** /*fold00*/
 | 
|---|
| 1111 | 
 | 
|---|
| 1112 | VOID SETTINGS :: QueryWindowData (SWP *pswp, USHORT us[7], BOOL f)
 | 
|---|
| 1113 | {
 | 
|---|
| 1114 |     // FIXME puke, yukk, choke! get this flag thing away! do it better!
 | 
|---|
| 1115 |     // FIXME what is with US?
 | 
|---|
| 1116 |     if (f)
 | 
|---|
| 1117 |         memcpy (pswp, QueryBinary(SEI_SWPSSW), sizeof (SWP));
 | 
|---|
| 1118 |     else
 | 
|---|
| 1119 |         memcpy (pswp, QueryBinary(SEI_SWP), sizeof (SWP));
 | 
|---|
| 1120 | 
 | 
|---|
| 1121 |     LONG  cx, cy;
 | 
|---|
| 1122 |     cx = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
 | 
|---|
| 1123 |     cy = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
 | 
|---|
| 1124 | 
 | 
|---|
| 1125 |     if (pswp->cx < 32)
 | 
|---|
| 1126 |         pswp->cx = 32;
 | 
|---|
| 1127 |     // bigger than screen?
 | 
|---|
| 1128 |     if (pswp->cx > cx)
 | 
|---|
| 1129 |         pswp->cx = cx;
 | 
|---|
| 1130 |     // partly outside of screen?
 | 
|---|
| 1131 |     if (pswp->x+pswp->cx >= cx)
 | 
|---|
| 1132 |         pswp->x = cx-pswp->cx;
 | 
|---|
| 1133 |     if (pswp->cy < 32)
 | 
|---|
| 1134 |         pswp->cy = 32;
 | 
|---|
| 1135 |     // bigger than screen?
 | 
|---|
| 1136 |     if (pswp->cy > cy)
 | 
|---|
| 1137 |         pswp->cy = cy;
 | 
|---|
| 1138 |     // partly outside of screen?
 | 
|---|
| 1139 |     if (pswp->y+pswp->cy >= cy)
 | 
|---|
| 1140 |         pswp->y = cy-pswp->cy;
 | 
|---|
| 1141 | }
 | 
|---|
| 1142 | 
 | 
|---|
| 1143 | // ** ReloadResources ***************************************************** /*FOLD00*/
 | 
|---|
| 1144 | 
 | 
|---|
| 1145 | BOOL Settings :: ReloadResources (PSZ psz)
 | 
|---|
| 1146 | {
 | 
|---|
| 1147 |     if (g_hmod)
 | 
|---|
| 1148 |         DosFreeModule(g_hmod);
 | 
|---|
| 1149 | 
 | 
|---|
| 1150 |     APIRET  rc;
 | 
|---|
| 1151 | 
 | 
|---|
| 1152 |     if ((rc = DosLoadModule(PSZ(NULL), 0, psz, &g_hmod)))
 | 
|---|
| 1153 |     {
 | 
|---|
| 1154 |         DisplayError("Error",
 | 
|---|
| 1155 |                      "Could not (re)load resource module '%s' (return code %d). "
 | 
|---|
| 1156 |                      "Make sure the DLL is in the LIBPATH. If this is the case, "
 | 
|---|
| 1157 |                      "try deleting GOTCHA.INI and restart. If this fails, contact "
 | 
|---|
| 1158 |                      "the author (ygk@qwest.net).", psz, rc);
 | 
|---|
| 1159 |         exit(1);
 | 
|---|
| 1160 |     }
 | 
|---|
| 1161 | 
 | 
|---|
| 1162 |     ResourceString::Module(g_hmod);
 | 
|---|
| 1163 | #ifdef _QUIET_
 | 
|---|
| 1164 |     pszPageTab[0] = RSTR (IDS_MAINWIN);
 | 
|---|
| 1165 |     pszPageTab[1] = RSTR (IDS_CAPTURE );
 | 
|---|
| 1166 |     pszPageTab[2] = RSTR (IDS_PAGESAVE);
 | 
|---|
| 1167 |     pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);
 | 
|---|
| 1168 | #else
 | 
|---|
| 1169 |     pszPageTab[0] = RSTR (IDS_PAGESAVE);
 | 
|---|
| 1170 |     pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT);
 | 
|---|
| 1171 |     pszPageTab[2] = RSTR (IDS_CAPTURE );
 | 
|---|
| 1172 |     pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);
 | 
|---|
| 1173 | #endif
 | 
|---|
| 1174 |     for( int i = 0; i < BMF_INVALID; i++ ) {
 | 
|---|
| 1175 |         ifi[ i ].label = RSTR ( IDS_BMF_JPG+i ); }
 | 
|---|
| 1176 | 
 | 
|---|
| 1177 |     return TRUE;
 | 
|---|
| 1178 | }
 | 
|---|
| 1179 | 
 | 
|---|
| 1180 | // ** SelectLanguage ****************************************************** /*FOLD00*/
 | 
|---|
| 1181 | 
 | 
|---|
| 1182 | VOID Settings :: SelectLanguage (VOID)
 | 
|---|
| 1183 | {
 | 
|---|
| 1184 |     // set this to some default, as we must open the settings dialog for
 | 
|---|
| 1185 |     // selecting a language
 | 
|---|
| 1186 | #ifdef _QUIET_
 | 
|---|
| 1187 | //#if 1
 | 
|---|
| 1188 |     pszPageTab[0] = RSTR (IDS_MAINWIN);
 | 
|---|
| 1189 |     pszPageTab[1] = RSTR (IDS_CAPTURE );
 | 
|---|
| 1190 |     pszPageTab[2] = RSTR (IDS_PAGESAVE);
 | 
|---|
| 1191 |     pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);
 | 
|---|
| 1192 | #else
 | 
|---|
| 1193 |     pszPageTab[0] = RSTR (IDS_PAGESAVE);
 | 
|---|
| 1194 |     pszPageTab[1] = RSTR (IDS_PAGESNAPSHOT);
 | 
|---|
| 1195 |     pszPageTab[2] = RSTR (IDS_CAPTURE );
 | 
|---|
| 1196 |     pszPageTab[3] = RSTR (IDS_PAGELANGUAGE);
 | 
|---|
| 1197 | #endif
 | 
|---|
| 1198 |     // bring up the "select language" settings page
 | 
|---|
| 1199 |     Dialog (TRUE);
 | 
|---|
| 1200 | }
 | 
|---|
| 1201 | 
 | 
|---|
| 1202 | // ** GetLanguages ******************************************************** /*FOLD00*/
 | 
|---|
| 1203 | 
 | 
|---|
| 1204 | USHORT Settings :: GetLanguages (HWND hwnd)
 | 
|---|
| 1205 | {
 | 
|---|
| 1206 |     // find all dlls and add the names to the language list
 | 
|---|
| 1207 |     HDIR          hdir;
 | 
|---|
| 1208 |     ULONG         c, fl, ul;
 | 
|---|
| 1209 |     FILEFINDBUF3  findbuf;
 | 
|---|
| 1210 |     APIRET        rc;
 | 
|---|
| 1211 |     PSZ           psz;
 | 
|---|
| 1212 |     HMODULE       hmod;
 | 
|---|
| 1213 | 
 | 
|---|
| 1214 |     fl   = FILE_NORMAL;
 | 
|---|
| 1215 |     hdir = HDIR_CREATE;
 | 
|---|
| 1216 |     c    = 1;
 | 
|---|
| 1217 | #ifdef _QUIET_
 | 
|---|
| 1218 |     rc   = DosFindFirst ("goqres*.dll", &hdir, fl, &findbuf,
 | 
|---|
| 1219 |                          sizeof (findbuf), &c, FIL_STANDARD);
 | 
|---|
| 1220 | #else
 | 
|---|
| 1221 |     rc   = DosFindFirst ("gotres*.dll", &hdir, fl, &findbuf,
 | 
|---|
| 1222 |                          sizeof (findbuf), &c, FIL_STANDARD);
 | 
|---|
| 1223 | #endif
 | 
|---|
| 1224 |     while (!rc)
 | 
|---|
| 1225 |     {
 | 
|---|
| 1226 |         // we don't want the extension
 | 
|---|
| 1227 |         if ((psz = strchr (findbuf.achName, '.')))
 | 
|---|
| 1228 |             *psz = '\0';
 | 
|---|
| 1229 |         // try opening the dll and read the version etc. data
 | 
|---|
| 1230 |         if ((rc = DosLoadModule(PSZ(NULL), 0, findbuf.achName, &hmod)) == NO_ERROR) {
 | 
|---|
| 1231 |             PVOID pv;
 | 
|---|
| 1232 |             if (DosGetResource(hmod, RT_RCDATA, DLL_ID, &pv) == NO_ERROR) {
 | 
|---|
| 1233 | #ifdef _QUIET_
 | 
|---|
| 1234 |                 if (strcmp(PSZ(pv), "Gotchaq!") == 0) {
 | 
|---|
| 1235 | #else
 | 
|---|
| 1236 |                 if (strcmp(PSZ(pv), "Gotcha!") == 0) {
 | 
|---|
| 1237 | #endif
 | 
|---|
| 1238 |                     psz = PSZ(pv)+strlen(PSZ(pv))+3;
 | 
|---|
| 1239 |                     ul = WinInsertLboxItem (hwnd, LIT_END, psz);
 | 
|---|
| 1240 |                     WinSendMsg(hwnd, LM_SETITEMHANDLE, MPFROMLONG(ul),
 | 
|---|
| 1241 |                                MPFROMP (strdup(findbuf.achName)));
 | 
|---|
| 1242 |                 }
 | 
|---|
| 1243 |                 DosFreeResource(pv);
 | 
|---|
| 1244 |             }
 | 
|---|
| 1245 |             DosFreeModule(hmod);
 | 
|---|
| 1246 |         }
 | 
|---|
| 1247 |         c = 1;
 | 
|---|
| 1248 |         rc = DosFindNext (hdir, &findbuf, sizeof (findbuf), &c);
 | 
|---|
| 1249 |     }
 | 
|---|
| 1250 |     DosFindClose (hdir);
 | 
|---|
| 1251 | 
 | 
|---|
| 1252 |     return 1;
 | 
|---|
| 1253 | }
 | 
|---|
| 1254 | 
 | 
|---|
| 1255 | // ** GetFileExtension **************************************************** /*FOLD00*/
 | 
|---|
| 1256 | 
 | 
|---|
| 1257 | PSZ Settings :: GetFileExtension( SHORT type )
 | 
|---|
| 1258 | {
 | 
|---|
| 1259 |     if( type == BMF_INVALID )
 | 
|---|
| 1260 |         type = SHORT( QueryFileFormat() );
 | 
|---|
| 1261 |     if( ( type >= BMF_JPG ) && ( type < BMF_INVALID ) )
 | 
|---|
| 1262 |         return ifi[ type ].extension;
 | 
|---|
| 1263 |     return "";
 | 
|---|
| 1264 | }
 | 
|---|
| 1265 | 
 | 
|---|
| 1266 | #if 0
 | 
|---|
| 1267 | // ** GetFOURCC *********************************************************** /*FOLD00*/
 | 
|---|
| 1268 | 
 | 
|---|
| 1269 | FOURCC Settings :: GetFOURCC( SHORT type )
 | 
|---|
| 1270 | {
 | 
|---|
| 1271 |     if( type == BMF_INVALID )
 | 
|---|
| 1272 |         type = SHORT( QueryFileFormat() );
 | 
|---|
| 1273 |     if( ( type >= BMF_JPG ) && ( type < BMF_INVALID ) )
 | 
|---|
| 1274 |         return ifi[ type ].fourcc;
 | 
|---|
| 1275 |     return 0L;
 | 
|---|
| 1276 | }
 | 
|---|
| 1277 | #endif
 | 
|---|
| 1278 | // ** GetFileEAType ******************************************************* /*FOLD00*/
 | 
|---|
| 1279 | 
 | 
|---|
| 1280 | PSZ Settings :: GetFileEAType( SHORT type )
 | 
|---|
| 1281 | {
 | 
|---|
| 1282 |     if( type == BMF_INVALID )
 | 
|---|
| 1283 |         type = SHORT( QueryFileFormat() );
 | 
|---|
| 1284 |     if( ( type >= BMF_JPG ) && ( type < BMF_INVALID ) )
 | 
|---|
| 1285 |         return ifi[ type ].eaType;
 | 
|---|
| 1286 |     return "";
 | 
|---|
| 1287 | }
 | 
|---|
| 1288 | 
 | 
|---|
| 1289 | // ************************************************************************
 | 
|---|
| 1290 | 
 | 
|---|
| 1291 | PSZ Settings :: QueryNumSaveDir( VOID )
 | 
|---|
| 1292 | {
 | 
|---|
| 1293 |     // Using a static buffer here is not really good, but good enough
 | 
|---|
| 1294 |     // currently as we know there will be no concurrent access.
 | 
|---|
| 1295 |     static CHAR ach[_MAX_PATH];
 | 
|---|
| 1296 | 
 | 
|---|
| 1297 |     if( strspn( QueryString( SEI_NUMSAVEDIR ), " \t\n\r" ) ==
 | 
|---|
| 1298 |         strlen( QueryString( SEI_NUMSAVEDIR ) ) )
 | 
|---|
| 1299 |         return getcwd( ach, _MAX_PATH );
 | 
|---|
| 1300 |     return QueryString( SEI_NUMSAVEDIR );
 | 
|---|
| 1301 | }
 | 
|---|
| 1302 | 
 | 
|---|
| 1303 | // ************************************************************************
 | 
|---|