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