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