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