[118] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: inis.c 1014 2008-05-11 23:05:08Z gyoung $
|
---|
| 5 |
|
---|
| 6 | Copyright (c) 1993-98 M. Kimes
|
---|
[912] | 7 | Copyright (c) 2004, 2008 Steven H. Levine
|
---|
[118] | 8 |
|
---|
[145] | 9 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 10 | 01 Aug 04 SHL Rework fixup usage
|
---|
| 11 | 24 May 05 SHL Rework Win_Error usage
|
---|
[186] | 12 | 05 Jun 05 SHL Use QWL_USER
|
---|
[336] | 13 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[533] | 14 | 03 Nov 06 SHL Renames
|
---|
| 15 | 03 Nov 06 SHL Count thread usage
|
---|
[574] | 16 | 22 Mar 07 GKY Use QWL_USER
|
---|
[593] | 17 | 30 Mar 07 GKY Remove GetPString for window class names
|
---|
[603] | 18 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limits
|
---|
| 19 | 06 Apr 07 GKY Add some error checking in drag/drop
|
---|
[618] | 20 | 19 Apr 07 SHL Use FreeDragInfoData. Add more drag/drop error checks.
|
---|
[793] | 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[871] | 22 | 16 Nov 07 SHL Ensure fixup buffer sufficiently large
|
---|
[912] | 23 | 09 Jan 08 SHL Avoid closing INI more times than opened
|
---|
| 24 | 09 Jan 08 SHL Add some missing error reporting
|
---|
| 25 | 09 Jan 08 SHL Standardize PrfOpenProfile return checks
|
---|
[914] | 26 | 09 Jan 08 SHL Use CloseProfile to avoid spurious system INI closes
|
---|
[985] | 27 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[118] | 28 |
|
---|
| 29 | ***********************************************************************/
|
---|
| 30 |
|
---|
[2] | 31 | #include <stdlib.h>
|
---|
| 32 | #include <string.h>
|
---|
| 33 | #include <ctype.h>
|
---|
| 34 | #include <share.h>
|
---|
[689] | 35 | #include <process.h> // _beginthread
|
---|
[145] | 36 |
|
---|
[907] | 37 | #define INCL_DOS
|
---|
| 38 | #define INCL_DOSERRORS
|
---|
| 39 | #define INCL_WIN
|
---|
| 40 | #define INCL_GPI
|
---|
| 41 | #define INCL_LONGLONG // dircnrs.h
|
---|
| 42 |
|
---|
[2] | 43 | #include "fm3dlg.h"
|
---|
| 44 | #include "fm3str.h"
|
---|
| 45 | #include "mle.h"
|
---|
[907] | 46 | #include "errutil.h" // Dos_Error...
|
---|
| 47 | #include "strutil.h" // GetPString
|
---|
| 48 | #include "fm3dll.h"
|
---|
[2] | 49 |
|
---|
| 50 | #pragma data_seg(DATA2)
|
---|
[336] | 51 |
|
---|
| 52 | static PSZ pszSrcFile = __FILE__;
|
---|
| 53 |
|
---|
[551] | 54 | typedef struct
|
---|
| 55 | {
|
---|
[2] | 56 | USHORT size;
|
---|
[914] | 57 | CHAR ininame[CCHMAXPATH]; // Must be null string if user or system ini
|
---|
[551] | 58 | HINI hini;
|
---|
| 59 | BOOL working;
|
---|
| 60 | BOOL edit;
|
---|
| 61 | BOOL confirm;
|
---|
| 62 | HWND hwndMenu;
|
---|
| 63 | CHAR applname[CCHMAXPATH];
|
---|
| 64 | CHAR keyname[CCHMAXPATH];
|
---|
| 65 | CHAR *data;
|
---|
| 66 | ULONG datalen;
|
---|
| 67 | SHORT appindex;
|
---|
| 68 | SHORT keyindex;
|
---|
| 69 | BOOL dontclose;
|
---|
[2] | 70 | USHORT currid;
|
---|
[551] | 71 | BOOL isbinary;
|
---|
| 72 | HWND hwndIni;
|
---|
| 73 | HWND hwndApp;
|
---|
| 74 | HWND hwndKey;
|
---|
| 75 | HWND hwndData;
|
---|
| 76 | HWND hwndPopup;
|
---|
| 77 | HWND hwndCurrent;
|
---|
| 78 | }
|
---|
| 79 | INIDATA;
|
---|
[2] | 80 |
|
---|
[551] | 81 | typedef struct
|
---|
| 82 | {
|
---|
| 83 | USHORT size;
|
---|
| 84 | USHORT action;
|
---|
| 85 | CHAR filename1[CCHMAXPATH];
|
---|
| 86 | CHAR filename2[CCHMAXPATH];
|
---|
| 87 | CHAR app[CCHMAXPATH];
|
---|
| 88 | CHAR key[CCHMAXPATH];
|
---|
| 89 | CHAR app2[CCHMAXPATH];
|
---|
| 90 | CHAR key2[CCHMAXPATH];
|
---|
| 91 | HWND hwndDlg;
|
---|
| 92 | HWND hwndSource;
|
---|
| 93 | BOOL confirm;
|
---|
| 94 | }
|
---|
| 95 | INIREC;
|
---|
[2] | 96 |
|
---|
[914] | 97 | /**
|
---|
| 98 | * Close profile unless it is user or system INI
|
---|
| 99 | * @param hini is profile handle
|
---|
| 100 | * @param fSkipIfSystem bypasses close for system INIs
|
---|
| 101 | */
|
---|
| 102 |
|
---|
| 103 | static VOID CloseProfile(HINI hini, BOOL fSkipIfSystem)
|
---|
| 104 | {
|
---|
| 105 | BOOL ok = fSkipIfSystem &&
|
---|
| 106 | (hini == HINI_USERPROFILE || hini == HINI_SYSTEMPROFILE);
|
---|
| 107 |
|
---|
| 108 | if (!ok) {
|
---|
| 109 | ok = PrfCloseProfile(hini);
|
---|
| 110 | if (!ok) {
|
---|
| 111 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 112 | "PrfCloseProfile failed for handle 0x%x", hini);
|
---|
| 113 | }
|
---|
| 114 | }
|
---|
| 115 | }
|
---|
| 116 |
|
---|
[551] | 117 | VOID CopyIniThread(VOID * args)
|
---|
[336] | 118 | {
|
---|
[551] | 119 | INIREC *inirec = (INIREC *) args;
|
---|
| 120 | HAB hab2;
|
---|
| 121 | HMQ hmq2;
|
---|
[914] | 122 | HINI hiniFrom = NULLHANDLE;
|
---|
| 123 | HINI hiniTo = NULLHANDLE;
|
---|
[551] | 124 | PRFPROFILE cprfp;
|
---|
| 125 | CHAR userini[CCHMAXPATH], sysini[CCHMAXPATH];
|
---|
[2] | 126 |
|
---|
[551] | 127 | if (inirec) {
|
---|
[2] | 128 | hab2 = WinInitialize(0);
|
---|
[551] | 129 | if (hab2) {
|
---|
| 130 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
| 131 | if (hmq2) {
|
---|
| 132 | WinCancelShutdown(hmq2, TRUE);
|
---|
[533] | 133 | IncrThreadUsage();
|
---|
[551] | 134 | *userini = *sysini = 0;
|
---|
| 135 | memset(&cprfp, 0, sizeof(PRFPROFILE));
|
---|
| 136 | cprfp.cchUserName = CCHMAXPATH;
|
---|
| 137 | cprfp.cchSysName = CCHMAXPATH;
|
---|
| 138 | cprfp.pszUserName = (PSZ) userini;
|
---|
| 139 | cprfp.pszSysName = (PSZ) sysini;
|
---|
| 140 | if (PrfQueryProfile(hab2, &cprfp)) {
|
---|
| 141 | if (!stricmp(cprfp.pszUserName, inirec->filename1))
|
---|
[914] | 142 | hiniFrom = HINI_USERPROFILE;
|
---|
[551] | 143 | else if (!stricmp(cprfp.pszSysName, inirec->filename1))
|
---|
[914] | 144 | hiniFrom = HINI_SYSTEMPROFILE;
|
---|
[551] | 145 | if (!stricmp(cprfp.pszUserName, inirec->filename2))
|
---|
[914] | 146 | hiniTo = HINI_USERPROFILE;
|
---|
[551] | 147 | else if (!stricmp(cprfp.pszSysName, inirec->filename2))
|
---|
[914] | 148 | hiniTo = HINI_SYSTEMPROFILE;
|
---|
[551] | 149 | }
|
---|
[914] | 150 | if (hiniFrom == NULLHANDLE) {
|
---|
| 151 | hiniFrom = PrfOpenProfile(hab2, inirec->filename1);
|
---|
| 152 | if (hiniFrom == NULLHANDLE) {
|
---|
[912] | 153 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 154 | "PrfOpenProfile failed for %s", inirec->filename1);
|
---|
| 155 | }
|
---|
| 156 | }
|
---|
[914] | 157 | if (hiniTo == NULLHANDLE) {
|
---|
[551] | 158 | if (!stricmp(inirec->filename1, inirec->filename2))
|
---|
[914] | 159 | hiniTo = hiniFrom;
|
---|
[912] | 160 | else {
|
---|
[914] | 161 | hiniTo = PrfOpenProfile(hab2, inirec->filename2);
|
---|
| 162 | if (hiniTo == NULLHANDLE) {
|
---|
[912] | 163 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 164 | "PrfOpenProfile failed for %s", inirec->filename2);
|
---|
| 165 | }
|
---|
| 166 | }
|
---|
[551] | 167 | }
|
---|
[914] | 168 | if (hiniFrom && hiniTo && (*inirec->app2 || hiniFrom != hiniTo)) {
|
---|
[2] | 169 |
|
---|
[551] | 170 | PVOID pDataK, pData;
|
---|
| 171 | PBYTE pCurrentK;
|
---|
| 172 | ULONG ulSize = 0L;
|
---|
[2] | 173 |
|
---|
[551] | 174 | if (inirec->action == IDM_MOVE || inirec->action == IDM_COPY) {
|
---|
| 175 | if (!*inirec->key) {
|
---|
| 176 | if (inirec->confirm &&
|
---|
[914] | 177 | PrfQueryProfileSize(hiniFrom, (PSZ) ((*inirec->app2) ?
|
---|
[551] | 178 | inirec->app2 : inirec->
|
---|
| 179 | app), NULL,
|
---|
| 180 | (PULONG) & ulSize) && ulSize) {
|
---|
| 181 | if (saymsg
|
---|
| 182 | (MB_YESNOCANCEL, HWND_DESKTOP,
|
---|
| 183 | GetPString(IDS_CONFIRMTEXT),
|
---|
| 184 | GetPString(IDS_INIOVERAPPNAMETEXT),
|
---|
| 185 | ((*inirec->app2) ? inirec->app2 : inirec->app),
|
---|
| 186 | inirec->filename1) != MBID_YES)
|
---|
| 187 | goto Abort;
|
---|
| 188 | }
|
---|
[914] | 189 | if (PrfQueryProfileSize(hiniTo,
|
---|
[551] | 190 | (PSZ) inirec->app,
|
---|
| 191 | NULL, (PULONG) & ulSize) && ulSize) {
|
---|
| 192 | pDataK = xmalloc(ulSize, pszSrcFile, __LINE__); /* allocate space for keynames */
|
---|
| 193 | if (pDataK) {
|
---|
| 194 | /* get keynames */
|
---|
[914] | 195 | if (PrfQueryProfileString(hiniTo,
|
---|
[551] | 196 | (PSZ) inirec->app,
|
---|
| 197 | NULL, "\0", pDataK, ulSize)) {
|
---|
| 198 | pCurrentK = pDataK;
|
---|
| 199 | /* step through keynames */
|
---|
| 200 | while (*pCurrentK) {
|
---|
[914] | 201 | if (PrfQueryProfileSize(hiniTo, inirec->app,
|
---|
[551] | 202 | pCurrentK,
|
---|
| 203 | (PULONG) & ulSize) && ulSize) {
|
---|
| 204 | pData = xmalloc(ulSize, pszSrcFile, __LINE__);
|
---|
| 205 | if (pData) {
|
---|
| 206 | /* get data */
|
---|
[914] | 207 | if (PrfQueryProfileData(hiniTo, inirec->app,
|
---|
[551] | 208 | pCurrentK,
|
---|
| 209 | pData, (PULONG) & ulSize))
|
---|
| 210 | /* write data to new ini file */
|
---|
[914] | 211 | PrfWriteProfileData(hiniFrom, ((*inirec->app2) ?
|
---|
[551] | 212 | inirec->
|
---|
| 213 | app2 : inirec->app),
|
---|
| 214 | pCurrentK, pData, ulSize);
|
---|
[1009] | 215 | xfree(pData, pszSrcFile, __LINE__); /* free data */
|
---|
[551] | 216 | }
|
---|
| 217 | }
|
---|
| 218 | while (*pCurrentK) /* next keyname */
|
---|
| 219 | pCurrentK++;
|
---|
| 220 | pCurrentK++;
|
---|
| 221 | }
|
---|
| 222 | }
|
---|
[1009] | 223 | xfree(pDataK, pszSrcFile, __LINE__); /* free keynames */
|
---|
[551] | 224 | }
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
| 227 | else {
|
---|
| 228 | if (inirec->confirm &&
|
---|
[914] | 229 | PrfQueryProfileSize(hiniFrom, (PSZ) ((*inirec->app2) ?
|
---|
[551] | 230 | inirec->app2 : inirec->
|
---|
| 231 | app),
|
---|
| 232 | ((*inirec->key2) ? inirec->
|
---|
| 233 | key2 : inirec->key), (PULONG) & ulSize)
|
---|
| 234 | && ulSize) {
|
---|
| 235 | if (saymsg
|
---|
| 236 | (MB_YESNOCANCEL, HWND_DESKTOP,
|
---|
| 237 | GetPString(IDS_CONFIRMTEXT),
|
---|
| 238 | GetPString(IDS_INIOVERAPPKEYNAMETEXT),
|
---|
| 239 | ((*inirec->app2) ? inirec->app2 : inirec->app),
|
---|
| 240 | ((*inirec->key2) ? inirec->key2 : inirec->key),
|
---|
| 241 | inirec->filename1) != MBID_YES)
|
---|
| 242 | goto Abort;
|
---|
| 243 | }
|
---|
[914] | 244 | if (PrfQueryProfileSize(hiniTo, inirec->app,
|
---|
[551] | 245 | inirec->key,
|
---|
| 246 | (PULONG) & ulSize) && ulSize) {
|
---|
| 247 | pData = xmalloc(ulSize, pszSrcFile, __LINE__);
|
---|
| 248 | if (pData) {
|
---|
| 249 | /* get data */
|
---|
[914] | 250 | if (PrfQueryProfileData(hiniTo, inirec->app,
|
---|
[551] | 251 | inirec->key,
|
---|
| 252 | pData, (PULONG) & ulSize))
|
---|
| 253 | /* write data to new ini file */
|
---|
[914] | 254 | PrfWriteProfileData(hiniFrom, ((*inirec->app2) ?
|
---|
[551] | 255 | inirec->app2 : inirec->app),
|
---|
| 256 | ((*inirec->key2) ?
|
---|
| 257 | inirec->key2 : inirec->key),
|
---|
| 258 | pData, ulSize);
|
---|
[1009] | 259 | xfree(pData, pszSrcFile, __LINE__); /* free data */
|
---|
[551] | 260 | }
|
---|
| 261 | }
|
---|
| 262 | }
|
---|
| 263 | if (inirec->action == IDM_MOVE) {
|
---|
| 264 | if (inirec->confirm &&
|
---|
| 265 | saymsg(MB_YESNOCANCEL,
|
---|
| 266 | HWND_DESKTOP,
|
---|
| 267 | GetPString(IDS_CONFIRMTEXT),
|
---|
| 268 | GetPString(IDS_INIDELETEMOVEDTEXT),
|
---|
| 269 | inirec->filename2) != MBID_YES)
|
---|
| 270 | goto Abort;
|
---|
[914] | 271 | PrfWriteProfileData(hiniTo,
|
---|
[551] | 272 | inirec->app,
|
---|
| 273 | ((*inirec->key) ? inirec->key : NULL),
|
---|
| 274 | NULL, 0L);
|
---|
| 275 | }
|
---|
| 276 | }
|
---|
| 277 | }
|
---|
| 278 | Abort:
|
---|
[914] | 279 | if (hiniFrom)
|
---|
| 280 | CloseProfile(hiniFrom, TRUE);
|
---|
| 281 | if (hiniTo && hiniTo != hiniFrom)
|
---|
| 282 | CloseProfile(hiniTo, FALSE);
|
---|
[551] | 283 | WinDestroyMsgQueue(hmq2);
|
---|
[2] | 284 | }
|
---|
[533] | 285 | DecrThreadUsage();
|
---|
[2] | 286 | WinTerminate(hab2);
|
---|
| 287 | }
|
---|
[551] | 288 | PostMsg(inirec->hwndDlg, WM_COMMAND, MPFROM2SHORT(INI_REFRESH, 0),
|
---|
| 289 | MPVOID);
|
---|
| 290 | if (inirec->action == IDM_MOVE && inirec->hwndSource &&
|
---|
| 291 | inirec->hwndSource != inirec->hwndDlg)
|
---|
| 292 | PostMsg(inirec->hwndSource, WM_COMMAND, MPFROM2SHORT(INI_REFRESH, 0),
|
---|
| 293 | MPVOID);
|
---|
[1009] | 294 | xfree(inirec, pszSrcFile, __LINE__);
|
---|
[2] | 295 | }
|
---|
| 296 | }
|
---|
| 297 |
|
---|
[551] | 298 | static VOID CompareIniThread(VOID * args)
|
---|
[336] | 299 | {
|
---|
[551] | 300 | INIREC *inirec = (INIREC *) args;
|
---|
| 301 | HAB hab2;
|
---|
| 302 | HMQ hmq2;
|
---|
[2] | 303 |
|
---|
[551] | 304 | if (inirec) {
|
---|
[2] | 305 | hab2 = WinInitialize(0);
|
---|
[551] | 306 | if (hab2) {
|
---|
| 307 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
| 308 | if (hmq2) {
|
---|
| 309 | WinCancelShutdown(hmq2, TRUE);
|
---|
[533] | 310 | IncrThreadUsage();
|
---|
[2] | 311 |
|
---|
[533] | 312 | // fixme to do something?
|
---|
| 313 |
|
---|
[551] | 314 | WinDestroyMsgQueue(hmq2);
|
---|
[2] | 315 | }
|
---|
[533] | 316 | DecrThreadUsage();
|
---|
[2] | 317 | WinTerminate(hab2);
|
---|
| 318 | }
|
---|
[1009] | 319 | xfree(inirec, pszSrcFile, __LINE__);
|
---|
[2] | 320 | }
|
---|
| 321 | }
|
---|
| 322 |
|
---|
[551] | 323 | static VOID BackupIniThread(VOID * args)
|
---|
[336] | 324 | {
|
---|
[914] | 325 | PPRFPROFILE prfp = (PPRFPROFILE)args;
|
---|
[551] | 326 | HAB hab2;
|
---|
| 327 | HMQ hmq2;
|
---|
[912] | 328 | HINI orig = NULLHANDLE;
|
---|
| 329 | HINI new;
|
---|
[551] | 330 | PVOID pDataA, pDataK, pData;
|
---|
| 331 | PBYTE pCurrentA, pCurrentK;
|
---|
[914] | 332 | ULONG ulSize;
|
---|
[551] | 333 | PRFPROFILE cprfp;
|
---|
| 334 | CHAR userini[CCHMAXPATH], sysini[CCHMAXPATH];
|
---|
[2] | 335 |
|
---|
[551] | 336 | if (prfp) {
|
---|
[2] | 337 | hab2 = WinInitialize(0);
|
---|
[551] | 338 | if (hab2) {
|
---|
| 339 | hmq2 = WinCreateMsgQueue(hab2, 0);
|
---|
| 340 | if (hmq2) {
|
---|
| 341 | WinCancelShutdown(hmq2, TRUE);
|
---|
[533] | 342 | IncrThreadUsage();
|
---|
[551] | 343 | *userini = *sysini = 0;
|
---|
| 344 | memset(&cprfp, 0, sizeof(PRFPROFILE));
|
---|
| 345 | cprfp.cchUserName = CCHMAXPATH;
|
---|
| 346 | cprfp.cchSysName = CCHMAXPATH;
|
---|
| 347 | cprfp.pszUserName = (PSZ) userini;
|
---|
| 348 | cprfp.pszSysName = (PSZ) sysini;
|
---|
| 349 | if (PrfQueryProfile(hab2, &cprfp)) {
|
---|
| 350 | if (!stricmp(cprfp.pszUserName, prfp->pszUserName))
|
---|
| 351 | orig = HINI_USERPROFILE;
|
---|
| 352 | else if (!stricmp(cprfp.pszSysName, prfp->pszUserName))
|
---|
| 353 | orig = HINI_SYSTEMPROFILE;
|
---|
| 354 | }
|
---|
[912] | 355 | if (orig == NULLHANDLE)
|
---|
[551] | 356 | orig = PrfOpenProfile(hab2, prfp->pszUserName);
|
---|
[912] | 357 | if (orig == NULLHANDLE) {
|
---|
| 358 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 359 | "PrfOpenProfile failed for %s", prfp->pszUserName);
|
---|
| 360 | }
|
---|
| 361 | else {
|
---|
[551] | 362 | new = PrfOpenProfile(hab2, prfp->pszSysName);
|
---|
[912] | 363 | if (new == NULLHANDLE) {
|
---|
| 364 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 365 | "PrfOpenProfile failed for %s", prfp->pszSysName);
|
---|
| 366 | }
|
---|
| 367 | else {
|
---|
[914] | 368 | ulSize = 0;
|
---|
[551] | 369 | if (PrfQueryProfileSize(orig, NULL, NULL, (PULONG) & ulSize)
|
---|
| 370 | && ulSize) {
|
---|
| 371 | pDataA = xmalloc(ulSize, pszSrcFile, __LINE__); /* allocate space for applnames */
|
---|
| 372 | if (pDataA) {
|
---|
| 373 | /* get applnames */
|
---|
| 374 | if (PrfQueryProfileString
|
---|
| 375 | (orig, NULL, NULL, "\0", pDataA, ulSize)) {
|
---|
| 376 | pCurrentA = pDataA;
|
---|
| 377 | /* step through applnames */
|
---|
| 378 | while (*pCurrentA) {
|
---|
| 379 | /* now keynames for this applname */
|
---|
| 380 | if (PrfQueryProfileSize(orig, (PSZ) pCurrentA, NULL,
|
---|
| 381 | (PULONG) & ulSize) && ulSize) {
|
---|
| 382 | pDataK = xmalloc(ulSize, pszSrcFile, __LINE__); /* allocate space for keynames */
|
---|
| 383 | if (pDataK) {
|
---|
| 384 | /* get keynames */
|
---|
| 385 | if (PrfQueryProfileString(orig, (PSZ) pCurrentA, NULL,
|
---|
| 386 | "\0", pDataK, ulSize)) {
|
---|
| 387 | pCurrentK = pDataK;
|
---|
| 388 | /* step through keynames */
|
---|
| 389 | while (*pCurrentK) {
|
---|
| 390 | if (PrfQueryProfileSize(orig, pCurrentA,
|
---|
| 391 | pCurrentK,
|
---|
| 392 | (PULONG) & ulSize) &&
|
---|
| 393 | ulSize) {
|
---|
| 394 | pData = xmalloc(ulSize, pszSrcFile, __LINE__);
|
---|
| 395 | if (pData) {
|
---|
| 396 | /* get data */
|
---|
| 397 | if (PrfQueryProfileData(orig, pCurrentA,
|
---|
| 398 | pCurrentK,
|
---|
| 399 | pData,
|
---|
| 400 | (PULONG) & ulSize))
|
---|
| 401 | /* write data to new ini file */
|
---|
| 402 | PrfWriteProfileData(new, pCurrentA,
|
---|
| 403 | pCurrentK, pData,
|
---|
| 404 | ulSize);
|
---|
[1009] | 405 | xfree(pData, pszSrcFile, __LINE__); /* free data */
|
---|
[551] | 406 | }
|
---|
| 407 | }
|
---|
| 408 | while (*pCurrentK) /* next keyname */
|
---|
| 409 | pCurrentK++;
|
---|
| 410 | pCurrentK++;
|
---|
| 411 | }
|
---|
| 412 | }
|
---|
[1009] | 413 | xfree(pDataK, pszSrcFile, __LINE__); /* free keynames */
|
---|
[551] | 414 | }
|
---|
| 415 | }
|
---|
| 416 | while (*pCurrentA) /* next applname */
|
---|
| 417 | pCurrentA++;
|
---|
| 418 | pCurrentA++;
|
---|
| 419 | }
|
---|
| 420 | }
|
---|
[1009] | 421 | xfree(pDataA, pszSrcFile, __LINE__); /* free applnames */
|
---|
[551] | 422 | }
|
---|
| 423 | }
|
---|
[914] | 424 | CloseProfile(new, FALSE);
|
---|
[551] | 425 | }
|
---|
[914] | 426 | CloseProfile(orig, TRUE);
|
---|
[551] | 427 | }
|
---|
| 428 | WinDestroyMsgQueue(hmq2);
|
---|
[2] | 429 | }
|
---|
[533] | 430 | DecrThreadUsage();
|
---|
[2] | 431 | WinTerminate(hab2);
|
---|
| 432 | }
|
---|
[1009] | 433 | xfree(prfp->pszUserName, pszSrcFile, __LINE__);
|
---|
| 434 | xfree(prfp->pszSysName, pszSrcFile, __LINE__);
|
---|
| 435 | xfree(prfp, pszSrcFile, __LINE__);
|
---|
[2] | 436 | }
|
---|
| 437 | }
|
---|
| 438 |
|
---|
[551] | 439 | static VOID EnumAppNames(HWND hwndList, HINI hini)
|
---|
[336] | 440 | {
|
---|
[2] | 441 | PVOID pData;
|
---|
| 442 | PBYTE pCurrent;
|
---|
[914] | 443 | ULONG ulSize = 0;
|
---|
[2] | 444 |
|
---|
[551] | 445 | WinSendMsg(hwndList, LM_DELETEALL, NULL, NULL);
|
---|
| 446 | if (!PrfQueryProfileSize(hini, NULL, NULL, (PULONG) & ulSize))
|
---|
| 447 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 448 | "PrfQueryProfileSize");
|
---|
[336] | 449 | else if (!ulSize)
|
---|
[377] | 450 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[336] | 451 | else {
|
---|
[551] | 452 | pData = xmalloc(ulSize, pszSrcFile, __LINE__);
|
---|
[336] | 453 | if (pData) {
|
---|
[551] | 454 | if (PrfQueryProfileString(hini, NULL, NULL, "\0", pData, ulSize)) {
|
---|
| 455 | pCurrent = pData;
|
---|
| 456 | WinEnableWindowUpdate(hwndList, FALSE);
|
---|
| 457 | while (*pCurrent) {
|
---|
| 458 | WinSendMsg(hwndList, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),
|
---|
| 459 | MPFROMP(pCurrent));
|
---|
| 460 | while (*pCurrent)
|
---|
| 461 | pCurrent++;
|
---|
| 462 | pCurrent++;
|
---|
| 463 | }
|
---|
| 464 | WinSendMsg(hwndList, LM_SELECTITEM, MPFROMSHORT(0),
|
---|
| 465 | MPFROMSHORT(TRUE));
|
---|
| 466 | WinEnableWindowUpdate(hwndList, TRUE);
|
---|
[2] | 467 | }
|
---|
[1009] | 468 | xfree(pData, pszSrcFile, __LINE__);
|
---|
[2] | 469 | }
|
---|
| 470 | }
|
---|
| 471 | }
|
---|
| 472 |
|
---|
[551] | 473 | static CHAR *GetKeyData(HWND hwndList, HINI hini, PSZ pAppName,
|
---|
| 474 | PSZ pKeyName, PULONG datalen)
|
---|
[336] | 475 | {
|
---|
[2] | 476 | ULONG ulKeySize = 0L;
|
---|
| 477 | PVOID pKeyData = NULL;
|
---|
| 478 |
|
---|
| 479 | *datalen = 0L;
|
---|
[551] | 480 | if (!PrfQueryProfileSize(hini, pAppName, pKeyName, (PULONG) & ulKeySize))
|
---|
| 481 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 482 | "PrfQueryProfileSize");
|
---|
[336] | 483 | else {
|
---|
[551] | 484 | pKeyData = xmalloc(ulKeySize + 1L, pszSrcFile, __LINE__);
|
---|
[336] | 485 | if (pKeyData) {
|
---|
[551] | 486 | if (!PrfQueryProfileData
|
---|
| 487 | (hini, pAppName, pKeyName, pKeyData, (PULONG) & ulKeySize))
|
---|
| 488 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 489 | "PrfQueryProfileData");
|
---|
[336] | 490 | else {
|
---|
[551] | 491 | HexDump(hwndList, pKeyData, ulKeySize);
|
---|
| 492 | {
|
---|
| 493 | CHAR s[81];
|
---|
[2] | 494 |
|
---|
[551] | 495 | sprintf(s,
|
---|
| 496 | GetPString(IDS_INIBYTESTEXT),
|
---|
| 497 | ulKeySize, &"s"[ulKeySize == 1]);
|
---|
| 498 | WinSetDlgItemText(WinQueryWindow(hwndList, QW_PARENT),
|
---|
| 499 | INI_NUMDATA, s);
|
---|
| 500 | }
|
---|
| 501 | *datalen = ulKeySize;
|
---|
[1009] | 502 | return (CHAR *)pKeyData;
|
---|
[2] | 503 | }
|
---|
| 504 | }
|
---|
| 505 | }
|
---|
| 506 | return NULL;
|
---|
| 507 | }
|
---|
| 508 |
|
---|
[551] | 509 | static BOOL EnumKeyNames(HWND hwndList, HINI hini, PSZ pAppName)
|
---|
[336] | 510 | {
|
---|
[2] | 511 | PVOID pData;
|
---|
| 512 | PBYTE pCurrent;
|
---|
[914] | 513 | ULONG ulSize = 0;
|
---|
[2] | 514 |
|
---|
[551] | 515 | WinSendMsg(hwndList, LM_DELETEALL, NULL, NULL);
|
---|
| 516 | if (!PrfQueryProfileSize(hini, pAppName, NULL, (PULONG) & ulSize))
|
---|
| 517 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 518 | "PrfQueryProfileSize");
|
---|
[336] | 519 | else {
|
---|
| 520 | if (!ulSize)
|
---|
[377] | 521 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[551] | 522 | pData = xmalloc(ulSize + 1L, pszSrcFile, __LINE__);
|
---|
[336] | 523 | if (pData) {
|
---|
[551] | 524 | if (!PrfQueryProfileString(hini, pAppName, NULL, "\0", pData, ulSize)) {
|
---|
| 525 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 526 | "PrfQueryProfileString");
|
---|
[1009] | 527 | xfree(pData, pszSrcFile, __LINE__);
|
---|
[336] | 528 | }
|
---|
| 529 | else {
|
---|
[551] | 530 | pCurrent = pData;
|
---|
| 531 | WinEnableWindowUpdate(hwndList, FALSE);
|
---|
| 532 | while (*pCurrent) {
|
---|
| 533 | WinSendMsg(hwndList, LM_INSERTITEM, MPFROMSHORT(LIT_SORTASCENDING),
|
---|
| 534 | MPFROMP(pCurrent));
|
---|
| 535 | while (*pCurrent)
|
---|
| 536 | pCurrent++;
|
---|
| 537 | pCurrent++;
|
---|
| 538 | }
|
---|
| 539 | WinSendMsg(hwndList, LM_SELECTITEM, MPFROMSHORT(0),
|
---|
| 540 | MPFROMSHORT(TRUE));
|
---|
[1014] | 541 | WinEnableWindowUpdate(hwndList, TRUE);
|
---|
| 542 | xfree(pData, pszSrcFile, __LINE__);
|
---|
[551] | 543 | return TRUE;
|
---|
[2] | 544 | }
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
| 547 | return FALSE;
|
---|
| 548 | }
|
---|
| 549 |
|
---|
| 550 | #define hwndMLE WinWindowFromID(hwnd,IAF_MLE)
|
---|
| 551 |
|
---|
[551] | 552 | MRESULT EXPENTRY FilterIniProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 553 | {
|
---|
[551] | 554 | INIDATA *inidata;
|
---|
[2] | 555 | static CHAR lasttext[8192] = "";
|
---|
| 556 |
|
---|
[551] | 557 | switch (msg) {
|
---|
| 558 | case WM_INITDLG:
|
---|
[574] | 559 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 560 | inidata = (INIDATA *) mp2;
|
---|
| 561 | WinSendDlgItemMsg(hwnd, IAF_SAVENAME, EM_SETTEXTLIMIT,
|
---|
| 562 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 563 | MLEsetformat(hwndMLE, MLFIE_NOTRANS);
|
---|
| 564 | MLEsetlimit(hwndMLE, 8192);
|
---|
| 565 | WinSetWindowText(hwndMLE, lasttext);
|
---|
| 566 | {
|
---|
[847] | 567 | FILEFINDBUF3 ffb;
|
---|
[551] | 568 | ULONG nm;
|
---|
| 569 | HDIR hdir;
|
---|
[2] | 570 |
|
---|
[551] | 571 | hdir = HDIR_CREATE;
|
---|
[761] | 572 | nm = 1;
|
---|
[551] | 573 | DosError(FERR_DISABLEHARDERR);
|
---|
[843] | 574 | if (!DosFindFirst("*.IST",
|
---|
| 575 | &hdir,
|
---|
| 576 | FILE_NORMAL | FILE_ARCHIVED,
|
---|
| 577 | &ffb, sizeof(ffb), &nm, FIL_STANDARD)) {
|
---|
[551] | 578 | do {
|
---|
| 579 | priority_bumped();
|
---|
| 580 | WinSendDlgItemMsg(hwnd, IAF_LISTBOX, LM_INSERTITEM,
|
---|
| 581 | MPFROMSHORT(LIT_SORTASCENDING),
|
---|
| 582 | MPFROMP(ffb.achName));
|
---|
[761] | 583 | nm = 1;
|
---|
[843] | 584 | } while (!DosFindNext(hdir, &ffb, sizeof(ffb), &nm));
|
---|
[551] | 585 | DosFindClose(hdir);
|
---|
| 586 | priority_bumped();
|
---|
[2] | 587 | }
|
---|
[551] | 588 | }
|
---|
| 589 | break;
|
---|
[2] | 590 |
|
---|
[551] | 591 | case WM_ADJUSTWINDOWPOS:
|
---|
| 592 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 593 | break;
|
---|
[2] | 594 |
|
---|
[551] | 595 | case UM_SETDIR:
|
---|
| 596 | PaintRecessedWindow(WinWindowFromID(hwnd, IAF_HELP), (HPS) 0, FALSE,
|
---|
| 597 | TRUE);
|
---|
| 598 | PaintRecessedWindow(WinWindowFromID(hwnd, IAF_SAVENAME), (HPS) 0, FALSE,
|
---|
| 599 | FALSE);
|
---|
| 600 | PaintRecessedWindow(WinWindowFromID(hwnd, IAF_LISTBOX), (HPS) 0, FALSE,
|
---|
| 601 | FALSE);
|
---|
| 602 | PaintRecessedWindow(WinWindowFromID(hwnd, IAF_MLE), (HPS) 0, FALSE,
|
---|
| 603 | FALSE);
|
---|
| 604 | return 0;
|
---|
[2] | 605 |
|
---|
[551] | 606 | case WM_CONTROL:
|
---|
| 607 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 608 | case IAF_SAVENAME:
|
---|
| 609 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
| 610 | WinSetDlgItemText(hwnd, IAF_HELP, NullStr);
|
---|
| 611 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
| 612 | WinSetDlgItemText(hwnd,
|
---|
| 613 | IAF_HELP, GetPString(IDS_MASKLISTNAMEHELPTEXT));
|
---|
| 614 | break;
|
---|
[2] | 615 |
|
---|
[551] | 616 | case IAF_LISTBOX:
|
---|
| 617 | if (SHORT2FROMMP(mp1) == LN_KILLFOCUS)
|
---|
| 618 | WinSetDlgItemText(hwnd, IAF_HELP, NullStr);
|
---|
| 619 | if (SHORT2FROMMP(mp1) == LN_SETFOCUS)
|
---|
| 620 | WinSetDlgItemText(hwnd,
|
---|
| 621 | IAF_HELP, GetPString(IDS_MASKLISTFILESHELPTEXT));
|
---|
| 622 | else if (SHORT2FROMMP(mp1) == LN_ENTER)
|
---|
| 623 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(IAF_LOAD, 0), MPVOID);
|
---|
| 624 | break;
|
---|
[2] | 625 |
|
---|
[551] | 626 | case IAF_MLE:
|
---|
| 627 | if (SHORT2FROMMP(mp1) == MLN_KILLFOCUS)
|
---|
| 628 | WinSetDlgItemText(hwnd, IAF_HELP, NullStr);
|
---|
| 629 | if (SHORT2FROMMP(mp1) == MLN_SETFOCUS)
|
---|
| 630 | WinSetDlgItemText(hwnd,
|
---|
| 631 | IAF_HELP, GetPString(IDS_MASKLISTMASKSHELPTEXT));
|
---|
| 632 | break;
|
---|
| 633 | }
|
---|
| 634 | return 0;
|
---|
[2] | 635 |
|
---|
[551] | 636 | case WM_COMMAND:
|
---|
| 637 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 638 | case DID_OK:
|
---|
| 639 | inidata = INSTDATA(hwnd);
|
---|
[914] | 640 | if (!inidata)
|
---|
| 641 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 642 | else {
|
---|
[551] | 643 | CHAR s[8193], app[1024];
|
---|
| 644 | register CHAR *p;
|
---|
| 645 | SHORT sSelect, numitems;
|
---|
| 646 | BOOL match;
|
---|
[2] | 647 |
|
---|
[551] | 648 | *s = 0;
|
---|
| 649 | WinQueryWindowText(hwndMLE, 8192, s);
|
---|
| 650 | if (!*s) {
|
---|
| 651 | DosBeep(250, 100);
|
---|
| 652 | break;
|
---|
| 653 | }
|
---|
| 654 | else {
|
---|
| 655 | strcpy(lasttext, s);
|
---|
| 656 | p = s;
|
---|
| 657 | while (*p) {
|
---|
| 658 | if (*p == '\r') {
|
---|
| 659 | memmove(p, p + 1, strlen(p));
|
---|
| 660 | continue;
|
---|
[336] | 661 | }
|
---|
[551] | 662 | if (*p == '\n')
|
---|
| 663 | *p = 0;
|
---|
| 664 | p++;
|
---|
| 665 | }
|
---|
| 666 | p++;
|
---|
| 667 | *p = 0;
|
---|
| 668 | }
|
---|
| 669 | numitems = (SHORT) WinSendMsg(inidata->hwndApp,
|
---|
| 670 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
| 671 | if (!numitems) {
|
---|
| 672 | DosBeep(250, 100);
|
---|
| 673 | break;
|
---|
| 674 | }
|
---|
| 675 | else {
|
---|
| 676 | WinSetPointer(HWND_DESKTOP, hptrBusy);
|
---|
| 677 | WinSetDlgItemText(hwnd, IAF_HELP, GetPString(IDS_FILTERINGTEXT));
|
---|
| 678 | sSelect = 0;
|
---|
| 679 | while (numitems) {
|
---|
| 680 | *app = 0;
|
---|
| 681 | WinSendMsg(inidata->hwndApp,
|
---|
| 682 | LM_QUERYITEMTEXT,
|
---|
| 683 | MPFROM2SHORT(sSelect, 1024), MPFROMP(app));
|
---|
| 684 | match = FALSE;
|
---|
| 685 | if (*app) {
|
---|
| 686 | p = s;
|
---|
| 687 | while (*p) {
|
---|
| 688 | if (*p != '/') {
|
---|
| 689 | if (wildcard(app, p, TRUE))
|
---|
| 690 | match = TRUE;
|
---|
| 691 | }
|
---|
| 692 | else if (wildcard(app, p + 1, TRUE)) {
|
---|
| 693 | match = FALSE;
|
---|
| 694 | break;
|
---|
| 695 | }
|
---|
| 696 | while (*p)
|
---|
| 697 | p++;
|
---|
| 698 | p++;
|
---|
| 699 | }
|
---|
[336] | 700 | }
|
---|
[551] | 701 | if (!match)
|
---|
| 702 | WinSendMsg(inidata->hwndApp, LM_DELETEITEM,
|
---|
| 703 | MPFROMSHORT(sSelect), MPVOID);
|
---|
| 704 | else
|
---|
| 705 | sSelect++;
|
---|
| 706 | numitems--;
|
---|
| 707 | }
|
---|
| 708 | WinSetPointer(HWND_DESKTOP, hptrArrow);
|
---|
| 709 | }
|
---|
| 710 | }
|
---|
| 711 | WinDismissDlg(hwnd, 1);
|
---|
| 712 | break;
|
---|
[2] | 713 |
|
---|
[551] | 714 | case IAF_LOAD:
|
---|
| 715 | {
|
---|
| 716 | CHAR s[8193];
|
---|
| 717 | FILE *fp;
|
---|
| 718 | INT len;
|
---|
| 719 | SHORT sSelect;
|
---|
[2] | 720 |
|
---|
[551] | 721 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, IAF_LISTBOX,
|
---|
| 722 | LM_QUERYSELECTION,
|
---|
| 723 | MPFROM2SHORT(LIT_FIRST, 0),
|
---|
| 724 | MPVOID);
|
---|
| 725 | if (sSelect < 0)
|
---|
| 726 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 727 | else {
|
---|
| 728 | *s = 0;
|
---|
| 729 | WinSendDlgItemMsg(hwnd, IAF_LISTBOX, LM_QUERYITEMTEXT,
|
---|
| 730 | MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s));
|
---|
| 731 | bstrip(s);
|
---|
| 732 | if (*s) {
|
---|
| 733 | fp = _fsopen(s, "r", SH_DENYWR);
|
---|
| 734 | if (fp) {
|
---|
| 735 | len = fread(s, 1, 8192, fp);
|
---|
| 736 | s[len] = 0;
|
---|
| 737 | WinSetWindowText(hwndMLE, s);
|
---|
| 738 | fclose(fp);
|
---|
| 739 | }
|
---|
| 740 | }
|
---|
| 741 | }
|
---|
| 742 | }
|
---|
| 743 | break;
|
---|
[2] | 744 |
|
---|
[551] | 745 | case IAF_SAVE:
|
---|
| 746 | {
|
---|
| 747 | CHAR s[8193], filename[CCHMAXPATH], *p;
|
---|
| 748 | FILE *fp;
|
---|
[2] | 749 |
|
---|
[551] | 750 | *filename = 0;
|
---|
| 751 | WinQueryDlgItemText(hwnd, IAF_SAVENAME, CCHMAXPATH, filename);
|
---|
| 752 | bstrip(filename);
|
---|
| 753 | if (*filename) {
|
---|
| 754 | p = strchr(filename, '.');
|
---|
| 755 | if (p) {
|
---|
| 756 | strcpy(p, ".IST");
|
---|
| 757 | WinSetDlgItemText(hwnd, IAF_SAVENAME, filename);
|
---|
| 758 | }
|
---|
| 759 | *s = 0;
|
---|
| 760 | WinQueryWindowText(hwndMLE, 8192, s);
|
---|
| 761 | if (!*s)
|
---|
| 762 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 763 | else {
|
---|
| 764 | fp = xfopen(filename, "w", pszSrcFile, __LINE__);
|
---|
| 765 | if (fp) {
|
---|
| 766 | fwrite(s, 1, strlen(s), fp);
|
---|
| 767 | fclose(fp);
|
---|
| 768 | WinSendDlgItemMsg(hwnd,
|
---|
| 769 | IAF_LISTBOX,
|
---|
| 770 | LM_INSERTITEM,
|
---|
| 771 | MPFROMSHORT(LIT_SORTASCENDING),
|
---|
| 772 | MPFROMP(filename));
|
---|
| 773 | }
|
---|
| 774 | }
|
---|
| 775 | }
|
---|
| 776 | }
|
---|
| 777 | break;
|
---|
[2] | 778 |
|
---|
[551] | 779 | case IAF_DELETE:
|
---|
| 780 | {
|
---|
| 781 | CHAR s[CCHMAXPATH];
|
---|
| 782 | SHORT sSelect;
|
---|
[2] | 783 |
|
---|
[551] | 784 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, IAF_LISTBOX,
|
---|
| 785 | LM_QUERYSELECTION,
|
---|
| 786 | MPFROM2SHORT(LIT_FIRST, 0),
|
---|
| 787 | MPVOID);
|
---|
| 788 | if (sSelect >= 0) {
|
---|
| 789 | *s = 0;
|
---|
| 790 | WinSendDlgItemMsg(hwnd, IAF_LISTBOX, LM_QUERYITEMTEXT,
|
---|
| 791 | MPFROM2SHORT(sSelect, CCHMAXPATH), MPFROMP(s));
|
---|
| 792 | bstrip(s);
|
---|
| 793 | if (*s) {
|
---|
| 794 | unlinkf(s);
|
---|
| 795 | WinSendDlgItemMsg(hwnd, IAF_LISTBOX, LM_DELETEITEM,
|
---|
| 796 | MPFROMSHORT(sSelect), MPVOID);
|
---|
| 797 | }
|
---|
| 798 | }
|
---|
| 799 | }
|
---|
| 800 | break;
|
---|
[2] | 801 |
|
---|
[551] | 802 | case DID_CANCEL:
|
---|
| 803 | WinDismissDlg(hwnd, 0);
|
---|
| 804 | break;
|
---|
[2] | 805 |
|
---|
[551] | 806 | case IDM_HELP:
|
---|
| 807 | if (hwndHelp)
|
---|
| 808 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 809 | MPFROM2SHORT(HELP_FILTERINI, 0),
|
---|
| 810 | MPFROMSHORT(HM_RESOURCEID));
|
---|
| 811 | break;
|
---|
| 812 | }
|
---|
| 813 | return 0;
|
---|
[2] | 814 | }
|
---|
[551] | 815 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 816 | }
|
---|
| 817 |
|
---|
[551] | 818 | MRESULT EXPENTRY IntraIniProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 819 | {
|
---|
[2] | 820 | INIREC *inirec;
|
---|
| 821 |
|
---|
[551] | 822 | switch (msg) {
|
---|
| 823 | case WM_INITDLG:
|
---|
[574] | 824 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 825 | inirec = (INIREC *) mp2;
|
---|
| 826 | WinSendDlgItemMsg(hwnd,
|
---|
| 827 | INII_NEWAPP,
|
---|
| 828 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 829 | WinSendDlgItemMsg(hwnd,
|
---|
| 830 | INII_NEWKEY,
|
---|
| 831 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 832 | {
|
---|
| 833 | CHAR s[CCHMAXPATH + 34];
|
---|
| 834 |
|
---|
| 835 | sprintf(s, GetPString(IDS_INIWASTEXT), inirec->app);
|
---|
| 836 | WinSetDlgItemText(hwnd, INII_OLDAPP, s);
|
---|
| 837 | }
|
---|
| 838 | if (!*inirec->key) {
|
---|
| 839 | WinEnableWindow(WinWindowFromID(hwnd, INII_NEWKEY), FALSE);
|
---|
| 840 | WinEnableWindow(WinWindowFromID(hwnd, INII_NEWKEYHDR), FALSE);
|
---|
| 841 | switch (inirec->action) {
|
---|
| 842 | case IDM_MOVE:
|
---|
| 843 | WinSetWindowText(hwnd, GetPString(IDS_INIRENAMEAPPTITLETEXT));
|
---|
| 844 | break;
|
---|
| 845 | case IDM_COPY:
|
---|
| 846 | WinSetWindowText(hwnd, GetPString(IDS_INICOPYAPPTITLETEXT));
|
---|
| 847 | break;
|
---|
| 848 | }
|
---|
| 849 | }
|
---|
| 850 | else {
|
---|
[2] | 851 | {
|
---|
[551] | 852 | CHAR s[CCHMAXPATH + 34];
|
---|
[2] | 853 |
|
---|
[551] | 854 | sprintf(s, GetPString(IDS_INIWASTEXT), inirec->key);
|
---|
| 855 | WinSetDlgItemText(hwnd, INII_OLDKEY, s);
|
---|
[2] | 856 | }
|
---|
[551] | 857 | WinSetDlgItemText(hwnd, INII_NEWAPP, inirec->app);
|
---|
| 858 | WinSendDlgItemMsg(hwnd,
|
---|
| 859 | INII_NEWAPP,
|
---|
| 860 | EM_SETSEL, MPFROM2SHORT(0, CCHMAXPATH), MPVOID);
|
---|
| 861 | switch (inirec->action) {
|
---|
| 862 | case IDM_MOVE:
|
---|
| 863 | WinSetWindowText(hwnd, GetPString(IDS_INIRENAMEKEYTITLETEXT));
|
---|
| 864 | break;
|
---|
| 865 | case IDM_COPY:
|
---|
| 866 | WinSetWindowText(hwnd, GetPString(IDS_INICOPYKEYTITLETEXT));
|
---|
| 867 | break;
|
---|
[2] | 868 | }
|
---|
[551] | 869 | }
|
---|
| 870 | break;
|
---|
[2] | 871 |
|
---|
[551] | 872 | case WM_COMMAND:
|
---|
| 873 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 874 | case DID_OK:
|
---|
[574] | 875 | inirec = (INIREC *) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 876 | if (inirec) {
|
---|
| 877 | WinQueryDlgItemText(hwnd, INII_NEWAPP, CCHMAXPATH, inirec->app2);
|
---|
| 878 | bstrip(inirec->app2);
|
---|
| 879 | if (!*inirec->app2) {
|
---|
| 880 | DosBeep(50, 100);
|
---|
| 881 | break;
|
---|
| 882 | }
|
---|
| 883 | if (*inirec->key) {
|
---|
| 884 | WinQueryDlgItemText(hwnd, INII_NEWKEY, CCHMAXPATH, inirec->key2);
|
---|
| 885 | bstrip(inirec->key2);
|
---|
| 886 | if (!*inirec->key2) {
|
---|
| 887 | DosBeep(50, 100);
|
---|
| 888 | break;
|
---|
| 889 | }
|
---|
| 890 | }
|
---|
| 891 | WinDismissDlg(hwnd, 1);
|
---|
[2] | 892 | }
|
---|
| 893 | break;
|
---|
| 894 |
|
---|
[551] | 895 | case DID_CANCEL:
|
---|
| 896 | WinDismissDlg(hwnd, 0);
|
---|
| 897 | break;
|
---|
[2] | 898 |
|
---|
[551] | 899 | case IDM_HELP:
|
---|
| 900 | if (hwndHelp)
|
---|
| 901 | WinSendMsg(hwndHelp,
|
---|
| 902 | HM_DISPLAY_HELP,
|
---|
| 903 | MPFROM2SHORT(HELP_INTRAINI, 0),
|
---|
| 904 | MPFROMSHORT(HM_RESOURCEID));
|
---|
| 905 | break;
|
---|
| 906 | }
|
---|
| 907 | return 0;
|
---|
[2] | 908 | }
|
---|
[551] | 909 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 910 | }
|
---|
| 911 |
|
---|
[551] | 912 | MRESULT EXPENTRY ChangeIniProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 913 | {
|
---|
[551] | 914 | switch (msg) {
|
---|
| 915 | case WM_INITDLG:
|
---|
[574] | 916 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 917 | WinSendDlgItemMsg(hwnd, INIR_USERPROFILE, EM_SETTEXTLIMIT,
|
---|
| 918 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 919 | WinSendDlgItemMsg(hwnd, INIR_SYSTEMPROFILE, EM_SETTEXTLIMIT,
|
---|
| 920 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 921 | break;
|
---|
[2] | 922 |
|
---|
[551] | 923 | case WM_COMMAND:
|
---|
| 924 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 925 | case INIR_FIND:
|
---|
| 926 | {
|
---|
| 927 | CHAR filename[CCHMAXPATH], *p, *ininame;
|
---|
| 928 | USHORT id = 0;
|
---|
| 929 | HWND hwndFocus;
|
---|
[2] | 930 |
|
---|
[551] | 931 | hwndFocus = WinQueryFocus(HWND_DESKTOP);
|
---|
| 932 | if (hwndFocus)
|
---|
| 933 | id = WinQueryWindowUShort(hwndFocus, QWS_ID);
|
---|
| 934 | if (id != INIR_SYSTEMPROFILE)
|
---|
| 935 | id = INIR_USERPROFILE;
|
---|
| 936 | ininame = INSTDATA(hwnd);
|
---|
| 937 | if (ininame && *ininame) {
|
---|
| 938 | strcpy(filename, ininame);
|
---|
| 939 | p = filename;
|
---|
| 940 | while (*p) {
|
---|
| 941 | if (*p == '/')
|
---|
| 942 | *p = '\\';
|
---|
| 943 | p++;
|
---|
| 944 | }
|
---|
| 945 | p = strrchr(filename, '\\');
|
---|
| 946 | if (p) {
|
---|
| 947 | p++;
|
---|
| 948 | *p = 0;
|
---|
| 949 | }
|
---|
| 950 | else
|
---|
| 951 | *filename = 0;
|
---|
| 952 | }
|
---|
| 953 | else
|
---|
| 954 | *filename = 0;
|
---|
| 955 | strcat(filename, "*.INI");
|
---|
| 956 | if (insert_filename(hwnd, filename, TRUE, FALSE) && *filename)
|
---|
| 957 | WinSetDlgItemText(hwnd, id, filename);
|
---|
| 958 | }
|
---|
| 959 | break;
|
---|
[2] | 960 |
|
---|
[551] | 961 | case DID_OK:
|
---|
| 962 | {
|
---|
| 963 | HINI testini;
|
---|
| 964 | PRFPROFILE prfp;
|
---|
| 965 | CHAR sysini[CCHMAXPATH];
|
---|
| 966 | CHAR userini[CCHMAXPATH];
|
---|
[2] | 967 |
|
---|
[551] | 968 | WinQueryDlgItemText(hwnd, INIR_USERPROFILE, CCHMAXPATH, userini);
|
---|
| 969 | WinQueryDlgItemText(hwnd, INIR_SYSTEMPROFILE, CCHMAXPATH, sysini);
|
---|
| 970 | testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), userini);
|
---|
[912] | 971 | if (testini == NULLHANDLE) {
|
---|
[551] | 972 | saymsg(MB_CANCEL,
|
---|
| 973 | hwnd,
|
---|
| 974 | GetPString(IDS_ERRORTEXT),
|
---|
| 975 | GetPString(IDS_INICANTOPENUSERTEXT), userini);
|
---|
| 976 | break;
|
---|
| 977 | }
|
---|
[914] | 978 | CloseProfile(testini, FALSE);
|
---|
[551] | 979 | testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), sysini);
|
---|
[912] | 980 | if (testini == NULLHANDLE) {
|
---|
[551] | 981 | saymsg(MB_CANCEL,
|
---|
| 982 | hwnd,
|
---|
| 983 | GetPString(IDS_ERRORTEXT),
|
---|
| 984 | GetPString(IDS_INICANTOPENSYSTEXT), sysini);
|
---|
| 985 | break;
|
---|
| 986 | }
|
---|
[914] | 987 | CloseProfile(testini, FALSE);
|
---|
[551] | 988 | memset(&prfp, 0, sizeof(PRFPROFILE));
|
---|
| 989 | prfp.cchUserName = strlen(sysini);
|
---|
| 990 | prfp.cchSysName = strlen(userini);
|
---|
| 991 | prfp.pszUserName = (PSZ) userini;
|
---|
| 992 | prfp.pszSysName = (PSZ) sysini;
|
---|
| 993 | if (!PrfReset(WinQueryAnchorBlock(hwnd), &prfp)) {
|
---|
| 994 | Win_Error(hwnd, hwnd, __FILE__, __LINE__,
|
---|
| 995 | GetPString(IDS_INIPRFRESETFAILEDTEXT));
|
---|
| 996 | }
|
---|
| 997 | else
|
---|
| 998 | WinDismissDlg(hwnd, 1);
|
---|
| 999 | }
|
---|
| 1000 | break;
|
---|
[2] | 1001 |
|
---|
[551] | 1002 | case DID_CANCEL:
|
---|
| 1003 | WinDismissDlg(hwnd, 0);
|
---|
| 1004 | break;
|
---|
[2] | 1005 |
|
---|
[551] | 1006 | case IDM_HELP:
|
---|
| 1007 | if (hwndHelp)
|
---|
| 1008 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 1009 | MPFROM2SHORT(HELP_CHANGEINI, 0),
|
---|
| 1010 | MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1011 | break;
|
---|
| 1012 | }
|
---|
| 1013 | return 0;
|
---|
[2] | 1014 | }
|
---|
[551] | 1015 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1016 | }
|
---|
| 1017 |
|
---|
[551] | 1018 | MRESULT EXPENTRY SwapIniProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 1019 | {
|
---|
[551] | 1020 | switch (msg) {
|
---|
| 1021 | case WM_INITDLG:
|
---|
[574] | 1022 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 1023 | WinSendDlgItemMsg(hwnd,
|
---|
| 1024 | INIR_USERPROFILE,
|
---|
| 1025 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1026 | WinSendDlgItemMsg(hwnd,
|
---|
| 1027 | INIR_SYSTEMPROFILE,
|
---|
| 1028 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1029 | WinSetWindowText(hwnd, GetPString(IDS_INISWAPOS2INISTITLETEXT));
|
---|
| 1030 | break;
|
---|
[2] | 1031 |
|
---|
[551] | 1032 | case WM_COMMAND:
|
---|
| 1033 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1034 | case INIR_FIND:
|
---|
| 1035 | {
|
---|
| 1036 | CHAR filename[CCHMAXPATH], *p, *ininame;
|
---|
| 1037 | USHORT id = 0;
|
---|
| 1038 | HWND hwndFocus;
|
---|
[2] | 1039 |
|
---|
[551] | 1040 | hwndFocus = WinQueryFocus(HWND_DESKTOP);
|
---|
| 1041 | if (hwndFocus)
|
---|
| 1042 | id = WinQueryWindowUShort(hwndFocus, QWS_ID);
|
---|
| 1043 | if (id != INIR_SYSTEMPROFILE)
|
---|
| 1044 | id = INIR_USERPROFILE;
|
---|
| 1045 | ininame = INSTDATA(hwnd);
|
---|
| 1046 | if (ininame && *ininame) {
|
---|
| 1047 | strcpy(filename, ininame);
|
---|
| 1048 | p = filename;
|
---|
| 1049 | while (*p) {
|
---|
| 1050 | if (*p == '/')
|
---|
| 1051 | *p = '\\';
|
---|
| 1052 | p++;
|
---|
| 1053 | }
|
---|
| 1054 | p = strrchr(filename, '\\');
|
---|
| 1055 | if (p) {
|
---|
| 1056 | p++;
|
---|
| 1057 | *p = 0;
|
---|
| 1058 | }
|
---|
| 1059 | else
|
---|
| 1060 | *filename = 0;
|
---|
| 1061 | }
|
---|
| 1062 | else
|
---|
| 1063 | *filename = 0;
|
---|
| 1064 | strcat(filename, "*.INI");
|
---|
| 1065 | if (insert_filename(hwnd, filename, TRUE, FALSE) && *filename)
|
---|
| 1066 | WinSetDlgItemText(hwnd, id, filename);
|
---|
| 1067 | }
|
---|
| 1068 | break;
|
---|
[2] | 1069 |
|
---|
[551] | 1070 | case DID_OK:
|
---|
| 1071 | {
|
---|
| 1072 | HINI testini;
|
---|
| 1073 | PRFPROFILE prfp;
|
---|
| 1074 | CHAR sysini[CCHMAXPATH];
|
---|
| 1075 | CHAR userini[CCHMAXPATH];
|
---|
| 1076 | CHAR oldsysini[CCHMAXPATH];
|
---|
| 1077 | CHAR olduserini[CCHMAXPATH];
|
---|
| 1078 | CHAR tempsysini[CCHMAXPATH];
|
---|
| 1079 | CHAR tempuserini[CCHMAXPATH];
|
---|
| 1080 | CHAR tempsysini2[CCHMAXPATH];
|
---|
| 1081 | CHAR tempuserini2[CCHMAXPATH];
|
---|
| 1082 | CHAR *p;
|
---|
| 1083 | APIRET rc;
|
---|
[2] | 1084 |
|
---|
[551] | 1085 | *tempuserini = 0;
|
---|
| 1086 | *tempsysini = 0;
|
---|
| 1087 | *tempuserini2 = 0;
|
---|
| 1088 | *tempsysini2 = 0;
|
---|
| 1089 | memset(&prfp, 0, sizeof(PRFPROFILE));
|
---|
| 1090 | prfp.cchUserName = CCHMAXPATH;
|
---|
| 1091 | prfp.cchSysName = CCHMAXPATH;
|
---|
| 1092 | prfp.pszUserName = (PSZ) olduserini;
|
---|
| 1093 | prfp.pszSysName = (PSZ) oldsysini;
|
---|
| 1094 | if (!PrfQueryProfile(WinQueryAnchorBlock(hwnd), &prfp)) {
|
---|
| 1095 | Win_Error(hwnd, hwnd, __FILE__, __LINE__,
|
---|
| 1096 | GetPString(IDS_INIQUERYPRFFAILEDTEXT));
|
---|
| 1097 | break;
|
---|
| 1098 | }
|
---|
| 1099 | WinQueryDlgItemText(hwnd, INIR_USERPROFILE, CCHMAXPATH, userini);
|
---|
| 1100 | WinQueryDlgItemText(hwnd, INIR_SYSTEMPROFILE, CCHMAXPATH, sysini);
|
---|
| 1101 | MakeFullName(userini);
|
---|
| 1102 | MakeFullName(sysini);
|
---|
| 1103 | testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), userini);
|
---|
[912] | 1104 | if (testini == NULLHANDLE) {
|
---|
[551] | 1105 | saymsg(MB_CANCEL,
|
---|
| 1106 | hwnd,
|
---|
| 1107 | GetPString(IDS_ERRORTEXT),
|
---|
| 1108 | GetPString(IDS_INICANTOPENUSERTEXT), userini);
|
---|
| 1109 | break;
|
---|
| 1110 | }
|
---|
[914] | 1111 | CloseProfile(testini, FALSE);
|
---|
[551] | 1112 | testini = PrfOpenProfile(WinQueryAnchorBlock(hwnd), sysini);
|
---|
[912] | 1113 | if (testini == NULLHANDLE) {
|
---|
[551] | 1114 | saymsg(MB_CANCEL,
|
---|
| 1115 | hwnd,
|
---|
| 1116 | GetPString(IDS_ERRORTEXT),
|
---|
| 1117 | GetPString(IDS_INICANTOPENSYSTEXT), sysini);
|
---|
| 1118 | break;
|
---|
| 1119 | }
|
---|
[914] | 1120 | CloseProfile(testini, FALSE);
|
---|
[551] | 1121 | /* make copies of new inis */
|
---|
| 1122 | *tempuserini = 0;
|
---|
| 1123 | *tempsysini = 0;
|
---|
| 1124 | save_dir2(tempuserini);
|
---|
| 1125 | if (tempuserini[strlen(tempuserini) - 1] != '\\')
|
---|
| 1126 | strcat(tempuserini, "\\");
|
---|
| 1127 | strcat(tempuserini, "TEMPUSER.INI");
|
---|
| 1128 | rc = DosCopy(userini, tempuserini, DCPY_EXISTING);
|
---|
| 1129 | if (rc) {
|
---|
| 1130 | Dos_Error(MB_CANCEL,
|
---|
| 1131 | rc,
|
---|
| 1132 | hwnd,
|
---|
| 1133 | __FILE__,
|
---|
| 1134 | __LINE__,
|
---|
| 1135 | GetPString(IDS_COMPCOPYFAILEDTEXT), userini, tempuserini);
|
---|
| 1136 | break;
|
---|
| 1137 | }
|
---|
| 1138 | save_dir2(tempsysini);
|
---|
| 1139 | if (tempsysini[strlen(tempsysini) - 1] != '\\')
|
---|
| 1140 | strcat(tempsysini, "\\");
|
---|
| 1141 | strcat(tempsysini, "TEMPSYS.INI");
|
---|
| 1142 | rc = DosCopy(sysini, tempsysini, DCPY_EXISTING);
|
---|
| 1143 | if (rc) {
|
---|
| 1144 | Dos_Error(MB_CANCEL,
|
---|
| 1145 | rc,
|
---|
| 1146 | hwnd,
|
---|
| 1147 | __FILE__,
|
---|
| 1148 | __LINE__,
|
---|
| 1149 | GetPString(IDS_COMPCOPYFAILEDTEXT), sysini, tempsysini);
|
---|
| 1150 | break;
|
---|
| 1151 | }
|
---|
| 1152 | memset(&prfp, 0, sizeof(PRFPROFILE));
|
---|
| 1153 | prfp.cchUserName = strlen(tempuserini);
|
---|
| 1154 | prfp.cchSysName = strlen(tempsysini);
|
---|
| 1155 | prfp.pszUserName = (PSZ) tempuserini;
|
---|
| 1156 | prfp.pszSysName = (PSZ) tempsysini;
|
---|
| 1157 | if (!PrfReset(WinQueryAnchorBlock(hwnd), &prfp)) {
|
---|
| 1158 | Win_Error(hwnd, hwnd, __FILE__, __LINE__,
|
---|
| 1159 | GetPString(IDS_INIPRFRESETFAILEDTEXT));
|
---|
| 1160 | }
|
---|
| 1161 | else {
|
---|
| 1162 | /* backup old inis */
|
---|
| 1163 | strcpy(tempuserini2, olduserini);
|
---|
| 1164 | p = strrchr(tempuserini2, '\\');
|
---|
| 1165 | if (!p)
|
---|
| 1166 | *tempuserini2 = 0;
|
---|
| 1167 | else {
|
---|
| 1168 | p++;
|
---|
| 1169 | *p = 0;
|
---|
| 1170 | }
|
---|
| 1171 | strcat(tempuserini2, "OS2INI.BAK");
|
---|
| 1172 | rc = DosCopy(olduserini, tempuserini2, DCPY_EXISTING);
|
---|
| 1173 | if (rc) {
|
---|
| 1174 | Dos_Error(MB_CANCEL,
|
---|
| 1175 | rc,
|
---|
| 1176 | hwnd,
|
---|
| 1177 | __FILE__,
|
---|
| 1178 | __LINE__,
|
---|
| 1179 | GetPString(IDS_COMPCOPYFAILEDTEXT),
|
---|
| 1180 | olduserini, tempuserini2);
|
---|
| 1181 | WinDismissDlg(hwnd, 1);
|
---|
| 1182 | break;
|
---|
| 1183 | }
|
---|
| 1184 | strcpy(tempsysini2, oldsysini);
|
---|
| 1185 | p = strrchr(tempsysini2, '\\');
|
---|
| 1186 | if (!p)
|
---|
| 1187 | *tempsysini2 = 0;
|
---|
| 1188 | else {
|
---|
| 1189 | p++;
|
---|
| 1190 | *p = 0;
|
---|
| 1191 | }
|
---|
| 1192 | strcat(tempsysini2, "OS2SYINI.BAK");
|
---|
| 1193 | rc = DosCopy(oldsysini, tempsysini2, DCPY_EXISTING);
|
---|
| 1194 | if (rc) {
|
---|
| 1195 | Dos_Error(MB_CANCEL,
|
---|
| 1196 | rc,
|
---|
| 1197 | hwnd,
|
---|
| 1198 | __FILE__,
|
---|
| 1199 | __LINE__,
|
---|
| 1200 | GetPString(IDS_COMPCOPYFAILEDTEXT),
|
---|
| 1201 | oldsysini, tempsysini2);
|
---|
| 1202 | WinDismissDlg(hwnd, 1);
|
---|
| 1203 | break;
|
---|
| 1204 | }
|
---|
| 1205 | /* copy new inis to old ini names */
|
---|
| 1206 | rc = DosCopy(userini, olduserini, DCPY_EXISTING);
|
---|
| 1207 | if (rc) {
|
---|
| 1208 | Dos_Error(MB_CANCEL,
|
---|
| 1209 | rc,
|
---|
| 1210 | hwnd,
|
---|
| 1211 | __FILE__,
|
---|
| 1212 | __LINE__,
|
---|
| 1213 | GetPString(IDS_COMPCOPYFAILEDTEXT),
|
---|
| 1214 | userini, olduserini);
|
---|
| 1215 | WinDismissDlg(hwnd, 1);
|
---|
| 1216 | break;
|
---|
| 1217 | }
|
---|
| 1218 | rc = DosCopy(sysini, oldsysini, DCPY_EXISTING);
|
---|
| 1219 | if (rc) {
|
---|
| 1220 | Dos_Error(MB_CANCEL,
|
---|
| 1221 | rc,
|
---|
| 1222 | hwnd,
|
---|
| 1223 | __FILE__,
|
---|
| 1224 | __LINE__,
|
---|
| 1225 | GetPString(IDS_COMPCOPYFAILEDTEXT),
|
---|
| 1226 | userini, olduserini);
|
---|
| 1227 | WinDismissDlg(hwnd, 1);
|
---|
| 1228 | break;
|
---|
| 1229 | }
|
---|
[843] | 1230 | /* replace temp inis with new permanent inis */
|
---|
[551] | 1231 | memset(&prfp, 0, sizeof(PRFPROFILE));
|
---|
| 1232 | prfp.cchUserName = strlen(oldsysini);
|
---|
| 1233 | prfp.cchSysName = strlen(olduserini);
|
---|
| 1234 | prfp.pszUserName = (PSZ) olduserini;
|
---|
| 1235 | prfp.pszSysName = (PSZ) oldsysini;
|
---|
| 1236 | if (!PrfReset(WinQueryAnchorBlock(hwnd), &prfp)) {
|
---|
| 1237 | Win_Error(hwnd, hwnd, __FILE__, __LINE__,
|
---|
| 1238 | GetPString(IDS_INIPRFRESETFAILEDTEXT));
|
---|
| 1239 | }
|
---|
| 1240 | else {
|
---|
| 1241 | Notify(GetPString(IDS_SUCCESSTEXT));
|
---|
| 1242 | unlinkf(tempuserini);
|
---|
| 1243 | unlinkf(tempsysini);
|
---|
| 1244 | }
|
---|
| 1245 | WinDismissDlg(hwnd, 1);
|
---|
| 1246 | }
|
---|
| 1247 | }
|
---|
| 1248 | break;
|
---|
[2] | 1249 |
|
---|
[551] | 1250 | case DID_CANCEL:
|
---|
| 1251 | WinDismissDlg(hwnd, 0);
|
---|
| 1252 | break;
|
---|
[2] | 1253 |
|
---|
[551] | 1254 | case IDM_HELP:
|
---|
| 1255 | if (hwndHelp)
|
---|
| 1256 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 1257 | MPFROM2SHORT(HELP_SWAPINI, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1258 | break;
|
---|
| 1259 | }
|
---|
| 1260 | return 0;
|
---|
[2] | 1261 | }
|
---|
[551] | 1262 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1263 | }
|
---|
| 1264 |
|
---|
[551] | 1265 | MRESULT EXPENTRY AddIniProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 1266 | {
|
---|
[914] | 1267 | INIDATA *inidata = INSTDATA(hwnd);
|
---|
[871] | 1268 | size_t l;
|
---|
[2] | 1269 |
|
---|
[551] | 1270 | switch (msg) {
|
---|
| 1271 | case WM_INITDLG:
|
---|
| 1272 | if (!mp2) {
|
---|
| 1273 | WinDismissDlg(hwnd, 0);
|
---|
| 1274 | break;
|
---|
| 1275 | }
|
---|
| 1276 | inidata = (INIDATA *) mp2;
|
---|
| 1277 | if (inidata->edit)
|
---|
| 1278 | WinSetWindowText(hwnd, GetPString(IDS_INIEDITINITITLETEXT));
|
---|
[574] | 1279 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) mp2);
|
---|
[551] | 1280 | WinSendDlgItemMsg(hwnd,
|
---|
| 1281 | IAD_APPNAME,
|
---|
| 1282 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1283 | WinSendDlgItemMsg(hwnd,
|
---|
| 1284 | IAD_KEYNAME,
|
---|
| 1285 | EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
| 1286 | WinSendDlgItemMsg(hwnd,
|
---|
| 1287 | IAD_DATA,
|
---|
| 1288 | EM_SETTEXTLIMIT, MPFROM2SHORT(32767, 0), MPVOID);
|
---|
| 1289 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
| 1290 | WinSetDlgItemText(hwnd, IAD_APPNAME, inidata->applname);
|
---|
| 1291 | if (inidata->edit) {
|
---|
| 1292 | WinSetDlgItemText(hwnd, IAD_KEYNAME, inidata->keyname);
|
---|
| 1293 | if (inidata->data && inidata->datalen) {
|
---|
[2] | 1294 |
|
---|
[551] | 1295 | CHAR *p;
|
---|
[2] | 1296 |
|
---|
[551] | 1297 | inidata->isbinary = FALSE;
|
---|
| 1298 | p = inidata->data;
|
---|
| 1299 | while ((p - inidata->data) < inidata->datalen - 1) {
|
---|
| 1300 | if (*p < ' ' || !isprint(*p)) {
|
---|
| 1301 | inidata->isbinary = TRUE;
|
---|
| 1302 | break;
|
---|
| 1303 | }
|
---|
| 1304 | p++;
|
---|
| 1305 | }
|
---|
| 1306 | if (inidata->isbinary) {
|
---|
| 1307 | inidata->isbinary = TRUE;
|
---|
| 1308 | WinCheckButton(hwnd, IAD_ISBINARY, TRUE);
|
---|
| 1309 | if (saymsg(MB_ENTERCANCEL | MB_ICONEXCLAMATION,
|
---|
| 1310 | hwnd,
|
---|
| 1311 | GetPString(IDS_WARNINGTEXT),
|
---|
| 1312 | GetPString(IDS_INIBINARYDATASKIPTEXT)) == MBID_CANCEL)
|
---|
| 1313 | WinDismissDlg(hwnd, 0);
|
---|
[871] | 1314 | l = inidata->datalen * 4 + 1;
|
---|
| 1315 | p = xmallocz(l, pszSrcFile, __LINE__);
|
---|
[551] | 1316 | if (p) {
|
---|
[871] | 1317 | fixup(inidata->data, p, l, inidata->datalen);
|
---|
[551] | 1318 | WinSetDlgItemText(hwnd, IAD_DATA, p);
|
---|
[1009] | 1319 | xfree(p, pszSrcFile, __LINE__);
|
---|
[551] | 1320 | }
|
---|
| 1321 | }
|
---|
| 1322 | else
|
---|
| 1323 | WinSetDlgItemText(hwnd, IAD_DATA, inidata->data);
|
---|
[2] | 1324 | }
|
---|
[551] | 1325 | PostMsg(hwnd, UM_SETDIR, MPFROMLONG(1L), MPVOID);
|
---|
| 1326 | }
|
---|
| 1327 | else
|
---|
| 1328 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 1329 | {
|
---|
| 1330 | CHAR s[32];
|
---|
[2] | 1331 |
|
---|
[551] | 1332 | *s = 0;
|
---|
| 1333 | WinQueryDlgItemText(hwnd, IAD_DATA, 32, s);
|
---|
| 1334 | if (*s)
|
---|
| 1335 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), TRUE);
|
---|
| 1336 | }
|
---|
| 1337 | WinSendDlgItemMsg(hwnd, IAD_APPNAME, EM_QUERYCHANGED, MPVOID, MPVOID);
|
---|
| 1338 | WinSendDlgItemMsg(hwnd, IAD_KEYNAME, EM_QUERYCHANGED, MPVOID, MPVOID);
|
---|
| 1339 | WinSendDlgItemMsg(hwnd, IAD_DATA, EM_QUERYCHANGED, MPVOID, MPVOID);
|
---|
| 1340 | break;
|
---|
[2] | 1341 |
|
---|
[551] | 1342 | case UM_SETDIR:
|
---|
| 1343 | if (mp1)
|
---|
| 1344 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, IAD_DATA));
|
---|
| 1345 | else
|
---|
| 1346 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, IAD_KEYNAME));
|
---|
| 1347 | return 0;
|
---|
[2] | 1348 |
|
---|
[551] | 1349 | case UM_SETUP:
|
---|
| 1350 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
| 1351 | hwnd,
|
---|
| 1352 | GetPString(IDS_WARNINGTEXT), GetPString(IDS_INIAPPKEYEXISTSTEXT));
|
---|
| 1353 | return 0;
|
---|
[2] | 1354 |
|
---|
[551] | 1355 | case WM_CONTROL:
|
---|
| 1356 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 1357 | case EN_KILLFOCUS:
|
---|
| 1358 | inidata = INSTDATA(hwnd);
|
---|
[914] | 1359 | if (!inidata)
|
---|
| 1360 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1361 | else {
|
---|
[551] | 1362 | CHAR s[CCHMAXPATH], applname[CCHMAXPATH];
|
---|
| 1363 | BOOL appchanged = FALSE, keychanged = FALSE;
|
---|
[2] | 1364 |
|
---|
[551] | 1365 | *applname = 0;
|
---|
| 1366 | WinQueryDlgItemText(hwnd, IAD_APPNAME, CCHMAXPATH, applname);
|
---|
| 1367 | bstrip(applname);
|
---|
| 1368 | if (*applname) {
|
---|
| 1369 | *s = 0;
|
---|
| 1370 | WinQueryDlgItemText(hwnd, IAD_KEYNAME, CCHMAXPATH, s);
|
---|
| 1371 | bstrip(s);
|
---|
| 1372 | if (*s) {
|
---|
| 1373 | appchanged = (BOOL) WinSendDlgItemMsg(hwnd, IAD_APPNAME,
|
---|
| 1374 | EM_QUERYCHANGED,
|
---|
| 1375 | MPVOID, MPVOID);
|
---|
| 1376 | keychanged = (BOOL) WinSendDlgItemMsg(hwnd, IAD_KEYNAME,
|
---|
| 1377 | EM_QUERYCHANGED,
|
---|
| 1378 | MPVOID, MPVOID);
|
---|
| 1379 | if (appchanged || keychanged) {
|
---|
[2] | 1380 |
|
---|
[551] | 1381 | ULONG size = 0L;
|
---|
[2] | 1382 |
|
---|
[551] | 1383 | if (PrfQueryProfileSize(inidata->hini, applname, s, &size))
|
---|
| 1384 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 1385 | }
|
---|
| 1386 | *s = 0;
|
---|
| 1387 | WinQueryDlgItemText(hwnd, IAD_DATA, CCHMAXPATH, s);
|
---|
| 1388 | bstrip(s);
|
---|
| 1389 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), (*s != 0));
|
---|
| 1390 | }
|
---|
| 1391 | else
|
---|
| 1392 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
| 1393 | }
|
---|
| 1394 | else
|
---|
| 1395 | WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
[2] | 1396 | }
|
---|
[551] | 1397 | break;
|
---|
| 1398 | }
|
---|
| 1399 | return 0;
|
---|
[2] | 1400 |
|
---|
[551] | 1401 | case WM_COMMAND:
|
---|
| 1402 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 1403 | case DID_OK:
|
---|
| 1404 | {
|
---|
| 1405 | CHAR applname[CCHMAXPATH], keyname[CCHMAXPATH], data[CCHMAXPATH];
|
---|
| 1406 | INT len;
|
---|
[2] | 1407 |
|
---|
[551] | 1408 | inidata = INSTDATA(hwnd);
|
---|
| 1409 | if (!inidata) {
|
---|
| 1410 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1411 | break;
|
---|
| 1412 | }
|
---|
| 1413 | inidata->isbinary = WinQueryButtonCheckstate(hwnd, IAD_ISBINARY);
|
---|
| 1414 | *applname = 0;
|
---|
| 1415 | WinQueryDlgItemText(hwnd, IAD_APPNAME, CCHMAXPATH, applname);
|
---|
| 1416 | bstrip(applname);
|
---|
| 1417 | if (*applname) {
|
---|
| 1418 | *keyname = 0;
|
---|
| 1419 | WinQueryDlgItemText(hwnd, IAD_KEYNAME, CCHMAXPATH, keyname);
|
---|
| 1420 | bstrip(keyname);
|
---|
| 1421 | if (*keyname) {
|
---|
| 1422 | *data = 0;
|
---|
| 1423 | WinQueryDlgItemText(hwnd, IAD_DATA, CCHMAXPATH, data);
|
---|
| 1424 | if (*data) {
|
---|
| 1425 | if (inidata->isbinary)
|
---|
| 1426 | len = literal(data);
|
---|
| 1427 | else
|
---|
| 1428 | len = strlen(data) + 1;
|
---|
| 1429 | PrfWriteProfileData(inidata->hini, applname, keyname, data,
|
---|
| 1430 | (ULONG) len);
|
---|
| 1431 | WinSendMsg(inidata->hwndIni, UM_RESCAN,
|
---|
| 1432 | MPFROMP(applname), MPFROMP(keyname));
|
---|
| 1433 | WinDismissDlg(hwnd, 1);
|
---|
| 1434 | }
|
---|
| 1435 | }
|
---|
| 1436 | }
|
---|
| 1437 | }
|
---|
| 1438 | break;
|
---|
[2] | 1439 |
|
---|
[551] | 1440 | case DID_CANCEL:
|
---|
| 1441 | WinDismissDlg(hwnd, 0);
|
---|
| 1442 | break;
|
---|
[2] | 1443 |
|
---|
[551] | 1444 | case IDM_HELP:
|
---|
| 1445 | if (hwndHelp)
|
---|
| 1446 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
| 1447 | MPFROM2SHORT(HELP_INIADD, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 1448 | break;
|
---|
| 1449 | }
|
---|
| 1450 | return 0;
|
---|
[2] | 1451 | }
|
---|
[551] | 1452 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1453 | }
|
---|
| 1454 |
|
---|
[551] | 1455 | static ULONG flFrameFlags = FCF_SYSMENU | FCF_SIZEBORDER | FCF_ICON |
|
---|
| 1456 | FCF_TITLEBAR | FCF_MINMAX | FCF_MENU | FCF_ACCELTABLE | FCF_NOBYTEALIGN;
|
---|
[2] | 1457 |
|
---|
[551] | 1458 | HWND StartIniEditor(HWND hwnd, CHAR * fname, INT flags)
|
---|
[336] | 1459 | {
|
---|
[2] | 1460 | /*
|
---|
| 1461 | * create an ini editor window
|
---|
| 1462 | * bitmapped flags:
|
---|
| 1463 | * 2 = don't position window for non-desktop client
|
---|
| 1464 | * 4 = don't kill proc when closed
|
---|
| 1465 | */
|
---|
| 1466 |
|
---|
[551] | 1467 | HWND hwndFrame, hwndClient;
|
---|
| 1468 | HINI hINI;
|
---|
| 1469 | HAB useHab = (HAB) 0;
|
---|
[2] | 1470 | CHAR *filename = NULL;
|
---|
| 1471 |
|
---|
[551] | 1472 | if (fExternalINIs || strcmp(realappname, FM3Str))
|
---|
[2] | 1473 | hwnd = HWND_DESKTOP;
|
---|
[551] | 1474 | if (hwnd != HWND_DESKTOP)
|
---|
[2] | 1475 | useHab = WinQueryAnchorBlock(hwnd);
|
---|
[551] | 1476 | if (fname && *fname) {
|
---|
| 1477 | filename = xstrdup(fname, pszSrcFile, __LINE__);
|
---|
[336] | 1478 | if (!filename)
|
---|
[551] | 1479 | return (HWND) 0;
|
---|
| 1480 | hINI = PrfOpenProfile(useHab, filename);
|
---|
[912] | 1481 | if (hINI == NULLHANDLE) {
|
---|
[1009] | 1482 | xfree(filename, pszSrcFile, __LINE__);
|
---|
[551] | 1483 | return (HWND) 0;
|
---|
[2] | 1484 | }
|
---|
| 1485 | else
|
---|
[914] | 1486 | CloseProfile(hINI, FALSE);
|
---|
[2] | 1487 | }
|
---|
| 1488 |
|
---|
[551] | 1489 | if (ParentIsDesktop(hwnd, hwnd))
|
---|
[2] | 1490 | flFrameFlags |= FCF_TASKLIST;
|
---|
| 1491 | hwndFrame = WinCreateStdWindow(hwnd,
|
---|
[551] | 1492 | 0,
|
---|
| 1493 | &flFrameFlags,
|
---|
[593] | 1494 | WC_INIEDITOR,
|
---|
[551] | 1495 | NullStr,
|
---|
| 1496 | fwsAnimate,
|
---|
| 1497 | FM3ModHandle, INI_FRAME, &hwndClient);
|
---|
| 1498 | if (hwndFrame) {
|
---|
| 1499 | WinSetWindowUShort(hwndFrame, QWS_ID, INI_FRAME);
|
---|
| 1500 | if (!ParentIsDesktop(hwndFrame, hwnd) && !(flags & 2)) {
|
---|
[2] | 1501 |
|
---|
| 1502 | SWP swp;
|
---|
| 1503 |
|
---|
[551] | 1504 | FillClient(hwnd, &swp, NULL, FALSE);
|
---|
| 1505 | WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
|
---|
| 1506 | SWP_SIZE | SWP_MOVE);
|
---|
[2] | 1507 | }
|
---|
[551] | 1508 | else if (ParentIsDesktop(hwndFrame, hwnd)) {
|
---|
| 1509 | if (!WinRestoreWindowPos(FM2Str, "INIWindowPos", hwndFrame)) {
|
---|
[2] | 1510 |
|
---|
[551] | 1511 | ULONG fl = SWP_MOVE | SWP_SIZE;
|
---|
| 1512 | SWP swp;
|
---|
[2] | 1513 |
|
---|
[551] | 1514 | WinQueryTaskSizePos(WinQueryAnchorBlock(hwndFrame), 0L, &swp);
|
---|
| 1515 | if (swp.fl & (SWP_MINIMIZE | SWP_HIDE))
|
---|
| 1516 | fl = swp.fl;
|
---|
| 1517 | else if (swp.fl & SWP_ACTIVATE)
|
---|
| 1518 | fl |= SWP_ACTIVATE;
|
---|
| 1519 | WinSetWindowPos(hwndFrame, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy,
|
---|
| 1520 | fl);
|
---|
[2] | 1521 | }
|
---|
| 1522 | }
|
---|
[551] | 1523 | PostMsg(hwndClient, UM_SELECT, MPVOID, MPVOID);
|
---|
| 1524 | PostMsg(hwndClient, UM_ACTION, MPVOID, MPVOID);
|
---|
| 1525 | if (!PostMsg(hwndClient, UM_LOADFILE, MPFROMP(((filename && *filename) ?
|
---|
| 1526 | filename : NULL)), MPVOID))
|
---|
| 1527 | WinSendMsg(hwndClient, UM_LOADFILE, MPFROMP(((filename && *filename) ?
|
---|
| 1528 | filename : NULL)), MPVOID);
|
---|
| 1529 | if (flags & 4)
|
---|
| 1530 | PostMsg(hwndClient, UM_INITIALSIZE, MPVOID, MPVOID);
|
---|
[2] | 1531 | }
|
---|
[985] | 1532 | else
|
---|
[1009] | 1533 | xfree(filename, pszSrcFile, __LINE__);
|
---|
[2] | 1534 | return hwndFrame;
|
---|
| 1535 | }
|
---|
| 1536 |
|
---|
[551] | 1537 | MRESULT EXPENTRY IniLBSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 1538 | {
|
---|
[574] | 1539 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 1540 | static HWND hwndPopup = (HWND) 0;
|
---|
[2] | 1541 |
|
---|
[551] | 1542 | switch (msg) {
|
---|
| 1543 | case WM_SETFOCUS:
|
---|
| 1544 | if (mp2)
|
---|
| 1545 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_FOCUSME, mp1, mp2);
|
---|
| 1546 | break;
|
---|
[2] | 1547 |
|
---|
[551] | 1548 | case WM_MENUEND:
|
---|
| 1549 | if (hwndPopup == (HWND) mp2) {
|
---|
| 1550 | WinDestroyWindow(hwndPopup);
|
---|
| 1551 | hwndPopup = (HWND) 0;
|
---|
| 1552 | }
|
---|
| 1553 | break;
|
---|
[2] | 1554 |
|
---|
[551] | 1555 | case WM_CONTEXTMENU:
|
---|
| 1556 | {
|
---|
| 1557 | USHORT id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[2] | 1558 |
|
---|
[551] | 1559 | switch (id) {
|
---|
| 1560 | case INI_APPLIST:
|
---|
| 1561 | id = INI_APPMENU;
|
---|
| 1562 | break;
|
---|
| 1563 | case INI_KEYLIST:
|
---|
| 1564 | id = INI_KEYMENU;
|
---|
| 1565 | break;
|
---|
| 1566 | default:
|
---|
| 1567 | id = 0;
|
---|
| 1568 | break;
|
---|
[2] | 1569 | }
|
---|
[551] | 1570 | if (id) {
|
---|
| 1571 | if (hwndPopup)
|
---|
| 1572 | WinDestroyWindow(hwndPopup);
|
---|
| 1573 | hwndPopup = WinLoadMenu(HWND_DESKTOP, FM3ModHandle, id);
|
---|
| 1574 | if (hwndPopup)
|
---|
| 1575 | WinPopupMenu(hwnd, WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1576 | hwndPopup, 8, 8, 0,
|
---|
| 1577 | PU_HCONSTRAIN | PU_VCONSTRAIN |
|
---|
| 1578 | PU_KEYBOARD | PU_MOUSEBUTTON1);
|
---|
| 1579 | }
|
---|
| 1580 | }
|
---|
| 1581 | break;
|
---|
[2] | 1582 |
|
---|
[551] | 1583 | case WM_BEGINDRAG:
|
---|
| 1584 | {
|
---|
| 1585 | PDRAGINFO pDInfo;
|
---|
| 1586 | DRAGITEM DItem;
|
---|
| 1587 | DRAGIMAGE DIcon;
|
---|
| 1588 | INIDATA *inidata;
|
---|
| 1589 | HPOINTER hptrINI;
|
---|
| 1590 | USHORT id;
|
---|
[603] | 1591 | HWND hDrop = 0;
|
---|
[2] | 1592 |
|
---|
[551] | 1593 | id = WinQueryWindowUShort(hwnd, QWS_ID);
|
---|
[574] | 1594 | inidata = WinQueryWindowPtr(WinQueryWindow(hwnd, QW_PARENT), QWL_USER);
|
---|
[551] | 1595 | if (!inidata || !*inidata->ininame || !*inidata->applname ||
|
---|
| 1596 | !inidata->keyname) {
|
---|
| 1597 | DosBeep(50, 100);
|
---|
| 1598 | break;
|
---|
[2] | 1599 | }
|
---|
[551] | 1600 | hptrINI = WinLoadPointer(HWND_DESKTOP, FM3ModHandle, INI_FRAME);
|
---|
| 1601 | memset(&DItem, 0, sizeof(DItem));
|
---|
| 1602 | memset(&DIcon, 0, sizeof(DIcon));
|
---|
| 1603 | DIcon.cb = sizeof(DIcon);
|
---|
| 1604 | DIcon.cptl = 0;
|
---|
| 1605 | DIcon.hImage = hptrINI;
|
---|
| 1606 | DIcon.fl = DRG_ICON;
|
---|
| 1607 | DIcon.sizlStretch.cx = 32;
|
---|
| 1608 | DIcon.sizlStretch.cy = 32;
|
---|
| 1609 | DIcon.cxOffset = -16;
|
---|
| 1610 | DIcon.cyOffset = 0;
|
---|
| 1611 | DItem.hwndItem = hwnd;
|
---|
| 1612 | DItem.ulItemID = 0L;
|
---|
| 1613 | DItem.hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
---|
| 1614 | DItem.hstrRMF = DrgAddStrHandle("<DRM_FM2INIRECORD,DRF_FM2INI>");
|
---|
| 1615 | DItem.hstrContainerName = DrgAddStrHandle(inidata->ininame);
|
---|
| 1616 | DItem.hstrSourceName = DrgAddStrHandle(inidata->applname);
|
---|
| 1617 | if (id == INI_APPLIST)
|
---|
| 1618 | DItem.hstrTargetName = DrgAddStrHandle(NullStr);
|
---|
| 1619 | else
|
---|
| 1620 | DItem.hstrTargetName = DrgAddStrHandle(inidata->keyname);
|
---|
| 1621 | DItem.fsControl = 0;
|
---|
| 1622 | DItem.fsSupportedOps = DO_COPYABLE | DO_LINKABLE | DO_MOVEABLE;
|
---|
| 1623 | pDInfo = DrgAllocDraginfo(1L);
|
---|
| 1624 | DrgSetDragitem(pDInfo, &DItem, sizeof(DRAGITEM), 0L);
|
---|
[603] | 1625 | hDrop = DrgDrag(hwnd, pDInfo, &DIcon, 1L, VK_ENDDRAG, (PVOID) NULL);
|
---|
[618] | 1626 | if (hDrop == NULLHANDLE)
|
---|
[843] | 1627 | FreeDragInfoData(hwnd, pDInfo);
|
---|
[551] | 1628 | WinDestroyPointer(hptrINI);
|
---|
| 1629 | }
|
---|
| 1630 | break;
|
---|
[2] | 1631 |
|
---|
[551] | 1632 | case DM_DRAGOVER:
|
---|
| 1633 | {
|
---|
| 1634 | PDRAGINFO pDInfo = (PDRAGINFO) mp1;
|
---|
[618] | 1635 | PDRAGITEM pDItem;
|
---|
[2] | 1636 |
|
---|
[618] | 1637 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
[843] | 1638 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 1639 | "DrgAccessDraginfo");
|
---|
[2] | 1640 | }
|
---|
[618] | 1641 | else {
|
---|
[843] | 1642 | pDItem = DrgQueryDragitemPtr(pDInfo,0);
|
---|
| 1643 | /* Check valid rendering mechanisms and data */
|
---|
| 1644 | if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) {
|
---|
[551] | 1645 | DrgFreeDraginfo(pDInfo);
|
---|
[618] | 1646 | return (MRFROM2SHORT(DOR_DROP, DO_LINK)); /* OK to drop */
|
---|
[843] | 1647 | }
|
---|
| 1648 | else if (DrgVerifyRMF(pDItem, DRM_FM2INIRECORD, DRF_FM2INI)) {
|
---|
[618] | 1649 | if (WinQueryWindow(pDInfo->hwndSource, QW_PARENT) !=
|
---|
| 1650 | WinQueryWindow(hwnd, QW_PARENT))
|
---|
| 1651 | {
|
---|
| 1652 | DrgFreeDraginfo(pDInfo);
|
---|
| 1653 | return (MRFROM2SHORT(DOR_DROP, ((fCopyDefault) ? DO_COPY : DO_MOVE)));
|
---|
| 1654 | }
|
---|
[843] | 1655 | }
|
---|
| 1656 | DrgFreeDraginfo(pDInfo);
|
---|
[551] | 1657 | }
|
---|
| 1658 | }
|
---|
[618] | 1659 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
[2] | 1660 |
|
---|
[551] | 1661 | case DM_DRAGLEAVE:
|
---|
[2] | 1662 |
|
---|
[551] | 1663 | break;
|
---|
[2] | 1664 |
|
---|
[551] | 1665 | case DM_DROP:
|
---|
| 1666 | {
|
---|
| 1667 | PDRAGINFO pDInfo = (PDRAGINFO) mp1;
|
---|
[843] | 1668 | PDRAGITEM pDItem; /* Pointer to DRAGITEM */
|
---|
[618] | 1669 | ULONG numitems, curitem, len;
|
---|
[551] | 1670 | USHORT action;
|
---|
| 1671 | CHAR szFrom[CCHMAXPATH + 2], szDir[CCHMAXPATH + 1],
|
---|
| 1672 | szTemp[CCHMAXPATH + 2];
|
---|
[847] | 1673 | FILESTATUS3 fsa;
|
---|
[551] | 1674 | INIREC inirec;
|
---|
[2] | 1675 |
|
---|
[618] | 1676 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
[843] | 1677 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 1678 | "DrgAccessDraginfo");
|
---|
| 1679 | return 0;
|
---|
[618] | 1680 | }
|
---|
[551] | 1681 | numitems = DrgQueryDragitemCount(pDInfo);
|
---|
[618] | 1682 | for (curitem = 0; curitem < numitems; curitem++) {
|
---|
[551] | 1683 | pDItem = DrgQueryDragitemPtr(pDInfo, curitem);
|
---|
| 1684 | if (DrgVerifyRMF(pDItem, DRM_OS2FILE, NULL)) {
|
---|
| 1685 | if (pDItem->fsControl & DC_PREPARE)
|
---|
| 1686 | DrgSendTransferMsg(pDItem->hwndItem,
|
---|
| 1687 | DM_ENDCONVERSATION,
|
---|
| 1688 | MPFROMLONG(pDItem->ulItemID),
|
---|
| 1689 | MPFROMLONG(DMFL_TARGETFAIL));
|
---|
| 1690 | else {
|
---|
| 1691 | if (FullDrgName(pDItem, szFrom, sizeof(szFrom)) &&
|
---|
[843] | 1692 | !DosQueryPathInfo(szFrom, FIL_STANDARD, &fsa, sizeof(fsa)))
|
---|
[551] | 1693 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
| 1694 | MPFROM2SHORT(IDM_COMPARE, 0), MPFROMP(szFrom));
|
---|
| 1695 | DrgSendTransferMsg(pDItem->hwndItem,
|
---|
| 1696 | DM_ENDCONVERSATION,
|
---|
| 1697 | MPFROMLONG(pDItem->ulItemID),
|
---|
| 1698 | MPFROMLONG(DMFL_TARGETFAIL));
|
---|
| 1699 | }
|
---|
| 1700 | }
|
---|
| 1701 | else if (DrgVerifyRMF(pDItem, DRM_FM2INIRECORD, DRF_FM2INI)) {
|
---|
| 1702 | *szDir = *szFrom = *szTemp = 0;
|
---|
| 1703 | len = DrgQueryStrName(pDItem->hstrContainerName, CCHMAXPATH, szDir);
|
---|
| 1704 | szDir[len] = 0;
|
---|
| 1705 | len = DrgQueryStrName(pDItem->hstrSourceName, CCHMAXPATH, szFrom);
|
---|
| 1706 | szFrom[len] = 0;
|
---|
| 1707 | len = DrgQueryStrName(pDItem->hstrTargetName, CCHMAXPATH, szTemp);
|
---|
| 1708 | szTemp[len] = 0;
|
---|
| 1709 | switch (pDInfo->usOperation) {
|
---|
| 1710 | case DO_MOVE:
|
---|
| 1711 | action = IDM_MOVE;
|
---|
| 1712 | break;
|
---|
| 1713 | case DO_COPY:
|
---|
| 1714 | action = IDM_COPY;
|
---|
| 1715 | break;
|
---|
| 1716 | default:
|
---|
| 1717 | action = IDM_INFO;
|
---|
| 1718 | break;
|
---|
| 1719 | }
|
---|
| 1720 | memset(&inirec, 0, sizeof(inirec));
|
---|
| 1721 | inirec.size = sizeof(inirec);
|
---|
| 1722 | strcpy(inirec.filename2, szDir);
|
---|
| 1723 | strcpy(inirec.app, szFrom);
|
---|
| 1724 | strcpy(inirec.key, szTemp);
|
---|
| 1725 | inirec.action = action;
|
---|
| 1726 | inirec.hwndSource = WinQueryWindow(pDInfo->hwndSource, QW_PARENT);
|
---|
| 1727 | WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
| 1728 | MPFROM2SHORT(action, 0), MPFROMP(&inirec));
|
---|
| 1729 | DrgSendTransferMsg(pDItem->hwndItem,
|
---|
| 1730 | DM_ENDCONVERSATION,
|
---|
| 1731 | MPFROMLONG(pDItem->ulItemID),
|
---|
| 1732 | MPFROMLONG(DMFL_TARGETFAIL));
|
---|
| 1733 | }
|
---|
[618] | 1734 | } // for
|
---|
| 1735 | FreeDragInfoData(hwnd, pDInfo);
|
---|
[551] | 1736 | }
|
---|
| 1737 | return 0;
|
---|
[2] | 1738 |
|
---|
[551] | 1739 | case WM_DESTROY:
|
---|
| 1740 | if (hwndPopup)
|
---|
| 1741 | WinDestroyWindow(hwndPopup);
|
---|
| 1742 | hwndPopup = (HWND) 0;
|
---|
| 1743 | break;
|
---|
[618] | 1744 | } // switch
|
---|
[551] | 1745 | if (oldproc)
|
---|
| 1746 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
| 1747 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1748 | }
|
---|
| 1749 |
|
---|
[551] | 1750 | MRESULT EXPENTRY IniLBSubProc2(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 1751 | {
|
---|
[574] | 1752 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 1753 |
|
---|
[551] | 1754 | switch (msg) {
|
---|
| 1755 | case WM_SETFOCUS:
|
---|
| 1756 | if (mp2)
|
---|
| 1757 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), UM_FOCUSME, mp1, mp2);
|
---|
| 1758 | break;
|
---|
[2] | 1759 | }
|
---|
[551] | 1760 | if (oldproc)
|
---|
| 1761 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
| 1762 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 1763 | }
|
---|
| 1764 |
|
---|
[551] | 1765 | MRESULT EXPENTRY IniProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[336] | 1766 | {
|
---|
[2] | 1767 | INIDATA *inidata;
|
---|
[551] | 1768 | SHORT sSel;
|
---|
[377] | 1769 | PFNWP oldproc;
|
---|
[2] | 1770 |
|
---|
[551] | 1771 | switch (msg) {
|
---|
| 1772 | case WM_CREATE:
|
---|
| 1773 | inidata = xmallocz(sizeof(INIDATA), pszSrcFile, __LINE__);
|
---|
| 1774 | if (!inidata) {
|
---|
| 1775 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 1776 | break;
|
---|
| 1777 | }
|
---|
| 1778 | inidata->size = sizeof(INIDATA);
|
---|
| 1779 | inidata->confirm = TRUE;
|
---|
| 1780 | inidata->currid = INI_APPLIST;
|
---|
| 1781 | inidata->hwndMenu = WinWindowFromID(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 1782 | FID_MENU);
|
---|
| 1783 | inidata->hwndIni = hwnd;
|
---|
[574] | 1784 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) inidata);
|
---|
[551] | 1785 | WinCheckMenuItem(inidata->hwndMenu, INI_CONFIRM, inidata->confirm);
|
---|
[377] | 1786 |
|
---|
[551] | 1787 | if (!WinCreateWindow
|
---|
| 1788 | (hwnd, WC_LISTBOX, (PSZ) NULL,
|
---|
| 1789 | WS_VISIBLE | LS_HORZSCROLL | LS_NOADJUSTPOS, 0, 0, 0, 0, hwnd,
|
---|
| 1790 | HWND_TOP, INI_APPLIST, NULL, NULL)) {
|
---|
| 1791 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1792 | }
|
---|
| 1793 | if (!WinCreateWindow
|
---|
| 1794 | (hwnd, WC_LISTBOX, (PSZ) NULL,
|
---|
| 1795 | WS_VISIBLE | LS_HORZSCROLL | LS_NOADJUSTPOS, 0, 0, 0, 0, hwnd,
|
---|
| 1796 | HWND_TOP, INI_KEYLIST, NULL, NULL)) {
|
---|
| 1797 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1798 | }
|
---|
| 1799 | if (!WinCreateWindow
|
---|
| 1800 | (hwnd, WC_LISTBOX, (PSZ) NULL,
|
---|
| 1801 | WS_VISIBLE | LS_HORZSCROLL | LS_NOADJUSTPOS, 0, 0, 0, 0, hwnd,
|
---|
| 1802 | HWND_TOP, INI_DATALIST, NULL, NULL)) {
|
---|
| 1803 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1804 | }
|
---|
| 1805 | if (!WinCreateWindow(hwnd, WC_STATIC, (PSZ) NULL, WS_VISIBLE | SS_TEXT |
|
---|
| 1806 | DT_CENTER | DT_VCENTER, 0, 0, 0, 0, hwnd, HWND_TOP,
|
---|
| 1807 | INI_NUMAPPS, NULL, NULL)) {
|
---|
| 1808 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1809 | }
|
---|
| 1810 | if (!WinCreateWindow(hwnd, WC_STATIC, (PSZ) NULL, WS_VISIBLE | SS_TEXT |
|
---|
| 1811 | DT_CENTER | DT_VCENTER, 0, 0, 0, 0, hwnd, HWND_TOP,
|
---|
| 1812 | INI_NUMKEYS, NULL, NULL)) {
|
---|
| 1813 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1814 | }
|
---|
| 1815 | if (!WinCreateWindow(hwnd, WC_STATIC, (PSZ) NULL, WS_VISIBLE | SS_TEXT |
|
---|
| 1816 | DT_CENTER | DT_VCENTER, 0, 0, 0, 0, hwnd, HWND_TOP,
|
---|
| 1817 | INI_NUMDATA, NULL, NULL)) {
|
---|
| 1818 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1819 | }
|
---|
| 1820 | if (!WinCreateWindow(hwnd,
|
---|
| 1821 | WC_STATIC,
|
---|
| 1822 | GetPString(IDS_APPLICATIONSTITLETEXT),
|
---|
| 1823 | WS_VISIBLE | SS_TEXT |
|
---|
| 1824 | DT_CENTER | DT_VCENTER,
|
---|
| 1825 | 0,
|
---|
| 1826 | 0, 0, 0, hwnd, HWND_TOP, INI_APPHDR, NULL, NULL)) {
|
---|
| 1827 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1828 | }
|
---|
| 1829 | if (!WinCreateWindow(hwnd,
|
---|
| 1830 | WC_STATIC,
|
---|
| 1831 | GetPString(IDS_KEYWORDSTITLETEXT),
|
---|
| 1832 | WS_VISIBLE | SS_TEXT |
|
---|
| 1833 | DT_CENTER | DT_VCENTER,
|
---|
| 1834 | 0,
|
---|
| 1835 | 0, 0, 0, hwnd, HWND_TOP, INI_KEYHDR, NULL, NULL)) {
|
---|
| 1836 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1837 | }
|
---|
| 1838 | if (!WinCreateWindow(hwnd,
|
---|
| 1839 | WC_STATIC,
|
---|
| 1840 | GetPString(IDS_DATABYTESTITLETEXT),
|
---|
| 1841 | WS_VISIBLE | SS_TEXT |
|
---|
| 1842 | DT_CENTER | DT_VCENTER,
|
---|
| 1843 | 0,
|
---|
| 1844 | 0, 0, 0, hwnd, HWND_TOP, INI_DATAHDR, NULL, NULL)) {
|
---|
| 1845 | Win_Error2(hwnd, hwnd, pszSrcFile, __LINE__, IDS_WINCREATEWINDOW);
|
---|
| 1846 | }
|
---|
[377] | 1847 |
|
---|
[551] | 1848 | inidata->hwndApp = WinWindowFromID(hwnd, INI_APPLIST);
|
---|
| 1849 | inidata->hwndKey = WinWindowFromID(hwnd, INI_KEYLIST);
|
---|
| 1850 | inidata->hwndData = WinWindowFromID(hwnd, INI_DATALIST);
|
---|
[2] | 1851 |
|
---|
[551] | 1852 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, INI_APPLIST),
|
---|
| 1853 | IniLBSubProc);
|
---|
| 1854 | WinSetWindowPtr(WinWindowFromID(hwnd, INI_APPLIST),
|
---|
| 1855 | QWL_USER, (PVOID) oldproc);
|
---|
| 1856 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, INI_KEYLIST),
|
---|
| 1857 | IniLBSubProc);
|
---|
| 1858 | WinSetWindowPtr(WinWindowFromID(hwnd, INI_KEYLIST),
|
---|
| 1859 | QWL_USER, (PVOID) oldproc);
|
---|
| 1860 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, INI_DATALIST),
|
---|
| 1861 | IniLBSubProc2);
|
---|
| 1862 | WinSetWindowPtr(WinWindowFromID(hwnd, INI_DATALIST),
|
---|
| 1863 | QWL_USER, (PVOID) oldproc);
|
---|
| 1864 | break;
|
---|
[2] | 1865 |
|
---|
[551] | 1866 | case UM_FOCUSME:
|
---|
| 1867 | case WM_SETFOCUS:
|
---|
| 1868 | if (mp2) {
|
---|
| 1869 | if (hwndMain && fAutoView)
|
---|
| 1870 | PostMsg(hwndMain, UM_LOADFILE, MPVOID, MPVOID);
|
---|
[914] | 1871 | inidata = INSTDATA(hwnd);
|
---|
| 1872 | if (!inidata)
|
---|
| 1873 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1874 | else if (hwndStatus) {
|
---|
[551] | 1875 | if (*inidata->ininame) {
|
---|
| 1876 | WinSetWindowText(hwndStatus, GetPString(IDS_INTERNALINIVIEWERTEXT));
|
---|
| 1877 | if (hwndStatus2)
|
---|
| 1878 | WinSetWindowText(hwndStatus2, inidata->ininame);
|
---|
| 1879 | }
|
---|
| 1880 | else
|
---|
| 1881 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
[2] | 1882 | }
|
---|
[551] | 1883 | }
|
---|
| 1884 | if (msg == WM_SETFOCUS)
|
---|
[2] | 1885 | break;
|
---|
[551] | 1886 | return 0;
|
---|
[2] | 1887 |
|
---|
[551] | 1888 | case UM_SELECT:
|
---|
| 1889 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, INI_APPLIST));
|
---|
| 1890 | break;
|
---|
[2] | 1891 |
|
---|
[551] | 1892 | case UM_ACTION:
|
---|
| 1893 | SetPresParams(WinWindowFromID(hwnd, INI_APPHDR),
|
---|
| 1894 | &RGBGREY,
|
---|
| 1895 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVBOLDTEXT));
|
---|
| 1896 | SetPresParams(WinWindowFromID(hwnd, INI_KEYHDR),
|
---|
| 1897 | &RGBGREY,
|
---|
| 1898 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVBOLDTEXT));
|
---|
| 1899 | SetPresParams(WinWindowFromID(hwnd, INI_DATAHDR),
|
---|
| 1900 | &RGBGREY,
|
---|
| 1901 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVBOLDTEXT));
|
---|
| 1902 | SetPresParams(WinWindowFromID(hwnd, INI_NUMAPPS),
|
---|
| 1903 | &RGBGREY,
|
---|
| 1904 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVBOLDTEXT));
|
---|
| 1905 | SetPresParams(WinWindowFromID(hwnd, INI_NUMKEYS),
|
---|
| 1906 | &RGBGREY,
|
---|
| 1907 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVBOLDTEXT));
|
---|
| 1908 | SetPresParams(WinWindowFromID(hwnd, INI_NUMDATA),
|
---|
| 1909 | &RGBGREY,
|
---|
| 1910 | &RGBBLACK, &RGBBLACK, GetPString(IDS_8HELVBOLDTEXT));
|
---|
| 1911 | if (!WinSetPresParam(WinWindowFromID(hwnd, INI_DATALIST),
|
---|
| 1912 | PP_FONTNAMESIZE,
|
---|
| 1913 | (ULONG) strlen(GetPString(IDS_5SYSTEMVIOTEXT)) + 1,
|
---|
| 1914 | (PVOID) GetPString(IDS_5SYSTEMVIOTEXT)))
|
---|
| 1915 | WinSetPresParam(WinWindowFromID(hwnd, INI_DATALIST),
|
---|
| 1916 | PP_FONTNAMESIZE,
|
---|
| 1917 | (ULONG) strlen(GetPString(IDS_10SYSTEMMONOTEXT)) + 1,
|
---|
| 1918 | (PVOID) GetPString(IDS_10SYSTEMMONOTEXT));
|
---|
| 1919 | RestorePresParams(hwnd, "IniUtil");
|
---|
| 1920 | return 0;
|
---|
[2] | 1921 |
|
---|
[551] | 1922 | case WM_PRESPARAMCHANGED:
|
---|
| 1923 | PresParamChanged(hwnd, "IniUtil", mp1, mp2);
|
---|
| 1924 | break;
|
---|
[2] | 1925 |
|
---|
[551] | 1926 | case UM_RESCAN:
|
---|
| 1927 | inidata = INSTDATA(hwnd);
|
---|
[914] | 1928 | if (!inidata)
|
---|
| 1929 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1930 | else if (mp1) {
|
---|
| 1931 | SHORT sSelect;
|
---|
| 1932 | BOOL inprofile;
|
---|
| 1933 | ULONG size;
|
---|
| 1934 | SHORT numitems = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
| 1935 | INI_APPLIST,
|
---|
| 1936 | LM_QUERYITEMCOUNT,
|
---|
| 1937 | MPVOID, MPVOID);
|
---|
| 1938 | if (!numitems) {
|
---|
| 1939 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(INI_REFRESH, 0), MPVOID);
|
---|
| 1940 | return 0;
|
---|
| 1941 | }
|
---|
| 1942 | size = 0;
|
---|
| 1943 | if (PrfQueryProfileSize(inidata->hini,
|
---|
[1009] | 1944 | (CHAR *)mp1, NULL, (PULONG) & size) && size)
|
---|
[914] | 1945 | inprofile = TRUE;
|
---|
| 1946 | else
|
---|
| 1947 | inprofile = FALSE;
|
---|
| 1948 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 1949 | INI_APPLIST,
|
---|
| 1950 | LM_SEARCHSTRING,
|
---|
| 1951 | MPFROM2SHORT(LSS_CASESENSITIVE,
|
---|
| 1952 | LIT_FIRST),
|
---|
[1009] | 1953 | MPFROMP((CHAR *)mp1));
|
---|
[914] | 1954 | if (sSelect >= 0) {
|
---|
| 1955 | if (!inprofile)
|
---|
[551] | 1956 | WinSendDlgItemMsg(hwnd,
|
---|
| 1957 | INI_APPLIST,
|
---|
[914] | 1958 | LM_DELETEITEM, MPFROMSHORT(sSelect), MPVOID);
|
---|
[1009] | 1959 | else if (!strcmp(inidata->applname, (CHAR *)mp1))
|
---|
[914] | 1960 | PostMsg(hwnd,
|
---|
| 1961 | WM_CONTROL,
|
---|
| 1962 | MPFROM2SHORT(INI_APPLIST, LN_SELECT),
|
---|
| 1963 | MPFROMLONG(WinWindowFromID(hwnd, INI_APPLIST)));
|
---|
[2] | 1964 | }
|
---|
[914] | 1965 | else if (inprofile)
|
---|
| 1966 | WinSendDlgItemMsg(hwnd,
|
---|
| 1967 | INI_APPLIST,
|
---|
| 1968 | LM_INSERTITEM,
|
---|
| 1969 | MPFROM2SHORT(LIT_SORTASCENDING, 0),
|
---|
[1009] | 1970 | MPFROMP((CHAR *)mp1));
|
---|
[914] | 1971 | if (mp2 && inidata->applname) {
|
---|
| 1972 | if (!EnumKeyNames(WinWindowFromID(hwnd, INI_KEYLIST),
|
---|
| 1973 | inidata->hini, inidata->applname))
|
---|
| 1974 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(INI_REFRESH, 0), MPVOID);
|
---|
| 1975 | }
|
---|
[551] | 1976 | }
|
---|
| 1977 | return 0;
|
---|
[2] | 1978 |
|
---|
[551] | 1979 | case UM_INITIALSIZE: /* kludge */
|
---|
[914] | 1980 | inidata = INSTDATA(hwnd);
|
---|
| 1981 | if (!inidata)
|
---|
| 1982 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 1983 | else
|
---|
[551] | 1984 | inidata->dontclose = TRUE;
|
---|
| 1985 | return 0;
|
---|
[2] | 1986 |
|
---|
[551] | 1987 | case WM_SIZE:
|
---|
| 1988 | {
|
---|
| 1989 | SHORT cx = SHORT1FROMMP(mp2);
|
---|
| 1990 | SHORT cy = SHORT2FROMMP(mp2);
|
---|
[2] | 1991 |
|
---|
[551] | 1992 | WinSetWindowPos(WinWindowFromID(hwnd, INI_APPHDR), HWND_TOP,
|
---|
| 1993 | 2, cy - 22, (cx / 4) - 4, 20, SWP_MOVE | SWP_SIZE);
|
---|
| 1994 | WinSetWindowPos(WinWindowFromID(hwnd, INI_NUMAPPS), HWND_TOP,
|
---|
| 1995 | (cx / 4) + 2, cy - 22, (cx / 4) - 4, 20,
|
---|
| 1996 | SWP_MOVE | SWP_SIZE);
|
---|
| 1997 | WinSetWindowPos(WinWindowFromID(hwnd, INI_APPLIST), HWND_TOP,
|
---|
| 1998 | 2, (cy / 2) + 2, (cx / 2) - 4, (cy / 2) - 28,
|
---|
| 1999 | SWP_MOVE | SWP_SIZE);
|
---|
| 2000 | WinSetWindowPos(WinWindowFromID(hwnd, INI_KEYHDR), HWND_TOP,
|
---|
| 2001 | (cx / 2) + 2, cy - 22, (cx / 4) - 4, 20,
|
---|
| 2002 | SWP_MOVE | SWP_SIZE);
|
---|
| 2003 | WinSetWindowPos(WinWindowFromID(hwnd, INI_NUMKEYS), HWND_TOP,
|
---|
| 2004 | (cx - (cx / 4)) + 2, cy - 22, (cx / 4) - 4, 20,
|
---|
| 2005 | SWP_MOVE | SWP_SIZE);
|
---|
| 2006 | WinSetWindowPos(WinWindowFromID(hwnd, INI_KEYLIST), HWND_TOP,
|
---|
| 2007 | (cx / 2) + 2, (cy / 2) + 2, (cx / 2) - 4, (cy / 2) - 28,
|
---|
| 2008 | SWP_MOVE | SWP_SIZE);
|
---|
| 2009 | WinSetWindowPos(WinWindowFromID(hwnd, INI_DATAHDR), HWND_TOP,
|
---|
| 2010 | 2, (cy / 2) - 22, (cx / 2) - 4, 20,
|
---|
| 2011 | SWP_MOVE | SWP_SIZE);
|
---|
| 2012 | WinSetWindowPos(WinWindowFromID(hwnd, INI_NUMDATA), HWND_TOP,
|
---|
| 2013 | (cx / 2) + 2, (cy / 2) - 22, (cx / 2) - 4, 20,
|
---|
| 2014 | SWP_MOVE | SWP_SIZE);
|
---|
| 2015 | WinSetWindowPos(WinWindowFromID(hwnd, INI_DATALIST), HWND_TOP,
|
---|
| 2016 | 2, 2, cx - 4, (cy / 2) - 28, SWP_MOVE | SWP_SIZE);
|
---|
| 2017 | }
|
---|
| 2018 | break;
|
---|
[2] | 2019 |
|
---|
[551] | 2020 | case UM_LOADFILE:
|
---|
| 2021 | /* load initial file */
|
---|
[914] | 2022 | inidata = INSTDATA(hwnd);
|
---|
| 2023 | if (!inidata)
|
---|
| 2024 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2025 | else {
|
---|
[551] | 2026 | if (mp1) {
|
---|
[1009] | 2027 | strcpy(inidata->ininame, (CHAR *)mp1);
|
---|
[551] | 2028 | inidata->hini = PrfOpenProfile(WinQueryAnchorBlock(hwnd),
|
---|
| 2029 | inidata->ininame);
|
---|
[1009] | 2030 | xfree(mp1, pszSrcFile, __LINE__);
|
---|
[2] | 2031 | }
|
---|
| 2032 | else
|
---|
[551] | 2033 | inidata->hini = HINI_USERPROFILE;
|
---|
[912] | 2034 | if (inidata->hini == NULLHANDLE) {
|
---|
| 2035 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 2036 | "PrfOpenProfile failed for %s", inidata->ininame);
|
---|
[551] | 2037 | }
|
---|
[914] | 2038 | else {
|
---|
| 2039 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2040 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2041 | WinSetWindowPos(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2042 | HWND_TOP,
|
---|
| 2043 | 0, 0, 0, 0, SWP_SHOW | SWP_ACTIVATE | SWP_ZORDER);
|
---|
| 2044 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2045 | return 0;
|
---|
| 2046 | }
|
---|
[551] | 2047 | }
|
---|
[914] | 2048 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[551] | 2049 | return 0;
|
---|
[2] | 2050 |
|
---|
[551] | 2051 | case WM_ERASEBACKGROUND:
|
---|
| 2052 | WinFillRect((HPS) mp1, (PRECTL) mp2, 0x00d0d0d0);
|
---|
| 2053 | return 0;
|
---|
[2] | 2054 |
|
---|
[551] | 2055 | case WM_PAINT:
|
---|
| 2056 | {
|
---|
| 2057 | HPS hps;
|
---|
| 2058 | RECTL rcl;
|
---|
[2] | 2059 |
|
---|
[551] | 2060 | hps = WinBeginPaint(hwnd, (HPS) 0, NULL);
|
---|
| 2061 | if (hps) {
|
---|
| 2062 | WinQueryWindowRect(hwnd, &rcl);
|
---|
| 2063 | WinFillRect(hps, &rcl, CLR_PALEGRAY);
|
---|
| 2064 | WinEndPaint(hps);
|
---|
| 2065 | /*
|
---|
| 2066 | * tell status window to paint its box
|
---|
| 2067 | */
|
---|
| 2068 | PaintRecessedWindow(WinWindowFromID(hwnd, INI_APPHDR),
|
---|
| 2069 | (HPS) 0, FALSE, FALSE);
|
---|
| 2070 | PaintRecessedWindow(WinWindowFromID(hwnd, INI_KEYHDR),
|
---|
| 2071 | (HPS) 0, FALSE, FALSE);
|
---|
| 2072 | PaintRecessedWindow(WinWindowFromID(hwnd, INI_DATAHDR),
|
---|
| 2073 | (HPS) 0, FALSE, FALSE);
|
---|
| 2074 | PaintRecessedWindow(WinWindowFromID(hwnd, INI_NUMAPPS),
|
---|
| 2075 | (HPS) 0, FALSE, FALSE);
|
---|
| 2076 | PaintRecessedWindow(WinWindowFromID(hwnd, INI_NUMKEYS),
|
---|
| 2077 | (HPS) 0, FALSE, FALSE);
|
---|
| 2078 | PaintRecessedWindow(WinWindowFromID(hwnd, INI_NUMDATA),
|
---|
| 2079 | (HPS) 0, FALSE, FALSE);
|
---|
| 2080 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2081 | if (!inidata)
|
---|
| 2082 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2083 | else if (inidata->hwndCurrent)
|
---|
[551] | 2084 | BoxWindow(inidata->hwndCurrent, (HPS) 0, CLR_RED);
|
---|
[2] | 2085 | }
|
---|
[551] | 2086 | }
|
---|
| 2087 | break;
|
---|
[2] | 2088 |
|
---|
[551] | 2089 | case WM_CONTROL:
|
---|
| 2090 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2091 | case INI_KEYLIST:
|
---|
| 2092 | case INI_APPLIST:
|
---|
| 2093 | case INI_DATALIST:
|
---|
| 2094 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 2095 | case LN_SETFOCUS:
|
---|
| 2096 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2097 | if (!inidata)
|
---|
| 2098 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2099 | else {
|
---|
[551] | 2100 | if (inidata->hwndCurrent)
|
---|
| 2101 | BoxWindow(inidata->hwndCurrent, (HPS) 0, CLR_PALEGRAY);
|
---|
| 2102 | inidata->hwndCurrent = WinWindowFromID(hwnd, SHORT1FROMMP(mp1));
|
---|
| 2103 | BoxWindow(WinWindowFromID(hwnd,
|
---|
| 2104 | SHORT1FROMMP(mp1)), (HPS) 0, CLR_RED);
|
---|
| 2105 | }
|
---|
| 2106 | break;
|
---|
[2] | 2107 |
|
---|
[551] | 2108 | case LN_ENTER:
|
---|
| 2109 | case LN_SELECT:
|
---|
| 2110 | {
|
---|
| 2111 | CHAR applname[CCHMAXPATH], keyname[CCHMAXPATH];
|
---|
| 2112 | SHORT sSelect;
|
---|
[2] | 2113 |
|
---|
[914] | 2114 | if (SHORT1FROMMP(mp1) == INI_DATALIST)
|
---|
| 2115 | break;
|
---|
| 2116 |
|
---|
[551] | 2117 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2118 | if (!inidata || !inidata->hini) {
|
---|
| 2119 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[551] | 2120 | break;
|
---|
[914] | 2121 | }
|
---|
[551] | 2122 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2123 | inidata->keyindex = inidata->appindex = 0;
|
---|
| 2124 | *applname = *keyname = *inidata->applname = *inidata->keyname = 0;
|
---|
| 2125 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 2126 | INI_APPLIST,
|
---|
| 2127 | LM_QUERYSELECTION,
|
---|
| 2128 | MPFROM2SHORT(LIT_FIRST, 0),
|
---|
| 2129 | MPVOID);
|
---|
| 2130 | if (sSelect < 0)
|
---|
| 2131 | break;
|
---|
| 2132 | inidata->appindex = sSelect;
|
---|
| 2133 | WinSendDlgItemMsg(hwnd,
|
---|
| 2134 | INI_APPLIST,
|
---|
| 2135 | LM_QUERYITEMTEXT,
|
---|
| 2136 | MPFROM2SHORT(sSelect, CCHMAXPATH - 1),
|
---|
| 2137 | MPFROMP(applname));
|
---|
| 2138 | if (SHORT1FROMMP(mp1) == INI_APPLIST) {
|
---|
| 2139 | if (!EnumKeyNames(WinWindowFromID(hwnd, INI_KEYLIST),
|
---|
| 2140 | inidata->hini, applname))
|
---|
| 2141 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(INI_REFRESH, 0), MPVOID);
|
---|
| 2142 | }
|
---|
| 2143 | else {
|
---|
| 2144 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, INI_KEYLIST,
|
---|
| 2145 | LM_QUERYSELECTION,
|
---|
| 2146 | MPFROM2SHORT(LIT_FIRST, 0),
|
---|
| 2147 | MPVOID);
|
---|
| 2148 | if (sSelect < 0)
|
---|
| 2149 | break;
|
---|
| 2150 | inidata->keyindex = sSelect;
|
---|
| 2151 | WinSendDlgItemMsg(hwnd,
|
---|
| 2152 | INI_KEYLIST,
|
---|
| 2153 | LM_QUERYITEMTEXT,
|
---|
| 2154 | MPFROM2SHORT(sSelect, CCHMAXPATH - 1),
|
---|
| 2155 | MPFROMP(keyname));
|
---|
| 2156 | if (!*keyname || !*applname)
|
---|
| 2157 | break;
|
---|
| 2158 | strcpy(inidata->keyname, keyname);
|
---|
| 2159 | strcpy(inidata->applname, applname);
|
---|
[1009] | 2160 | xfree(inidata->data, pszSrcFile, __LINE__);
|
---|
[551] | 2161 | inidata->data = GetKeyData(WinWindowFromID(hwnd,
|
---|
| 2162 | INI_DATALIST),
|
---|
| 2163 | inidata->hini,
|
---|
| 2164 | applname, keyname, &inidata->datalen);
|
---|
| 2165 | if (!inidata->data)
|
---|
| 2166 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(INI_REFRESH, 0), MPVOID);
|
---|
| 2167 | }
|
---|
| 2168 | }
|
---|
| 2169 | break;
|
---|
[2] | 2170 | }
|
---|
[551] | 2171 | break;
|
---|
| 2172 | }
|
---|
| 2173 | return 0;
|
---|
[2] | 2174 |
|
---|
[551] | 2175 | case UM_SETDIR:
|
---|
| 2176 | {
|
---|
| 2177 | SHORT num;
|
---|
| 2178 | CHAR s[81];
|
---|
[2] | 2179 |
|
---|
[551] | 2180 | num = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 2181 | INI_APPLIST,
|
---|
| 2182 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
[900] | 2183 | sprintf(s, "%u", num);
|
---|
[551] | 2184 | WinSetDlgItemText(hwnd, INI_NUMAPPS, s);
|
---|
| 2185 | num = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 2186 | INI_KEYLIST,
|
---|
| 2187 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
[900] | 2188 | sprintf(s, "%u", num);
|
---|
[551] | 2189 | WinSetDlgItemText(hwnd, INI_NUMKEYS, s);
|
---|
| 2190 | WinSetDlgItemText(hwnd, INI_NUMDATA, "0");
|
---|
| 2191 | WinSendDlgItemMsg(hwnd, INI_DATALIST, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[914] | 2192 | // inidata = WinQueryWindowPtr(hwnd, QWL_USER); // 09 Jan 08 SHL
|
---|
[551] | 2193 | }
|
---|
| 2194 | return 0;
|
---|
[2] | 2195 |
|
---|
[551] | 2196 | case UM_SETUP:
|
---|
| 2197 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2198 | if (!inidata)
|
---|
| 2199 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2200 | else {
|
---|
[551] | 2201 | PRFPROFILE prfp;
|
---|
| 2202 | CHAR sysini[CCHMAXPATH + 81];
|
---|
| 2203 | CHAR userini[CCHMAXPATH];
|
---|
[2] | 2204 |
|
---|
[551] | 2205 | memset(&prfp, 0, sizeof(PRFPROFILE));
|
---|
| 2206 | prfp.cchUserName = CCHMAXPATH;
|
---|
| 2207 | prfp.cchSysName = CCHMAXPATH;
|
---|
| 2208 | prfp.pszUserName = (PSZ) userini;
|
---|
| 2209 | prfp.pszSysName = (PSZ) sysini;
|
---|
| 2210 | if (PrfQueryProfile(WinQueryAnchorBlock(hwnd), &prfp)) {
|
---|
| 2211 | if (inidata->hini == HINI_SYSTEMPROFILE)
|
---|
| 2212 | strcpy(inidata->ininame, sysini);
|
---|
| 2213 | else if (inidata->hini == HINI_USERPROFILE)
|
---|
| 2214 | strcpy(inidata->ininame, userini);
|
---|
| 2215 | sprintf(sysini, GetPString(IDS_INITITLETEXT), inidata->ininame);
|
---|
| 2216 | WinSetWindowText(WinQueryWindow(hwnd, QW_PARENT), sysini);
|
---|
| 2217 | if (WinQueryWindow(hwnd, QW_PARENT) ==
|
---|
| 2218 | WinQueryActiveWindow(WinQueryWindow
|
---|
| 2219 | (WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2220 | QW_PARENT))) {
|
---|
| 2221 | if (hwndStatus)
|
---|
| 2222 | WinSetWindowText(hwndStatus,
|
---|
| 2223 | GetPString(IDS_INTERNALINIVIEWERTEXT));
|
---|
| 2224 | if (hwndStatus2)
|
---|
| 2225 | WinSetWindowText(hwndStatus2, inidata->ininame);
|
---|
| 2226 | }
|
---|
[2] | 2227 | }
|
---|
| 2228 | else
|
---|
[551] | 2229 | WinSetWindowText(WinQueryWindow(hwnd, QW_PARENT),
|
---|
| 2230 | GetPString(IDS_INIQUERYPRFFAILEDTEXT));
|
---|
[914] | 2231 | return 0;
|
---|
[551] | 2232 | }
|
---|
[914] | 2233 |
|
---|
| 2234 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
[551] | 2235 | return 0;
|
---|
[2] | 2236 |
|
---|
[551] | 2237 | case WM_CHAR:
|
---|
| 2238 | if (!(SHORT1FROMMP(mp1) & KC_KEYUP)) {
|
---|
| 2239 | if (SHORT1FROMMP(mp1) & KC_VIRTUALKEY) {
|
---|
| 2240 | switch (SHORT2FROMMP(mp2)) {
|
---|
| 2241 | case VK_DELETE:
|
---|
| 2242 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2243 | if (!inidata)
|
---|
| 2244 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2245 | else {
|
---|
| 2246 | SHORT cmd = inidata->hwndCurrent &&
|
---|
| 2247 | WinQueryWindowUShort(inidata->hwndCurrent, QWS_ID) ==
|
---|
| 2248 | INI_APPLIST ?
|
---|
| 2249 | INI_DELETEAPP :INI_DELETEKEY;
|
---|
[551] | 2250 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(cmd, 0), MPVOID);
|
---|
| 2251 | }
|
---|
| 2252 | break;
|
---|
| 2253 | }
|
---|
[2] | 2254 | }
|
---|
[551] | 2255 | }
|
---|
| 2256 | break;
|
---|
[2] | 2257 |
|
---|
[551] | 2258 | case WM_COMMAND:
|
---|
| 2259 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 2260 | case IDM_FINDNEXT:
|
---|
| 2261 | case IDM_FINDFIRST:
|
---|
| 2262 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2263 | if (!inidata)
|
---|
| 2264 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2265 | else if (inidata->hwndCurrent) {
|
---|
| 2266 | STRINGINPARMS sip;
|
---|
| 2267 | static CHAR tofind[258] = "";
|
---|
| 2268 | SHORT x, z;
|
---|
[2] | 2269 |
|
---|
[914] | 2270 | if (SHORT1FROMMP(mp1) == IDM_FINDFIRST || !*tofind) {
|
---|
| 2271 | z = LIT_FIRST;
|
---|
| 2272 | memset(&sip, 0, sizeof(sip));
|
---|
| 2273 | sip.help = GetPString(IDS_INISEARCHHELPTEXT);
|
---|
| 2274 | sip.prompt = GetPString(IDS_INISEARCHPROMPTTEXT);
|
---|
| 2275 | sip.inputlen = 257;
|
---|
| 2276 | sip.ret = tofind;
|
---|
| 2277 | sip.title = GetPString(IDS_INISEARCHTITLETEXT);
|
---|
| 2278 | if (WinDlgBox(HWND_DESKTOP,
|
---|
| 2279 | hwnd,
|
---|
| 2280 | InputDlgProc, FM3ModHandle, STR_FRAME, &sip)) {
|
---|
| 2281 | rstrip(tofind);
|
---|
| 2282 | if (!*tofind) {
|
---|
| 2283 | DosBeep(50, 100);
|
---|
| 2284 | break;
|
---|
[551] | 2285 | }
|
---|
| 2286 | }
|
---|
| 2287 | else
|
---|
[914] | 2288 | break;
|
---|
[551] | 2289 | }
|
---|
[914] | 2290 | else {
|
---|
| 2291 | z = (SHORT) WinSendMsg(inidata->hwndCurrent,
|
---|
| 2292 | LM_QUERYSELECTION,
|
---|
| 2293 | MPFROM2SHORT(LIT_CURSOR, 0), MPVOID);
|
---|
| 2294 | if (z < 0)
|
---|
| 2295 | z = LIT_FIRST;
|
---|
| 2296 | }
|
---|
| 2297 | x = (SHORT) WinSendMsg(inidata->hwndCurrent,
|
---|
| 2298 | LM_SEARCHSTRING,
|
---|
| 2299 | MPFROM2SHORT(LSS_SUBSTRING, z),
|
---|
| 2300 | MPFROMP(tofind));
|
---|
| 2301 | if (x >= 0 && x > z) {
|
---|
| 2302 | WinSendMsg(inidata->hwndCurrent,
|
---|
| 2303 | LM_SETTOPINDEX, MPFROM2SHORT(x, 0), MPVOID);
|
---|
| 2304 | WinSendMsg(inidata->hwndCurrent,
|
---|
| 2305 | LM_SELECTITEM,
|
---|
| 2306 | MPFROM2SHORT(x, 0), MPFROM2SHORT(TRUE, 0));
|
---|
| 2307 | }
|
---|
| 2308 | else
|
---|
| 2309 | DosBeep(250, 100);
|
---|
[551] | 2310 | }
|
---|
| 2311 | break;
|
---|
[2] | 2312 |
|
---|
[551] | 2313 | case IDM_FILTER:
|
---|
| 2314 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2315 | if (!inidata)
|
---|
| 2316 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2317 | else {
|
---|
| 2318 | SHORT numitems = (SHORT)WinSendDlgItemMsg(hwnd,
|
---|
| 2319 | INI_APPLIST,
|
---|
| 2320 | LM_QUERYITEMCOUNT,
|
---|
| 2321 | MPVOID, MPVOID);
|
---|
[551] | 2322 | if (numitems)
|
---|
| 2323 | WinDlgBox(HWND_DESKTOP,
|
---|
| 2324 | hwnd,
|
---|
| 2325 | FilterIniProc, FM3ModHandle, IAF_FRAME, (PVOID) inidata);
|
---|
| 2326 | else
|
---|
| 2327 | DosBeep(50, 100);
|
---|
| 2328 | }
|
---|
| 2329 | break;
|
---|
[2] | 2330 |
|
---|
[551] | 2331 | case IDM_COPY:
|
---|
| 2332 | case IDM_INFO:
|
---|
| 2333 | case IDM_MOVE:
|
---|
[914] | 2334 | inidata = INSTDATA(hwnd);
|
---|
[551] | 2335 | if (!inidata || !*inidata->ininame)
|
---|
[914] | 2336 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2337 | else if (mp2) {
|
---|
| 2338 | INIREC *inirec = xmallocz(sizeof(INIREC), pszSrcFile, __LINE__);
|
---|
[551] | 2339 | if (inirec) {
|
---|
| 2340 | *inirec = *(INIREC *) mp2;
|
---|
| 2341 | inirec->hwndDlg = hwnd;
|
---|
| 2342 | inirec->confirm = inidata->confirm;
|
---|
| 2343 | strcpy(inirec->filename1, inidata->ininame);
|
---|
| 2344 | if (_beginthread(CopyIniThread, NULL, 122880, (PVOID) inirec) == -1) {
|
---|
| 2345 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2346 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
[1009] | 2347 | xfree(inirec, pszSrcFile, __LINE__);
|
---|
[551] | 2348 | }
|
---|
| 2349 | }
|
---|
| 2350 | }
|
---|
| 2351 | break;
|
---|
[2] | 2352 |
|
---|
[551] | 2353 | case IDM_COMPARE:
|
---|
[914] | 2354 | inidata = INSTDATA(hwnd);
|
---|
[551] | 2355 | if (!inidata || !*inidata->ininame)
|
---|
[914] | 2356 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2357 | else if (mp2) {
|
---|
| 2358 | INIREC *inirec = xmalloc(sizeof(INIREC), pszSrcFile, __LINE__);
|
---|
[551] | 2359 | if (inirec) {
|
---|
[1009] | 2360 | strcpy(inirec->filename2, (CHAR *)(mp2));
|
---|
[551] | 2361 | strcpy(inirec->filename1, inidata->ininame);
|
---|
| 2362 | inirec->hwndDlg = hwnd;
|
---|
| 2363 | if (_beginthread(CompareIniThread, NULL, 122880, (PVOID) inirec) ==
|
---|
| 2364 | -1) {
|
---|
| 2365 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2366 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
[1009] | 2367 | xfree(inirec, pszSrcFile, __LINE__);
|
---|
[551] | 2368 | }
|
---|
| 2369 | }
|
---|
| 2370 | }
|
---|
| 2371 | break;
|
---|
[2] | 2372 |
|
---|
[551] | 2373 | case INI_COPYAPP:
|
---|
| 2374 | case INI_COPYKEY:
|
---|
| 2375 | case INI_RENAMEAPP:
|
---|
| 2376 | case INI_RENAMEKEY:
|
---|
[914] | 2377 | inidata = INSTDATA(hwnd);
|
---|
| 2378 | if (!inidata) {
|
---|
| 2379 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2380 | break;
|
---|
| 2381 | }
|
---|
| 2382 | if (!*inidata->ininame ||
|
---|
[551] | 2383 | !*inidata->applname ||
|
---|
| 2384 | (!*inidata->keyname &&
|
---|
| 2385 | (SHORT1FROMMP(mp1) == INI_RENAMEKEY ||
|
---|
| 2386 | SHORT1FROMMP(mp1) == INI_COPYKEY)))
|
---|
| 2387 | break;
|
---|
| 2388 | {
|
---|
[914] | 2389 | INIREC *inirec = xmallocz(sizeof(INIREC), pszSrcFile, __LINE__);
|
---|
[551] | 2390 | if (inirec) {
|
---|
| 2391 | inirec->size = sizeof(INIREC);
|
---|
| 2392 | inirec->hwndDlg = hwnd;
|
---|
| 2393 | inirec->confirm = inidata->confirm;
|
---|
| 2394 | inirec->action = (SHORT1FROMMP(mp1) == INI_COPYAPP ||
|
---|
| 2395 | SHORT1FROMMP(mp1) == INI_COPYKEY) ?
|
---|
| 2396 | IDM_COPY : IDM_MOVE;
|
---|
| 2397 | strcpy(inirec->filename1, inidata->ininame);
|
---|
| 2398 | strcpy(inirec->filename2, inidata->ininame);
|
---|
| 2399 | if (SHORT1FROMMP(mp1) == INI_COPYKEY ||
|
---|
| 2400 | SHORT1FROMMP(mp1) == INI_RENAMEKEY)
|
---|
| 2401 | strcpy(inirec->key, inidata->keyname);
|
---|
| 2402 | strcpy(inirec->app, inidata->applname);
|
---|
| 2403 | if (!WinDlgBox(HWND_DESKTOP,
|
---|
| 2404 | hwnd,
|
---|
| 2405 | IntraIniProc,
|
---|
| 2406 | FM3ModHandle, INII_FRAME, (PVOID) inirec)) {
|
---|
[1009] | 2407 | xfree(inirec, pszSrcFile, __LINE__);
|
---|
[551] | 2408 | break;
|
---|
| 2409 | }
|
---|
| 2410 | if (_beginthread(CopyIniThread, NULL, 122880, (PVOID) inirec) == -1) {
|
---|
| 2411 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2412 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
[1009] | 2413 | xfree(inirec, pszSrcFile, __LINE__);
|
---|
[551] | 2414 | }
|
---|
| 2415 | }
|
---|
| 2416 | }
|
---|
| 2417 | break;
|
---|
[2] | 2418 |
|
---|
[551] | 2419 | case INI_BACKUPINI:
|
---|
| 2420 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2421 | if (!inidata)
|
---|
| 2422 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2423 | else if (*inidata->ininame) {
|
---|
| 2424 | // 09 Jan 08 SHL fixme to complain
|
---|
[551] | 2425 | CHAR filename[CCHMAXPATH], *p;
|
---|
[2] | 2426 |
|
---|
[551] | 2427 | strcpy(filename, inidata->ininame);
|
---|
| 2428 | p = filename;
|
---|
| 2429 | while (*p) {
|
---|
| 2430 | if (*p == '/')
|
---|
| 2431 | *p = '\\';
|
---|
| 2432 | p++;
|
---|
| 2433 | }
|
---|
| 2434 | p = strrchr(filename, '\\');
|
---|
| 2435 | if (p) {
|
---|
| 2436 | p++;
|
---|
| 2437 | *p = 0;
|
---|
| 2438 | }
|
---|
| 2439 | else
|
---|
| 2440 | *filename = 0;
|
---|
| 2441 | strcat(filename, "*.INI");
|
---|
| 2442 | if (export_filename(hwnd, filename, TRUE)) {
|
---|
[2] | 2443 |
|
---|
[551] | 2444 | PPRFPROFILE prfp;
|
---|
[2] | 2445 |
|
---|
[551] | 2446 | prfp = xmallocz(sizeof(PRFPROFILE), pszSrcFile, __LINE__);
|
---|
| 2447 | if (prfp) {
|
---|
| 2448 | prfp->pszUserName =
|
---|
| 2449 | xstrdup(inidata->ininame, pszSrcFile, __LINE__);
|
---|
| 2450 | if (!prfp->pszUserName)
|
---|
[1009] | 2451 | xfree(prfp, pszSrcFile, __LINE__);
|
---|
[551] | 2452 | else {
|
---|
| 2453 | prfp->cchUserName = strlen(prfp->pszUserName);
|
---|
| 2454 | prfp->pszSysName = xstrdup(filename, pszSrcFile, __LINE__);
|
---|
| 2455 | if (!prfp->pszSysName) {
|
---|
[1009] | 2456 | xfree(prfp->pszUserName, pszSrcFile, __LINE__);
|
---|
| 2457 | xfree(prfp, pszSrcFile, __LINE__);
|
---|
[551] | 2458 | }
|
---|
| 2459 | else {
|
---|
| 2460 | prfp->cchSysName = strlen(prfp->pszSysName);
|
---|
| 2461 | if (_beginthread(BackupIniThread, NULL, 122880, (PVOID) prfp)
|
---|
| 2462 | == -1) {
|
---|
| 2463 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 2464 | GetPString(IDS_COULDNTSTARTTHREADTEXT));
|
---|
[1009] | 2465 | xfree(prfp->pszSysName, pszSrcFile, __LINE__);
|
---|
| 2466 | xfree(prfp->pszUserName, pszSrcFile, __LINE__);
|
---|
| 2467 | xfree(prfp, pszSrcFile, __LINE__);
|
---|
[551] | 2468 | }
|
---|
| 2469 | else
|
---|
[771] | 2470 | DosSleep(100); //05 Aug 07 GKY 250
|
---|
[551] | 2471 | }
|
---|
| 2472 | }
|
---|
| 2473 | }
|
---|
| 2474 | }
|
---|
| 2475 | }
|
---|
| 2476 | break;
|
---|
[2] | 2477 |
|
---|
[551] | 2478 | case INI_CHANGEINI:
|
---|
| 2479 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2480 | if (!inidata)
|
---|
| 2481 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2482 | else {
|
---|
[551] | 2483 | if (WinDlgBox(HWND_DESKTOP,
|
---|
| 2484 | hwnd,
|
---|
| 2485 | ChangeIniProc,
|
---|
| 2486 | FM3ModHandle, INIR_FRAME, (PVOID) inidata->ininame)) {
|
---|
| 2487 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2488 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2489 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2490 | }
|
---|
| 2491 | }
|
---|
| 2492 | break;
|
---|
[2] | 2493 |
|
---|
[551] | 2494 | case INI_SWAPINI:
|
---|
| 2495 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2496 | if (!inidata)
|
---|
| 2497 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2498 | else {
|
---|
[551] | 2499 | if (WinDlgBox(HWND_DESKTOP,
|
---|
| 2500 | hwnd,
|
---|
| 2501 | SwapIniProc,
|
---|
| 2502 | FM3ModHandle, INIR_FRAME, (PVOID) inidata->ininame)) {
|
---|
| 2503 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2504 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2505 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2506 | }
|
---|
| 2507 | }
|
---|
| 2508 | break;
|
---|
[2] | 2509 |
|
---|
[551] | 2510 | case IDM_NEXTWINDOW:
|
---|
| 2511 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2512 | if (!inidata)
|
---|
| 2513 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2514 | else {
|
---|
[551] | 2515 | inidata->currid++;
|
---|
| 2516 | if (inidata->currid > INI_DATALIST)
|
---|
| 2517 | inidata->currid = INI_APPLIST;
|
---|
| 2518 | }
|
---|
| 2519 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, inidata->currid));
|
---|
| 2520 | break;
|
---|
[2] | 2521 |
|
---|
[551] | 2522 | case IDM_PREVWINDOW:
|
---|
| 2523 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2524 | if (!inidata)
|
---|
| 2525 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2526 | else {
|
---|
[551] | 2527 | inidata->currid--;
|
---|
| 2528 | if (inidata->currid < INI_APPLIST)
|
---|
| 2529 | inidata->currid = INI_DATALIST;
|
---|
| 2530 | }
|
---|
| 2531 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, inidata->currid));
|
---|
| 2532 | break;
|
---|
[2] | 2533 |
|
---|
[551] | 2534 | case INI_CONFIRM:
|
---|
| 2535 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2536 | if (!inidata)
|
---|
| 2537 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2538 | else {
|
---|
[551] | 2539 | inidata->confirm = (inidata->confirm) ? FALSE : TRUE;
|
---|
| 2540 | WinCheckMenuItem(inidata->hwndMenu, INI_CONFIRM, inidata->confirm);
|
---|
[2] | 2541 |
|
---|
[551] | 2542 | }
|
---|
| 2543 | break;
|
---|
[2] | 2544 |
|
---|
[551] | 2545 | case INI_EDITENTRY:
|
---|
| 2546 | case INI_ADDENTRY:
|
---|
| 2547 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2548 | if (!inidata)
|
---|
| 2549 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2550 | else {
|
---|
[551] | 2551 | inidata->edit = (SHORT1FROMMP(mp1) == INI_EDITENTRY);
|
---|
| 2552 | WinDlgBox(HWND_DESKTOP,
|
---|
| 2553 | hwnd, AddIniProc, FM3ModHandle, IAD_FRAME, (PVOID) inidata);
|
---|
| 2554 | }
|
---|
| 2555 | break;
|
---|
[2] | 2556 |
|
---|
[551] | 2557 | case INI_OTHERPROFILE:
|
---|
| 2558 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2559 | if (!inidata)
|
---|
| 2560 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2561 | else {
|
---|
[551] | 2562 | CHAR filename[CCHMAXPATH + 81], *p;
|
---|
[847] | 2563 | FILESTATUS3 fsa;
|
---|
[551] | 2564 | HINI hINI;
|
---|
[2] | 2565 |
|
---|
[551] | 2566 | strcpy(filename, inidata->ininame);
|
---|
| 2567 | p = filename;
|
---|
| 2568 | while (*p) {
|
---|
| 2569 | if (*p == '/')
|
---|
| 2570 | *p = '\\';
|
---|
| 2571 | p++;
|
---|
| 2572 | }
|
---|
| 2573 | p = strrchr(filename, '\\');
|
---|
| 2574 | if (p) {
|
---|
| 2575 | p++;
|
---|
| 2576 | *p = 0;
|
---|
| 2577 | }
|
---|
| 2578 | else
|
---|
| 2579 | *filename = 0;
|
---|
| 2580 | strcat(filename, "*.INI");
|
---|
| 2581 | if (insert_filename(hwnd,
|
---|
| 2582 | filename,
|
---|
| 2583 | TRUE,
|
---|
| 2584 | TRUE) &&
|
---|
| 2585 | *filename &&
|
---|
[847] | 2586 | !DosQueryPathInfo(filename, FIL_STANDARD, &fsa, sizeof(fsa))) {
|
---|
[551] | 2587 | hINI = PrfOpenProfile(WinQueryAnchorBlock(hwnd), filename);
|
---|
[912] | 2588 | if (hINI == NULLHANDLE) {
|
---|
[551] | 2589 | Win_Error(hwnd, hwnd, __FILE__, __LINE__,
|
---|
| 2590 | GetPString(IDS_INICANTOPENINITEXT), filename);
|
---|
| 2591 | }
|
---|
| 2592 | else {
|
---|
| 2593 | if (*inidata->ininame) {
|
---|
| 2594 | if (inidata->hini)
|
---|
[914] | 2595 | CloseProfile(inidata->hini, FALSE);
|
---|
[551] | 2596 | *inidata->ininame = 0;
|
---|
| 2597 | }
|
---|
| 2598 | inidata->hini = hINI;
|
---|
| 2599 | strcpy(inidata->ininame, filename);
|
---|
| 2600 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2601 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2602 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2603 | }
|
---|
| 2604 | }
|
---|
| 2605 | }
|
---|
| 2606 | break;
|
---|
[2] | 2607 |
|
---|
[551] | 2608 | case INI_USERPROFILE:
|
---|
| 2609 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2610 | if (!inidata)
|
---|
| 2611 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2612 | else {
|
---|
| 2613 | if (inidata->hini && *inidata->ininame)
|
---|
| 2614 | CloseProfile(inidata->hini, FALSE);
|
---|
[551] | 2615 | *inidata->ininame = 0;
|
---|
| 2616 | inidata->hini = HINI_USERPROFILE;
|
---|
| 2617 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2618 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2619 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2620 | }
|
---|
| 2621 | break;
|
---|
[2] | 2622 |
|
---|
[551] | 2623 | case INI_SYSTEMPROFILE:
|
---|
| 2624 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2625 | if (!inidata)
|
---|
| 2626 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2627 | else {
|
---|
| 2628 | if (inidata->hini && *inidata->ininame)
|
---|
| 2629 | CloseProfile(inidata->hini, FALSE);
|
---|
[551] | 2630 | *inidata->ininame = 0;
|
---|
| 2631 | inidata->hini = HINI_SYSTEMPROFILE;
|
---|
| 2632 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
| 2633 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2634 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2635 | }
|
---|
| 2636 | break;
|
---|
[2] | 2637 |
|
---|
[551] | 2638 | case INI_REFRESH:
|
---|
| 2639 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2640 | if (!inidata)
|
---|
| 2641 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2642 | else {
|
---|
[551] | 2643 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2644 | EnumAppNames(WinWindowFromID(hwnd, INI_APPLIST), inidata->hini);
|
---|
| 2645 | }
|
---|
| 2646 | break;
|
---|
[2] | 2647 |
|
---|
[551] | 2648 | case INI_DELETEKEY:
|
---|
| 2649 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2650 | if (!inidata)
|
---|
| 2651 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2652 | else if (*inidata->applname && *inidata->keyname) {
|
---|
[2] | 2653 |
|
---|
[551] | 2654 | SHORT keyindex = inidata->keyindex;
|
---|
[2] | 2655 |
|
---|
[551] | 2656 | if (inidata->confirm && saymsg(MB_YESNO,
|
---|
| 2657 | hwnd,
|
---|
| 2658 | GetPString(IDS_CONFIRMTEXT),
|
---|
| 2659 | GetPString(IDS_INIDELETEKEYTEXT),
|
---|
| 2660 | inidata->keyname) == MBID_NO)
|
---|
| 2661 | break;
|
---|
| 2662 | PrfWriteProfileData(inidata->hini,
|
---|
| 2663 | inidata->applname, inidata->keyname, NULL, 0L);
|
---|
| 2664 | *inidata->keyname = 0;
|
---|
| 2665 | WinSendDlgItemMsg(hwnd,
|
---|
| 2666 | INI_KEYLIST,
|
---|
| 2667 | LM_DELETEITEM, MPFROM2SHORT(keyindex, 0), MPVOID);
|
---|
| 2668 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2669 | sSel = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 2670 | INI_KEYLIST,
|
---|
| 2671 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
| 2672 | if (!sSel)
|
---|
| 2673 | WinSendMsg(hwnd, INI_DELETEAPP, MPVOID, MPVOID);
|
---|
| 2674 | else {
|
---|
| 2675 | sSel = min(keyindex, sSel - 1);
|
---|
| 2676 | WinSendDlgItemMsg(hwnd,
|
---|
| 2677 | INI_KEYLIST,
|
---|
| 2678 | LM_SELECTITEM,
|
---|
| 2679 | MPFROMSHORT(sSel), MPFROMSHORT(TRUE));
|
---|
| 2680 | }
|
---|
| 2681 | }
|
---|
| 2682 | break;
|
---|
[2] | 2683 |
|
---|
[551] | 2684 | case INI_DELETEAPP:
|
---|
| 2685 | inidata = INSTDATA(hwnd);
|
---|
[914] | 2686 | if (!inidata)
|
---|
| 2687 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2688 | // 09 Jan 08 SHL fixme to complain?
|
---|
| 2689 | else if (*inidata->applname) {
|
---|
[2] | 2690 |
|
---|
[551] | 2691 | SHORT appindex = inidata->appindex;
|
---|
[2] | 2692 |
|
---|
[551] | 2693 | if (inidata->confirm && saymsg(MB_YESNO,
|
---|
| 2694 | hwnd,
|
---|
| 2695 | GetPString(IDS_CONFIRMTEXT),
|
---|
| 2696 | GetPString(IDS_INIDELETEAPPTEXT),
|
---|
| 2697 | inidata->applname) == MBID_NO)
|
---|
| 2698 | break;
|
---|
| 2699 | PrfWriteProfileData(inidata->hini, inidata->applname, NULL, NULL, 0L);
|
---|
| 2700 | *inidata->applname = *inidata->keyname = 0;
|
---|
| 2701 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2702 | WinSendDlgItemMsg(hwnd, INI_KEYLIST, LM_DELETEALL, MPVOID, MPVOID);
|
---|
| 2703 | WinSendDlgItemMsg(hwnd,
|
---|
| 2704 | INI_APPLIST,
|
---|
| 2705 | LM_DELETEITEM, MPFROM2SHORT(appindex, 0), MPVOID);
|
---|
| 2706 | WinSendMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 2707 | sSel = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 2708 | INI_APPLIST,
|
---|
| 2709 | LM_QUERYITEMCOUNT, MPVOID, MPVOID);
|
---|
| 2710 | if (sSel) {
|
---|
| 2711 | sSel = min(appindex, sSel - 1);
|
---|
| 2712 | WinSendDlgItemMsg(hwnd,
|
---|
| 2713 | INI_APPLIST,
|
---|
| 2714 | LM_SELECTITEM,
|
---|
| 2715 | MPFROMSHORT(sSel), MPFROMSHORT(TRUE));
|
---|
| 2716 | }
|
---|
| 2717 | }
|
---|
| 2718 | break;
|
---|
[2] | 2719 |
|
---|
[551] | 2720 | case DID_OK:
|
---|
| 2721 | case DID_CANCEL:
|
---|
| 2722 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
| 2723 | break;
|
---|
[2] | 2724 |
|
---|
[551] | 2725 | case IDM_HELP:
|
---|
| 2726 | if (hwndHelp)
|
---|
| 2727 | WinSendMsg(hwndHelp,
|
---|
| 2728 | HM_DISPLAY_HELP,
|
---|
| 2729 | MPFROM2SHORT(HELP_INI, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
| 2730 | break;
|
---|
[2] | 2731 |
|
---|
[551] | 2732 | case IDM_ABOUT:
|
---|
| 2733 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
| 2734 | hwnd,
|
---|
| 2735 | GetPString(IDS_VIEWABOUTTITLETEXT),
|
---|
| 2736 | GetPString(IDS_INIABOUTTEXT));
|
---|
| 2737 | break;
|
---|
| 2738 | }
|
---|
| 2739 | return 0;
|
---|
[2] | 2740 |
|
---|
[551] | 2741 | case WM_CLOSE:
|
---|
| 2742 | if (ParentIsDesktop(WinQueryWindow(hwnd, QW_PARENT), (HWND) 0)) {
|
---|
[2] | 2743 |
|
---|
[551] | 2744 | SWP swp;
|
---|
[2] | 2745 |
|
---|
[551] | 2746 | WinQueryWindowPos(WinQueryWindow(hwnd, QW_PARENT), &swp);
|
---|
| 2747 | if (!(swp.fl & (SWP_HIDE | SWP_MINIMIZE)))
|
---|
| 2748 | WinStoreWindowPos(FM2Str,
|
---|
| 2749 | "INIWindowPos", WinQueryWindow(hwnd, QW_PARENT));
|
---|
[914] | 2750 | // inidata = WinQueryWindowPtr(hwnd, QWL_USER); // 09 Jan 08 SHL
|
---|
[551] | 2751 | }
|
---|
| 2752 | WinDestroyWindow(WinQueryWindow(hwnd, QW_PARENT));
|
---|
| 2753 | return 0;
|
---|
[2] | 2754 |
|
---|
[551] | 2755 | case WM_DESTROY:
|
---|
| 2756 | {
|
---|
| 2757 | BOOL dontclose = FALSE;
|
---|
[2] | 2758 |
|
---|
[914] | 2759 | inidata = INSTDATA(hwnd);
|
---|
| 2760 | if (!inidata)
|
---|
| 2761 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
| 2762 | else {
|
---|
[551] | 2763 | dontclose = inidata->dontclose;
|
---|
[914] | 2764 | if (inidata->hini != NULLHANDLE && *inidata->ininame)
|
---|
| 2765 | CloseProfile(inidata->hini, FALSE);
|
---|
[1009] | 2766 | xfree(inidata->data, pszSrcFile, __LINE__);
|
---|
[551] | 2767 | if (inidata->hwndPopup)
|
---|
| 2768 | WinDestroyWindow(inidata->hwndPopup);
|
---|
[1009] | 2769 | xfree(inidata, pszSrcFile, __LINE__);
|
---|
[2] | 2770 | }
|
---|
[551] | 2771 | if (!dontclose &&
|
---|
| 2772 | ParentIsDesktop(hwnd, WinQueryWindow(WinQueryWindow(hwnd,
|
---|
| 2773 | QW_PARENT),
|
---|
| 2774 | QW_PARENT))) {
|
---|
| 2775 | if (!PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID))
|
---|
| 2776 | DosExit(EXIT_PROCESS, 1);
|
---|
| 2777 | }
|
---|
| 2778 | }
|
---|
| 2779 | break;
|
---|
[2] | 2780 | }
|
---|
[551] | 2781 | return WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 2782 | }
|
---|
[793] | 2783 |
|
---|
| 2784 | #pragma alloc_text(INIS,EnumAppNames,GetKeyData,EnumKeyNames,AddIniProc,IniProc,BackupIniThread)
|
---|
| 2785 | #pragma alloc_text(INIS,ChangeIniProc,SwapIniProc,IniLBSubProc,IniLBSubProc2,CopyIniThread)
|
---|
| 2786 | #pragma alloc_text(INIS,IntraIniProc,FilterIniProc)
|
---|
| 2787 | #pragma alloc_text(STARTUP,StartIniEditor)
|
---|