source: trunk/dll/inis.c@ 1038

Last change on this file since 1038 was 1038, checked in by Gregg Young, 17 years ago

More fortify cleanup

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