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