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