source: trunk/dll/inis.c@ 1009

Last change on this file since 1009 was 1009, checked in by Steven Levine, 17 years ago

Add xfree xstrdup Fortify support
Add MT capable Fortify scope logic

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