1 |
|
---|
2 | /**************************************************************************************
|
---|
3 |
|
---|
4 | $Id: assoc.c 1163 2008-09-05 21:43:52Z jbs $
|
---|
5 |
|
---|
6 | Copyright (c) 1993-98 M. Kimes
|
---|
7 | Copyright (c) 2004, 2008 Steven H.Levine
|
---|
8 |
|
---|
9 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
10 | 14 Jul 06 SHL Use Runtime_Error
|
---|
11 | 29 Jul 06 SHL Use xfgets, xfgets_bstripcr
|
---|
12 | 10 Sep 06 GKY Add Move to last, Okay adds if new, Replace Current in Listbox Dialog
|
---|
13 | 19 Oct 06 GKY Rework replace logic
|
---|
14 | 18 Feb 07 GKY Move error messages etc to string file
|
---|
15 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
16 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
17 | 06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
|
---|
18 | 29 Feb 08 GKY Changes to enable user settable command line length
|
---|
19 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
20 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
|
---|
21 | 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
|
---|
22 |
|
---|
23 | **************************************************************************************/
|
---|
24 |
|
---|
25 | #include <stdlib.h>
|
---|
26 | #include <string.h>
|
---|
27 | #include <share.h>
|
---|
28 |
|
---|
29 | #define INCL_DOS
|
---|
30 | #define INCL_WIN
|
---|
31 | #define INCL_PM
|
---|
32 | #define INCL_WINHOOKS
|
---|
33 | #define INCL_LONGLONG // dircnrs.h
|
---|
34 |
|
---|
35 | #include "fm3dlg.h"
|
---|
36 | #include "fm3str.h"
|
---|
37 | #include "pathutil.h" // BldQuotedFileName
|
---|
38 | #include "errutil.h" // Dos_Error...
|
---|
39 | #include "strutil.h" // GetPString
|
---|
40 | #include "assoc.h"
|
---|
41 | #include "fm3dll.h"
|
---|
42 | #include "fortify.h"
|
---|
43 |
|
---|
44 | #pragma data_seg(DATA1)
|
---|
45 |
|
---|
46 | typedef struct
|
---|
47 | {
|
---|
48 | LONG offset;
|
---|
49 | ULONG flags;
|
---|
50 | PSZ pszCmdLine;
|
---|
51 | CHAR mask[CCHMAXPATH];
|
---|
52 | CHAR sig[CCHMAXPATH];
|
---|
53 | }
|
---|
54 | ASSOC;
|
---|
55 |
|
---|
56 | typedef struct LINKASSOC
|
---|
57 | {
|
---|
58 | CHAR *mask;
|
---|
59 | PSZ pszCmdLine;
|
---|
60 | CHAR *sig;
|
---|
61 | LONG offset;
|
---|
62 | ULONG flags;
|
---|
63 | struct LINKASSOC *prev;
|
---|
64 | struct LINKASSOC *next;
|
---|
65 | }
|
---|
66 | LINKASSOC;
|
---|
67 |
|
---|
68 | static LINKASSOC *asshead = NULL, *asstail = NULL;
|
---|
69 | static BOOL assloaded = FALSE, replace = FALSE;
|
---|
70 |
|
---|
71 | static PSZ pszSrcFile = __FILE__;
|
---|
72 |
|
---|
73 | static VOID load_associations(VOID);
|
---|
74 | static VOID save_associations(VOID);
|
---|
75 |
|
---|
76 | MRESULT EXPENTRY AssocTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
77 | {
|
---|
78 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
79 | static BOOL emphasized = FALSE;
|
---|
80 |
|
---|
81 | switch (msg) {
|
---|
82 | case DM_DRAGOVER:
|
---|
83 | if (!emphasized) {
|
---|
84 | emphasized = TRUE;
|
---|
85 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
86 | }
|
---|
87 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
88 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
89 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
90 |
|
---|
91 | case DM_DRAGLEAVE:
|
---|
92 | if (emphasized) {
|
---|
93 | emphasized = FALSE;
|
---|
94 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
95 | }
|
---|
96 | break;
|
---|
97 |
|
---|
98 | case DM_DROPHELP:
|
---|
99 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_ASSOCDROPHELPTEXT));
|
---|
100 | return 0;
|
---|
101 |
|
---|
102 | case DM_DROP:
|
---|
103 | {
|
---|
104 | char szFrom[CCHMAXPATH + 5];
|
---|
105 |
|
---|
106 | if (emphasized) {
|
---|
107 | emphasized = FALSE;
|
---|
108 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
109 | }
|
---|
110 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, CCHMAXPATH)) {
|
---|
111 | strcat(szFrom, " %a");
|
---|
112 | WinSetWindowText(hwnd, szFrom);
|
---|
113 | }
|
---|
114 | }
|
---|
115 | return 0;
|
---|
116 | }
|
---|
117 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
118 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
119 | }
|
---|
120 |
|
---|
121 | VOID free_associations(VOID)
|
---|
122 | {
|
---|
123 | LINKASSOC *info, *next;
|
---|
124 |
|
---|
125 | info = asshead;
|
---|
126 | while (info) {
|
---|
127 | next = info->next;
|
---|
128 | xfree(info->mask, pszSrcFile, __LINE__);
|
---|
129 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
130 | xfree(info->sig, pszSrcFile, __LINE__);
|
---|
131 | free(info);
|
---|
132 | info = next;
|
---|
133 | }
|
---|
134 | asshead = asstail = NULL;
|
---|
135 | }
|
---|
136 |
|
---|
137 | VOID load_associations(VOID)
|
---|
138 | {
|
---|
139 | FILE *fp;
|
---|
140 | LINKASSOC *info;
|
---|
141 | PSZ pszCmdLine;
|
---|
142 | CHAR mask[CCHMAXPATH + 24];
|
---|
143 | CHAR sig[CCHMAXPATH + 24];
|
---|
144 | CHAR offset[72];
|
---|
145 | CHAR flags[72];
|
---|
146 |
|
---|
147 | if (asshead)
|
---|
148 | free_associations();
|
---|
149 | assloaded = TRUE;
|
---|
150 | BldFullPathName(mask, pFM2SaveDirectory, "ASSOC.DAT");
|
---|
151 | fp = _fsopen(mask, "r", SH_DENYWR);
|
---|
152 | pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
153 | if (!pszCmdLine) {
|
---|
154 | if (fp)
|
---|
155 | fclose(fp); //already complained
|
---|
156 | }
|
---|
157 | if (fp) {
|
---|
158 | while (!feof(fp)) {
|
---|
159 | if (!xfgets(mask, sizeof(mask), fp, pszSrcFile, __LINE__)) // fixme why +24?
|
---|
160 | break;
|
---|
161 | mask[CCHMAXPATH] = 0;
|
---|
162 | bstripcr(mask);
|
---|
163 | if (!*mask || *mask == ';')
|
---|
164 | continue;
|
---|
165 | if (!xfgets(pszCmdLine, MaxComLineStrg, fp, pszSrcFile, __LINE__) ||
|
---|
166 | !xfgets(sig, CCHMAXPATH + 24, fp, pszSrcFile, __LINE__) ||
|
---|
167 | !xfgets(offset, sizeof(offset), fp, pszSrcFile, __LINE__) ||
|
---|
168 | !xfgets(flags, sizeof(flags), fp, pszSrcFile, __LINE__))
|
---|
169 | break; /* error! */
|
---|
170 | pszCmdLine[MaxComLineStrg - 1] = 0;
|
---|
171 | bstripcr(pszCmdLine);
|
---|
172 | sig[CCHMAXPATH] = 0;
|
---|
173 | bstripcr(sig);
|
---|
174 | offset[34] = 0;
|
---|
175 | bstripcr(offset);
|
---|
176 | flags[34] = 0;
|
---|
177 | bstripcr(flags);
|
---|
178 | if (!*pszCmdLine)
|
---|
179 | continue;
|
---|
180 | info = xmallocz(sizeof(LINKASSOC), pszSrcFile, __LINE__);
|
---|
181 | if (info) {
|
---|
182 | info->pszCmdLine = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
|
---|
183 | info->mask = xstrdup(mask, pszSrcFile, __LINE__);
|
---|
184 | if (*sig)
|
---|
185 | info->sig = xstrdup(sig, pszSrcFile, __LINE__);
|
---|
186 | info->offset = atol(offset);
|
---|
187 | info->flags = atol(flags);
|
---|
188 | if (!info->pszCmdLine || !info->mask) {
|
---|
189 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
190 | xfree(info->mask, pszSrcFile, __LINE__);
|
---|
191 | free(info);
|
---|
192 | break;
|
---|
193 | }
|
---|
194 | if (!asshead)
|
---|
195 | asshead = info;
|
---|
196 | else {
|
---|
197 | asstail->next = info;
|
---|
198 | info->prev = asstail;
|
---|
199 | }
|
---|
200 | asstail = info;
|
---|
201 | }
|
---|
202 | }
|
---|
203 | xfree(pszCmdLine, pszSrcFile, __LINE__);
|
---|
204 | fclose(fp);
|
---|
205 | }
|
---|
206 | }
|
---|
207 |
|
---|
208 | VOID display_associations(HWND hwnd, ASSOC *temp, LINKASSOC *info)
|
---|
209 | {
|
---|
210 | CHAR szEnviroment[2048];
|
---|
211 | PSZ pszDisplayStr;
|
---|
212 | SHORT x;
|
---|
213 |
|
---|
214 | *szEnviroment = 0;
|
---|
215 | WinQueryDlgItemText(hwnd, ASS_ENVIRON, 2048, szEnviroment);
|
---|
216 | bstripcr(szEnviroment);
|
---|
217 | if (*szEnviroment)
|
---|
218 | PrfWriteProfileString(fmprof, FM3Str, temp->pszCmdLine, szEnviroment);
|
---|
219 | pszDisplayStr = xmallocz((CCHMAXPATH * 2) + MaxComLineStrg + 6,
|
---|
220 | pszSrcFile, __LINE__);
|
---|
221 | if (pszDisplayStr) {
|
---|
222 | sprintf(pszDisplayStr, "%-12s \x1a %-24s %s%s%s", temp->mask,
|
---|
223 | temp->pszCmdLine, (*temp->sig) ?
|
---|
224 | "[" : NullStr, (*temp->sig) ? temp->sig : NullStr,
|
---|
225 | (*temp->sig) ? "]" : NullStr);
|
---|
226 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
227 | ASS_LISTBOX,
|
---|
228 | LM_INSERTITEM,
|
---|
229 | MPFROM2SHORT(LIT_END, 0), MPFROMP(pszDisplayStr));
|
---|
230 | if (x >= 0) {
|
---|
231 | WinSendDlgItemMsg(hwnd,
|
---|
232 | ASS_LISTBOX,
|
---|
233 | LM_SETITEMHANDLE,
|
---|
234 | MPFROMSHORT(x), MPFROMP(info));
|
---|
235 | WinSendDlgItemMsg(hwnd,
|
---|
236 | ASS_LISTBOX,
|
---|
237 | LM_SELECTITEM,
|
---|
238 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
239 | }
|
---|
240 | free(pszDisplayStr);
|
---|
241 | }
|
---|
242 | }
|
---|
243 |
|
---|
244 | VOID save_associations(VOID)
|
---|
245 | {
|
---|
246 | LINKASSOC *info;
|
---|
247 | FILE *fp;
|
---|
248 | CHAR s[CCHMAXPATH + 14];
|
---|
249 |
|
---|
250 | if (!assloaded || !asshead)
|
---|
251 | return;
|
---|
252 | info = asshead;
|
---|
253 | #ifdef NEVER
|
---|
254 | while (info) {
|
---|
255 | next = info->next;
|
---|
256 | if (!strcmp("*", info->mask)) {
|
---|
257 | if (info != asshead) { /* already top record */
|
---|
258 | if (info->prev)
|
---|
259 | (info->prev)->next = info->next;
|
---|
260 | if (info->next)
|
---|
261 | (info->next)->prev = info->prev;
|
---|
262 | if (info == asstail)
|
---|
263 | asstail = info->prev;
|
---|
264 | info->next = asshead->next;
|
---|
265 | info->prev = NULL;
|
---|
266 | asshead = info;
|
---|
267 | }
|
---|
268 | }
|
---|
269 | info = next;
|
---|
270 | }
|
---|
271 | #endif
|
---|
272 | BldFullPathName(s, pFM2SaveDirectory, "ASSOC.DAT");
|
---|
273 | if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
|
---|
274 | return; //already gave error msg
|
---|
275 | fp = xfopen(s, "w", pszSrcFile, __LINE__);
|
---|
276 | if (fp) {
|
---|
277 | fputs(GetPString(IDS_ASSOCFILETEXT), fp);
|
---|
278 | info = asshead;
|
---|
279 | while (info) {
|
---|
280 | fprintf(fp,
|
---|
281 | ";\n%0.*s\n%0.*s\n%0.*s\n%lu\n%lu\n",
|
---|
282 | CCHMAXPATH,
|
---|
283 | info->mask,
|
---|
284 | MaxComLineStrg,
|
---|
285 | info->pszCmdLine,
|
---|
286 | CCHMAXPATH,
|
---|
287 | (info->sig) ? info->sig : NullStr, info->offset, info->flags);
|
---|
288 | info = info->next;
|
---|
289 | }
|
---|
290 | fclose(fp);
|
---|
291 | }
|
---|
292 | }
|
---|
293 |
|
---|
294 | LINKASSOC *add_association(ASSOC * addme)
|
---|
295 | {
|
---|
296 | LINKASSOC *info;
|
---|
297 |
|
---|
298 | if (addme && *addme->pszCmdLine && *addme->mask) {
|
---|
299 | info = asshead;
|
---|
300 | while (info) {
|
---|
301 | if ((!replace) && (!stricmp(info->mask, addme->mask) &&
|
---|
302 | ((!info->sig && !*addme->sig) || (!replace) &&
|
---|
303 | (info->sig && !strcmp(addme->sig, info->sig)))))
|
---|
304 | return NULL;
|
---|
305 | info = info->next;
|
---|
306 | }
|
---|
307 | if (!info) {
|
---|
308 | info = xmallocz(sizeof(LINKASSOC), pszSrcFile, __LINE__);
|
---|
309 | if (info) {
|
---|
310 | info->pszCmdLine = xstrdup(addme->pszCmdLine, pszSrcFile, __LINE__);
|
---|
311 | info->mask = xstrdup(addme->mask, pszSrcFile, __LINE__);
|
---|
312 | if (*addme->sig)
|
---|
313 | info->sig = xstrdup(addme->sig, pszSrcFile, __LINE__);
|
---|
314 | if (addme->offset)
|
---|
315 | info->offset = addme->offset;
|
---|
316 | if (addme->flags)
|
---|
317 | info->flags = addme->flags;
|
---|
318 | if (!info->pszCmdLine || !info->mask) {
|
---|
319 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
320 | xfree(info->mask, pszSrcFile, __LINE__);
|
---|
321 | free(info);
|
---|
322 | }
|
---|
323 | else {
|
---|
324 | if (!asshead) /* only item in list */
|
---|
325 | asshead = asstail = info;
|
---|
326 | else {
|
---|
327 | if (asstail) { /* place at tail */
|
---|
328 | asstail->next = info;
|
---|
329 | info->prev = asstail;
|
---|
330 | }
|
---|
331 | asstail = info;
|
---|
332 | }
|
---|
333 | return info;
|
---|
334 | }
|
---|
335 | }
|
---|
336 | }
|
---|
337 | }
|
---|
338 | return NULL;
|
---|
339 | }
|
---|
340 |
|
---|
341 | BOOL kill_association(ASSOC * killme)
|
---|
342 | {
|
---|
343 | LINKASSOC *info;
|
---|
344 |
|
---|
345 | if (killme && *killme->mask) {
|
---|
346 | info = asshead;
|
---|
347 | while (info) {
|
---|
348 | if (!stricmp(info->mask, killme->mask) &&
|
---|
349 | info->offset == killme->offset &&
|
---|
350 | (((!info->sig || !*info->sig) && !*killme->sig) ||
|
---|
351 | (info->sig && !strcmp(killme->sig, info->sig)))) {
|
---|
352 | if (info == asshead) {
|
---|
353 | asshead = info->next;
|
---|
354 | if (info == asstail)
|
---|
355 | asstail = info->prev;
|
---|
356 | }
|
---|
357 | else {
|
---|
358 | if (info->next)
|
---|
359 | (info->next)->prev = info->prev;
|
---|
360 | if (info->prev)
|
---|
361 | (info->prev)->next = info->next;
|
---|
362 | if (info == asstail)
|
---|
363 | asstail = info->prev;
|
---|
364 | }
|
---|
365 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
366 | xfree(info->mask, pszSrcFile, __LINE__);
|
---|
367 | xfree(info->sig, pszSrcFile, __LINE__);
|
---|
368 | free(info);
|
---|
369 | return TRUE;
|
---|
370 | }
|
---|
371 | info = info->next;
|
---|
372 | }
|
---|
373 | }
|
---|
374 | return FALSE;
|
---|
375 | }
|
---|
376 |
|
---|
377 | INT ExecAssociation(HWND hwnd, CHAR * datafile)
|
---|
378 | {
|
---|
379 | CHAR *file, sig[CCHMAXPATH], sigl[CCHMAXPATH], mask[CCHMAXPATH], *p;
|
---|
380 | FILE *fp;
|
---|
381 | BOOL didmatch, exclude;
|
---|
382 | ULONG offset;
|
---|
383 | LINKASSOC *info;
|
---|
384 |
|
---|
385 | if (!assloaded)
|
---|
386 | load_associations();
|
---|
387 | if (!asshead)
|
---|
388 | return -1;
|
---|
389 | if (!datafile || !*datafile)
|
---|
390 | return -1;
|
---|
391 | file = strrchr(datafile, '\\');
|
---|
392 | if (!file)
|
---|
393 | file = strrchr(datafile, ':');
|
---|
394 | if (file)
|
---|
395 | file++;
|
---|
396 | else
|
---|
397 | file = datafile;
|
---|
398 | info = asshead;
|
---|
399 | while (info) {
|
---|
400 | strcpy(mask, info->mask);
|
---|
401 | p = strtok(mask, ";");
|
---|
402 | while (p) {
|
---|
403 | if (*p == '/') {
|
---|
404 | p++;
|
---|
405 | exclude = TRUE;
|
---|
406 | }
|
---|
407 | else
|
---|
408 | exclude = FALSE;
|
---|
409 | didmatch = wildcard((strchr(p, '\\') ||
|
---|
410 | strchr(p, ':')) ? datafile : file, p, FALSE);
|
---|
411 | if (exclude && didmatch)
|
---|
412 | didmatch = FALSE;
|
---|
413 | if (didmatch) {
|
---|
414 | if (info->sig && *info->sig) {
|
---|
415 | strcpy(sigl, info->sig);
|
---|
416 | literal(sigl);
|
---|
417 | fp = _fsopen(datafile, "rb", SH_DENYNO);
|
---|
418 | if (fp) {
|
---|
419 | if (info->offset < 0L) {
|
---|
420 | fseek(fp, 0L, SEEK_END);
|
---|
421 | offset = ftell(fp) + info->offset;
|
---|
422 | }
|
---|
423 | else
|
---|
424 | offset = info->offset;
|
---|
425 | fseek(fp, offset, SEEK_SET);
|
---|
426 | if (fread(sig,
|
---|
427 | 1,
|
---|
428 | strlen(sigl),
|
---|
429 | fp) != strlen(sigl) || strncmp(sigl, sig, strlen(sigl)))
|
---|
430 | didmatch = FALSE;
|
---|
431 | fclose(fp);
|
---|
432 | }
|
---|
433 | }
|
---|
434 | }
|
---|
435 | if (didmatch) { /* got a match; do it... */
|
---|
436 |
|
---|
437 | CHAR *list[2];
|
---|
438 | INT flags, rc;
|
---|
439 | BOOL dieafter = FALSE;
|
---|
440 |
|
---|
441 | if (fAmAV2) {
|
---|
442 | if (stristr(info->pszCmdLine, "AV2.EXE") ||
|
---|
443 | stristr(info->pszCmdLine, "AV2.CMD") || stristr(info->pszCmdLine, "<>"))
|
---|
444 | return -1;
|
---|
445 | }
|
---|
446 | if (!strcmp(info->pszCmdLine, "<>")) {
|
---|
447 | OpenObject(datafile, Default, hwnd);
|
---|
448 | return 0;
|
---|
449 | }
|
---|
450 | list[0] = datafile;
|
---|
451 | list[1] = NULL;
|
---|
452 | flags = info->flags;
|
---|
453 | if (!(flags & FULLSCREEN))
|
---|
454 | flags |= WINDOWED;
|
---|
455 | if (flags & KEEP)
|
---|
456 | flags |= SEPARATEKEEP;
|
---|
457 | else
|
---|
458 | flags |= SEPARATE;
|
---|
459 | flags &= (~KEEP);
|
---|
460 | if (flags & DIEAFTER)
|
---|
461 | dieafter = TRUE;
|
---|
462 | flags &= (~DIEAFTER);
|
---|
463 | rc = ExecOnList(hwnd,
|
---|
464 | info->pszCmdLine,
|
---|
465 | flags,
|
---|
466 | NULL, list, GetPString(IDS_EXECASSOCTITLETEXT),
|
---|
467 | pszSrcFile, __LINE__);
|
---|
468 | if (rc != -1 && dieafter)
|
---|
469 | PostMsg((HWND) 0, WM_QUIT, MPVOID, MPVOID);
|
---|
470 | return rc;
|
---|
471 | }
|
---|
472 | p = strtok(0, ";");
|
---|
473 | }
|
---|
474 | info = info->next;
|
---|
475 | }
|
---|
476 | return -1;
|
---|
477 | }
|
---|
478 |
|
---|
479 | MRESULT EXPENTRY AssocDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
480 | {
|
---|
481 | LINKASSOC *info;
|
---|
482 | SHORT x, y;
|
---|
483 |
|
---|
484 | switch (msg) {
|
---|
485 | case WM_INITDLG:
|
---|
486 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
487 | WinSendDlgItemMsg(hwnd, ASS_MASK, EM_SETTEXTLIMIT,
|
---|
488 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
489 | WinSendDlgItemMsg(hwnd, ASS_CL, EM_SETTEXTLIMIT,
|
---|
490 | MPFROM2SHORT(1000, 0), MPVOID);
|
---|
491 | WinSendDlgItemMsg(hwnd, ASS_SIG, EM_SETTEXTLIMIT,
|
---|
492 | MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
|
---|
493 | WinSendDlgItemMsg(hwnd, ASS_OFFSET, EM_SETTEXTLIMIT,
|
---|
494 | MPFROM2SHORT(34, 0), MPVOID);
|
---|
495 | WinSetDlgItemText(hwnd, ASS_MASK, NullStr);
|
---|
496 | WinSetDlgItemText(hwnd, ASS_CL, NullStr);
|
---|
497 | WinSetDlgItemText(hwnd, ASS_SIG, NullStr);
|
---|
498 | WinSetDlgItemText(hwnd, ASS_OFFSET, "0");
|
---|
499 | WinCheckButton(hwnd, ASS_DEFAULT, TRUE);
|
---|
500 | WinCheckButton(hwnd, ASS_PROMPT, FALSE);
|
---|
501 | WinCheckButton(hwnd, ASS_KEEP, FALSE);
|
---|
502 | WinCheckButton(hwnd, ASS_DIEAFTER, FALSE);
|
---|
503 | PostMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
504 | {
|
---|
505 | PFNWP oldproc;
|
---|
506 |
|
---|
507 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, ASS_CL),
|
---|
508 | (PFNWP) AssocTextProc);
|
---|
509 | if (oldproc)
|
---|
510 | WinSetWindowPtr(WinWindowFromID(hwnd, ASS_CL), QWL_USER,
|
---|
511 | (PVOID) oldproc);
|
---|
512 | }
|
---|
513 | break;
|
---|
514 |
|
---|
515 | case UM_UNDO:
|
---|
516 | {
|
---|
517 | PSZ pszDisplayStr;
|
---|
518 |
|
---|
519 | pszDisplayStr = xmallocz((CCHMAXPATH * 2) + MaxComLineStrg + 6,
|
---|
520 | pszSrcFile, __LINE__);
|
---|
521 | if (pszDisplayStr) {
|
---|
522 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
523 | info = asshead;
|
---|
524 | while (info) {
|
---|
525 | sprintf(pszDisplayStr,
|
---|
526 | "%-12s \x1a %-24s %s%s%s",
|
---|
527 | info->mask,
|
---|
528 | info->pszCmdLine,
|
---|
529 | (info->sig && *info->sig) ?
|
---|
530 | "[" : NullStr,
|
---|
531 | (info->sig && *info->sig) ? info->sig : NullStr,
|
---|
532 | (info->sig && *info->sig) ? "]" : NullStr);
|
---|
533 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
534 | ASS_LISTBOX,
|
---|
535 | LM_INSERTITEM,
|
---|
536 | MPFROM2SHORT(LIT_END, 0), MPFROMP(pszDisplayStr));
|
---|
537 | if (x >= 0)
|
---|
538 | WinSendDlgItemMsg(hwnd,
|
---|
539 | ASS_LISTBOX,
|
---|
540 | LM_SETITEMHANDLE, MPFROMSHORT(x), MPFROMP(info));
|
---|
541 | info = info->next;
|
---|
542 | }
|
---|
543 | WinSendDlgItemMsg(hwnd,
|
---|
544 | ASS_LISTBOX,
|
---|
545 | LM_SELECTITEM, MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
546 | xfree(pszDisplayStr, pszSrcFile, __LINE__);
|
---|
547 | }
|
---|
548 | }
|
---|
549 | return 0;
|
---|
550 |
|
---|
551 | case WM_CONTROL:
|
---|
552 | if (SHORT1FROMMP(mp1) == ASS_LISTBOX) {
|
---|
553 | switch (SHORT2FROMMP(mp1)) {
|
---|
554 | case LN_ENTER:
|
---|
555 | case LN_SELECT:
|
---|
556 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
557 | ASS_LISTBOX,
|
---|
558 | LM_QUERYSELECTION,
|
---|
559 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
560 | if (x >= 0) {
|
---|
561 |
|
---|
562 | CHAR s[36];
|
---|
563 |
|
---|
564 | info = (LINKASSOC *) WinSendDlgItemMsg(hwnd,
|
---|
565 | ASS_LISTBOX,
|
---|
566 | LM_QUERYITEMHANDLE,
|
---|
567 | MPFROMSHORT(x), MPVOID);
|
---|
568 | if (!info) {
|
---|
569 | Runtime_Error(pszSrcFile, __LINE__, "Query item handle failed");
|
---|
570 | break;
|
---|
571 | }
|
---|
572 | WinSetDlgItemText(hwnd, ASS_MASK, info->mask);
|
---|
573 | WinSetDlgItemText(hwnd, ASS_CL, info->pszCmdLine);
|
---|
574 | WinSetDlgItemText(hwnd, ASS_SIG,
|
---|
575 | (info->sig && *info->sig) ? info->sig : NullStr);
|
---|
576 | sprintf(s, "%ld", info->offset);
|
---|
577 | WinSetDlgItemText(hwnd, ASS_OFFSET, s);
|
---|
578 | if (!(info->flags & 1023))
|
---|
579 | WinCheckButton(hwnd, ASS_DEFAULT, TRUE);
|
---|
580 | else {
|
---|
581 | if (info->flags & FULLSCREEN)
|
---|
582 | WinCheckButton(hwnd, ASS_FULLSCREEN, TRUE);
|
---|
583 | else if (info->flags & MINIMIZED)
|
---|
584 | WinCheckButton(hwnd, ASS_MINIMIZED, TRUE);
|
---|
585 | else if (info->flags & MAXIMIZED)
|
---|
586 | WinCheckButton(hwnd, ASS_MAXIMIZED, TRUE);
|
---|
587 | else if (info->flags & INVISIBLE)
|
---|
588 | WinCheckButton(hwnd, ASS_INVISIBLE, TRUE);
|
---|
589 | }
|
---|
590 | WinCheckButton(hwnd, ASS_KEEP, ((info->flags & KEEP) != 0));
|
---|
591 | WinCheckButton(hwnd, ASS_DIEAFTER, ((info->flags & DIEAFTER) != 0));
|
---|
592 | WinCheckButton(hwnd, ASS_PROMPT, ((info->flags & PROMPT) != 0));
|
---|
593 | {
|
---|
594 | CHAR env[1002];
|
---|
595 | ULONG size;
|
---|
596 |
|
---|
597 | *env = 0;
|
---|
598 | size = sizeof(env) - 1;
|
---|
599 | if (PrfQueryProfileData(fmprof,
|
---|
600 | FM3Str, info->pszCmdLine, env, &size) && *env)
|
---|
601 | WinSetDlgItemText(hwnd, ASS_ENVIRON, env);
|
---|
602 | else
|
---|
603 | WinSetDlgItemText(hwnd, ASS_ENVIRON, NullStr);
|
---|
604 | }
|
---|
605 | }
|
---|
606 | break;
|
---|
607 | }
|
---|
608 | }
|
---|
609 | return 0;
|
---|
610 |
|
---|
611 | case WM_COMMAND:
|
---|
612 | switch (SHORT1FROMMP(mp1)) {
|
---|
613 | case ASS_TOP:
|
---|
614 | x = (SHORT) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
615 | LM_QUERYSELECTION,
|
---|
616 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
617 | if (x >= 0) {
|
---|
618 | info = (LINKASSOC *) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
619 | LM_QUERYITEMHANDLE,
|
---|
620 | MPFROMSHORT(x), MPVOID);
|
---|
621 | if (info) {
|
---|
622 | if (info != asshead) {
|
---|
623 | if (info->prev)
|
---|
624 | info->prev->next = info->next;
|
---|
625 | if (info->next)
|
---|
626 | info->next->prev = info->prev;
|
---|
627 | if (info == asstail)
|
---|
628 | asstail = info->prev;
|
---|
629 | info->prev = NULL;
|
---|
630 | info->next = asshead;
|
---|
631 | asshead->prev = info;
|
---|
632 | asshead = info;
|
---|
633 | WinSendMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
634 | }
|
---|
635 | }
|
---|
636 | }
|
---|
637 | break;
|
---|
638 |
|
---|
639 | case ASS_BOTTOM:
|
---|
640 | x = (SHORT) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
641 | LM_QUERYSELECTION,
|
---|
642 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
643 | if (x >= 0) {
|
---|
644 | info = (LINKASSOC *) WinSendDlgItemMsg(hwnd, ASS_LISTBOX,
|
---|
645 | LM_QUERYITEMHANDLE,
|
---|
646 | MPFROMSHORT(x), MPVOID);
|
---|
647 | if (info) {
|
---|
648 | if (info != asstail) {
|
---|
649 | if (info->next)
|
---|
650 | info->next->prev = info->prev;
|
---|
651 | if (info->prev)
|
---|
652 | info->prev->next = info->next;
|
---|
653 | if (info == asshead)
|
---|
654 | asshead = info->next;
|
---|
655 | info->next = NULL;
|
---|
656 | info->prev = asstail;
|
---|
657 | asstail->next = info;
|
---|
658 | asstail = info;
|
---|
659 | WinSendMsg(hwnd, UM_UNDO, MPVOID, MPVOID);
|
---|
660 | }
|
---|
661 | }
|
---|
662 | }
|
---|
663 | break;
|
---|
664 | case ASS_FIND:
|
---|
665 | {
|
---|
666 | CHAR filename[CCHMAXPATH + 9], szfilename[CCHMAXPATH + 9];
|
---|
667 |
|
---|
668 | *filename = 0;
|
---|
669 | if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
|
---|
670 | BldQuotedFileName(szfilename, filename);
|
---|
671 | strcat(szfilename, " %a");
|
---|
672 | WinSetDlgItemText(hwnd, ASS_CL, szfilename);
|
---|
673 | }
|
---|
674 | }
|
---|
675 | break;
|
---|
676 |
|
---|
677 | case DID_OK:
|
---|
678 | {
|
---|
679 | ASSOC temp;
|
---|
680 | CHAR dummy[34];
|
---|
681 | PSZ pszWorkBuf;
|
---|
682 | replace = FALSE;
|
---|
683 |
|
---|
684 | memset(&temp, 0, sizeof(ASSOC));
|
---|
685 | temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
686 | if (!temp.pszCmdLine)
|
---|
687 | break; //already complained
|
---|
688 |
|
---|
689 | {
|
---|
690 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
691 | ASS_LISTBOX,
|
---|
692 | LM_QUERYSELECTION, MPVOID, MPVOID);
|
---|
693 | if (x == LIT_NONE)
|
---|
694 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
695 | ASS_LISTBOX,
|
---|
696 | LM_SELECTITEM,
|
---|
697 | MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
698 | }
|
---|
699 | pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
700 | if (!pszWorkBuf) {
|
---|
701 | free(temp.pszCmdLine);
|
---|
702 | break; //already complained
|
---|
703 | }
|
---|
704 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
705 | WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
|
---|
706 | if (strcmp(temp.pszCmdLine, "<>")) {
|
---|
707 | NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
|
---|
708 | memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
709 | }
|
---|
710 | free(pszWorkBuf);
|
---|
711 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
712 | rstrip(temp.sig);
|
---|
713 | if (*temp.sig) {
|
---|
714 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
715 | temp.offset = atol(dummy);
|
---|
716 | }
|
---|
717 | bstrip(temp.mask);
|
---|
718 | bstrip(temp.pszCmdLine);
|
---|
719 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
720 | temp.flags = 0;
|
---|
721 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
722 | temp.flags = FULLSCREEN;
|
---|
723 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
724 | temp.flags = MINIMIZED;
|
---|
725 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
726 | temp.flags = MAXIMIZED;
|
---|
727 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
728 | temp.flags = INVISIBLE;
|
---|
729 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
730 | temp.flags |= KEEP;
|
---|
731 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
732 | temp.flags |= DIEAFTER;
|
---|
733 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
734 | temp.flags |= PROMPT;
|
---|
735 | if (fCancelAction){
|
---|
736 | fCancelAction = FALSE;
|
---|
737 | free(temp.pszCmdLine);
|
---|
738 | break;
|
---|
739 | }
|
---|
740 | else
|
---|
741 | info = add_association(&temp);
|
---|
742 | if (!info)
|
---|
743 | WinDismissDlg(hwnd, 1); /* Runtime_Error(pszSrcFile, __LINE__, "add_association"); */
|
---|
744 | else {
|
---|
745 | display_associations(hwnd, &temp, info);
|
---|
746 | save_associations();
|
---|
747 | }
|
---|
748 | free(temp.pszCmdLine);
|
---|
749 | }
|
---|
750 | WinDismissDlg(hwnd, 1);
|
---|
751 | break;
|
---|
752 |
|
---|
753 | case DID_CANCEL:
|
---|
754 | WinDismissDlg(hwnd, 0);
|
---|
755 | break;
|
---|
756 |
|
---|
757 | case IDM_HELP:
|
---|
758 | if (hwndHelp)
|
---|
759 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
760 | MPFROM2SHORT(HELP_ASSOC, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
761 | break;
|
---|
762 |
|
---|
763 | case ASS_ADD:
|
---|
764 | {
|
---|
765 | ASSOC temp;
|
---|
766 | CHAR dummy[34];
|
---|
767 | PSZ pszWorkBuf;
|
---|
768 | replace = FALSE;
|
---|
769 |
|
---|
770 | memset(&temp, 0, sizeof(ASSOC));
|
---|
771 | temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
772 | if (!temp.pszCmdLine)
|
---|
773 | break; //already complained
|
---|
774 | pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
775 | if (!pszWorkBuf) {
|
---|
776 | free(temp.pszCmdLine);
|
---|
777 | break; //already complained
|
---|
778 | }
|
---|
779 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
780 | WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
|
---|
781 | if (strcmp(temp.pszCmdLine, "<>")) {
|
---|
782 | NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
|
---|
783 | memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
784 | }
|
---|
785 | free(pszWorkBuf);
|
---|
786 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
787 | rstrip(temp.sig);
|
---|
788 | if (*temp.sig) {
|
---|
789 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
790 | temp.offset = atol(dummy);
|
---|
791 | }
|
---|
792 | bstrip(temp.mask);
|
---|
793 | bstrip(temp.pszCmdLine);
|
---|
794 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
795 | temp.flags = 0;
|
---|
796 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
797 | temp.flags = FULLSCREEN;
|
---|
798 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
799 | temp.flags = MINIMIZED;
|
---|
800 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
801 | temp.flags = MAXIMIZED;
|
---|
802 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
803 | temp.flags = INVISIBLE;
|
---|
804 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
805 | temp.flags |= KEEP;
|
---|
806 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
807 | temp.flags |= DIEAFTER;
|
---|
808 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
809 | temp.flags |= PROMPT;
|
---|
810 | if (fCancelAction){
|
---|
811 | fCancelAction = FALSE;
|
---|
812 | free(temp.pszCmdLine);
|
---|
813 | break;
|
---|
814 | }
|
---|
815 | else
|
---|
816 | info = add_association(&temp);
|
---|
817 | //Add will fail if mask is not changed
|
---|
818 | if (info) {
|
---|
819 | display_associations(hwnd, &temp, info);
|
---|
820 | save_associations();
|
---|
821 | }
|
---|
822 | free(temp.pszCmdLine);
|
---|
823 | }
|
---|
824 | break;
|
---|
825 |
|
---|
826 | case ASS_DELETE:
|
---|
827 | {
|
---|
828 | ASSOC temp;
|
---|
829 | CHAR dummy[34];
|
---|
830 |
|
---|
831 | memset(&temp, 0, sizeof(ASSOC));
|
---|
832 | temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
833 | if (!temp.pszCmdLine)
|
---|
834 | break; //already complained
|
---|
835 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
836 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
837 | rstrip(temp.sig);
|
---|
838 | if (*temp.sig) {
|
---|
839 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
840 | temp.offset = atol(dummy);
|
---|
841 | }
|
---|
842 | bstrip(temp.mask);
|
---|
843 | PrfWriteProfileData(fmprof, FM3Str, temp.mask, NULL, 0L);
|
---|
844 | if (kill_association(&temp)) {
|
---|
845 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
846 | ASS_LISTBOX,
|
---|
847 | LM_QUERYSELECTION,
|
---|
848 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
849 | if (x >= 0) {
|
---|
850 | WinSendDlgItemMsg(hwnd,
|
---|
851 | ASS_LISTBOX,
|
---|
852 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
853 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_SELECTITEM,
|
---|
854 | MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
|
---|
855 | }
|
---|
856 | save_associations();
|
---|
857 | }
|
---|
858 | free(temp.pszCmdLine);
|
---|
859 | }
|
---|
860 |
|
---|
861 | break;
|
---|
862 | case ASS_REPLACE:
|
---|
863 |
|
---|
864 | {
|
---|
865 | ASSOC temp;
|
---|
866 | CHAR dummy[34];
|
---|
867 | PSZ pszWorkBuf;
|
---|
868 | replace = TRUE;
|
---|
869 |
|
---|
870 | memset(&temp, 0, sizeof(ASSOC));
|
---|
871 | temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
872 | if (!temp.pszCmdLine)
|
---|
873 | break; //already complained
|
---|
874 | y = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
875 | ASS_LISTBOX,
|
---|
876 | LM_QUERYSELECTION,
|
---|
877 | MPFROMSHORT(LIT_CURSOR), MPVOID);
|
---|
878 | pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
879 | if (!pszWorkBuf) {
|
---|
880 | free(temp.pszCmdLine);
|
---|
881 | break; //already complained
|
---|
882 | }
|
---|
883 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
884 | WinQueryDlgItemText(hwnd, ASS_CL, MaxComLineStrg, temp.pszCmdLine);
|
---|
885 | if (strcmp(temp.pszCmdLine, "<>")) {
|
---|
886 | NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
|
---|
887 | memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
888 | }
|
---|
889 | free(pszWorkBuf);
|
---|
890 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
891 | rstrip(temp.sig);
|
---|
892 | if (*temp.sig) {
|
---|
893 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
894 | temp.offset = atol(dummy);
|
---|
895 | }
|
---|
896 | bstrip(temp.mask);
|
---|
897 | bstrip(temp.pszCmdLine);
|
---|
898 | if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
|
---|
899 | temp.flags = 0;
|
---|
900 | else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
|
---|
901 | temp.flags = FULLSCREEN;
|
---|
902 | else if (WinQueryButtonCheckstate(hwnd, ASS_MINIMIZED))
|
---|
903 | temp.flags = MINIMIZED;
|
---|
904 | else if (WinQueryButtonCheckstate(hwnd, ASS_MAXIMIZED))
|
---|
905 | temp.flags = MAXIMIZED;
|
---|
906 | else if (WinQueryButtonCheckstate(hwnd, ASS_INVISIBLE))
|
---|
907 | temp.flags = INVISIBLE;
|
---|
908 | if (WinQueryButtonCheckstate(hwnd, ASS_KEEP))
|
---|
909 | temp.flags |= KEEP;
|
---|
910 | if (WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
|
---|
911 | temp.flags |= DIEAFTER;
|
---|
912 | if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
|
---|
913 | temp.flags |= PROMPT;
|
---|
914 | if (fCancelAction){
|
---|
915 | fCancelAction = FALSE;
|
---|
916 | free(temp.pszCmdLine);
|
---|
917 | break;
|
---|
918 | }
|
---|
919 | else
|
---|
920 | info = add_association(&temp);
|
---|
921 | if (info) {
|
---|
922 | display_associations(hwnd, &temp, info);
|
---|
923 | save_associations();
|
---|
924 | }
|
---|
925 | free(temp.pszCmdLine);
|
---|
926 | }
|
---|
927 | {
|
---|
928 | ASSOC temp;
|
---|
929 | CHAR dummy[34];
|
---|
930 |
|
---|
931 | temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
932 | if (!temp.pszCmdLine)
|
---|
933 | break; //already complained
|
---|
934 | WinSendDlgItemMsg(hwnd,
|
---|
935 | ASS_LISTBOX,
|
---|
936 | LM_SELECTITEM, MPFROMSHORT(y), MPFROMSHORT(TRUE));
|
---|
937 | memset(temp.sig, 0, sizeof(temp.sig));
|
---|
938 | memset(temp.mask, 0, sizeof(temp.mask));
|
---|
939 | temp.offset = 0;
|
---|
940 | WinQueryDlgItemText(hwnd, ASS_MASK, sizeof(temp.mask), temp.mask);
|
---|
941 | WinQueryDlgItemText(hwnd, ASS_SIG, sizeof(temp.sig), temp.sig);
|
---|
942 | rstrip(temp.sig);
|
---|
943 | if (*temp.sig) {
|
---|
944 | WinQueryDlgItemText(hwnd, ASS_OFFSET, sizeof(dummy), dummy);
|
---|
945 | temp.offset = atol(dummy);
|
---|
946 | }
|
---|
947 | bstrip(temp.mask);
|
---|
948 | PrfWriteProfileData(fmprof, FM3Str, temp.mask, NULL, 0L);
|
---|
949 | if (!kill_association(&temp))
|
---|
950 | Runtime_Error(pszSrcFile, __LINE__, "kill_association");
|
---|
951 | else {
|
---|
952 |
|
---|
953 | if (y >= 0) {
|
---|
954 | WinSendDlgItemMsg(hwnd,
|
---|
955 | ASS_LISTBOX,
|
---|
956 | LM_DELETEITEM, MPFROMSHORT(y), MPVOID);
|
---|
957 | WinSendDlgItemMsg(hwnd, ASS_LISTBOX, LM_SELECTITEM,
|
---|
958 | MPFROMSHORT(x - 1), MPFROMSHORT(TRUE));
|
---|
959 | }
|
---|
960 | save_associations();
|
---|
961 | }
|
---|
962 | free(temp.pszCmdLine);
|
---|
963 | }
|
---|
964 | break;
|
---|
965 | }
|
---|
966 | return 0;
|
---|
967 | }
|
---|
968 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
969 | }
|
---|
970 |
|
---|
971 | VOID EditAssociations(HWND hwnd)
|
---|
972 | {
|
---|
973 | static CHAR stop = 0;
|
---|
974 |
|
---|
975 | if (stop)
|
---|
976 | return;
|
---|
977 | stop++;
|
---|
978 | if (!assloaded)
|
---|
979 | load_associations();
|
---|
980 | WinDlgBox(HWND_DESKTOP, hwnd, AssocDlgProc, FM3ModHandle, ASS_FRAME, NULL);
|
---|
981 | stop = 0;
|
---|
982 | }
|
---|
983 |
|
---|
984 | #pragma alloc_text(ASSOC2,free_associations,load_associations,save_associations,display_associations)
|
---|
985 | #pragma alloc_text(ASSOC2,ExecAssociation,AssocTextProc)
|
---|
986 | #pragma alloc_text(ASSOC,add_association,kill_association,AssocDlgProc,EditAssociations)
|
---|