1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: command.c 1521 2010-05-02 21:48:59Z gyoung $
|
---|
5 |
|
---|
6 | Custom commands
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2004, 2010 Steven H. Levine
|
---|
10 |
|
---|
11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
12 | 06 Jun 05 SHL Drop unused code
|
---|
13 | 14 Jul 06 SHL Use Runtime_Error
|
---|
14 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
15 | 15 Aug 06 SHL Better can't add message
|
---|
16 | 18 Sep 06 GKY Add replace command and update okay to add if changed
|
---|
17 | 17 Feb 07 GKY Move error messages etc to string file
|
---|
18 | 22 Mar 07 GKY Use QWL_USER
|
---|
19 | 23 Mar 07 GKY Replace doesn't change item position
|
---|
20 | 23 Mar 07 GKY Okay fails silently when item not changed
|
---|
21 | 19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
|
---|
22 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
23 | 06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
|
---|
24 | 29 Feb 08 GKY Changes to enable user settable command line length
|
---|
25 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
26 | 18 Jul 08 SHL Add Fortify support
|
---|
27 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
|
---|
28 | 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
|
---|
29 | 15 Oct 08 GKY Prevent asking to add %a on NormalizeCmdLine abort
|
---|
30 | 21 Dec 09 GKY Fix the environment so it can be saved, deleted and used consistently.
|
---|
31 | 21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command.
|
---|
32 | Added load_inicommand to load the IDs from the ini file.
|
---|
33 | 21 Dec 09 GKY Added 20 new hot keys for commands.
|
---|
34 | 21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c
|
---|
35 | 27 Dec 09 GKY Moved Commands to the INI file this makes commands.dat obsolete
|
---|
36 | 27 Dec 09 GKY Added QueryCommandSettings to streamline code
|
---|
37 | 27 Dec 09 GKY Made command hotkeys user selectable.
|
---|
38 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10).
|
---|
39 | Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
40 | 01 May 10 GKY Add ENVIRONMENT_SIZE variable to standardize this size everywhere.
|
---|
41 | 01 May 10 GKY Changes to move environment storage to INI file
|
---|
42 |
|
---|
43 | ***********************************************************************/
|
---|
44 |
|
---|
45 | #include <stdlib.h>
|
---|
46 | #include <string.h>
|
---|
47 | #include <share.h>
|
---|
48 |
|
---|
49 | #define INCL_DOS
|
---|
50 | #define INCL_WIN
|
---|
51 | #define INCL_LONGLONG // dircnrs.h
|
---|
52 |
|
---|
53 | #include "fm3dll.h"
|
---|
54 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
55 | #include "notebook.h" // Data declaration(s)
|
---|
56 | #include "init.h" // Data declaration(s)
|
---|
57 | #include "mainwnd.h" // Data declaration(s)
|
---|
58 | #include "newview.h" // Data declarations
|
---|
59 | #include "fm3dlg.h"
|
---|
60 | #include "fm3str.h"
|
---|
61 | #include "tools.h"
|
---|
62 | #include "arccnrs.h" // BldQuotedFileName
|
---|
63 | #include "errutil.h" // Dos_Error...
|
---|
64 | #include "strutil.h" // GetPString
|
---|
65 | #include "droplist.h" // AcceptOneDrop, DropHelp, GetOneDrop
|
---|
66 | #include "misc.h" // DrawTargetEmphasis
|
---|
67 | #include "systemf.h" // ExecOnList
|
---|
68 | #include "getnames.h" // insert_filename
|
---|
69 | #include "wrappers.h" // xfgets
|
---|
70 | #include "pathutil.h" // NormalizeCmdLine
|
---|
71 | #include "command.h"
|
---|
72 | #include "strips.h" // bstrip
|
---|
73 | #include "dirs.h" // save_dir2
|
---|
74 | #include "fortify.h"
|
---|
75 |
|
---|
76 | VOID load_inicommands(VOID);
|
---|
77 |
|
---|
78 | typedef struct
|
---|
79 | {
|
---|
80 | PSZ pszCmdLine;
|
---|
81 | CHAR title[100];
|
---|
82 | CHAR env[ENVIRONMENT_SIZE];
|
---|
83 | ULONG flags;
|
---|
84 | ULONG ID;
|
---|
85 | ULONG HotKeyID;
|
---|
86 | }
|
---|
87 | COMMAND;
|
---|
88 |
|
---|
89 | BOOL QueryCommandSettings(HWND hwnd, COMMAND *temp);
|
---|
90 | VOID save_commands(VOID);
|
---|
91 |
|
---|
92 | // Data defintions
|
---|
93 | #pragma data_seg(DATA1)
|
---|
94 |
|
---|
95 | static PSZ pszSrcFile = __FILE__;
|
---|
96 | static LINKCMDS *cmdtail;
|
---|
97 | static BOOL UsedCommandIDs[300];
|
---|
98 | static BOOL UsedHotKeyIDs[40];
|
---|
99 | static PSZ pszCommandsList;
|
---|
100 | static ULONG ulSizeCommandsList = 10000;
|
---|
101 | static BOOL fLoadCommandsFromINI = FALSE;
|
---|
102 |
|
---|
103 | #pragma data_seg(GLOBAL2)
|
---|
104 | LINKCMDS *cmdhead;
|
---|
105 | BOOL cmdloaded;
|
---|
106 |
|
---|
107 | MRESULT EXPENTRY CommandTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
108 | {
|
---|
109 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
110 | static BOOL emphasized = FALSE;
|
---|
111 |
|
---|
112 | switch (msg) {
|
---|
113 | case DM_DRAGOVER:
|
---|
114 | if (!emphasized) {
|
---|
115 | emphasized = TRUE;
|
---|
116 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
117 | }
|
---|
118 | if (AcceptOneDrop(hwnd, mp1, mp2))
|
---|
119 | return MRFROM2SHORT(DOR_DROP, DO_MOVE);
|
---|
120 | return MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
121 |
|
---|
122 | case DM_DRAGLEAVE:
|
---|
123 | if (emphasized) {
|
---|
124 | emphasized = FALSE;
|
---|
125 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
126 | }
|
---|
127 | break;
|
---|
128 |
|
---|
129 | case DM_DROPHELP:
|
---|
130 | DropHelp(mp1, mp2, hwnd, GetPString(IDS_DROPCMDHELPTEXT));
|
---|
131 | return 0;
|
---|
132 |
|
---|
133 | case DM_DROP:
|
---|
134 | {
|
---|
135 | char szFrom[CCHMAXPATH + 5];
|
---|
136 |
|
---|
137 | if (emphasized) {
|
---|
138 | emphasized = FALSE;
|
---|
139 | DrawTargetEmphasis(hwnd, emphasized);
|
---|
140 | }
|
---|
141 | if (GetOneDrop(hwnd, mp1, mp2, szFrom, CCHMAXPATH)) {
|
---|
142 | strcat(szFrom, " %a");
|
---|
143 | WinSetWindowText(hwnd, szFrom);
|
---|
144 | }
|
---|
145 | }
|
---|
146 | return 0;
|
---|
147 | }
|
---|
148 | return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
|
---|
149 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
150 | }
|
---|
151 |
|
---|
152 | MRESULT EXPENTRY ReOrderProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
153 | {
|
---|
154 | switch (msg) {
|
---|
155 | case WM_INITDLG:
|
---|
156 | if (!cmdhead) {
|
---|
157 | WinDismissDlg(hwnd, 0);
|
---|
158 | break;
|
---|
159 | }
|
---|
160 | {
|
---|
161 | LINKCMDS *info;
|
---|
162 | SHORT x;
|
---|
163 |
|
---|
164 | info = cmdhead;
|
---|
165 | while (info) {
|
---|
166 | x = (SHORT) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX, LM_INSERTITEM,
|
---|
167 | MPFROMSHORT(LIT_END),
|
---|
168 | MPFROMP(info->title));
|
---|
169 | if (x < 0) {
|
---|
170 | Runtime_Error(pszSrcFile, __LINE__, "no cmd");
|
---|
171 | WinDismissDlg(hwnd, 0);
|
---|
172 | }
|
---|
173 | else {
|
---|
174 | WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX, LM_SETITEMHANDLE,
|
---|
175 | MPFROMSHORT(x), MPFROMP(info));
|
---|
176 | }
|
---|
177 | info = info->next;
|
---|
178 | }
|
---|
179 | }
|
---|
180 | break;
|
---|
181 |
|
---|
182 | case WM_CONTROL:
|
---|
183 | return 0;
|
---|
184 |
|
---|
185 | case WM_COMMAND:
|
---|
186 | switch (SHORT1FROMMP(mp1)) {
|
---|
187 | case DID_CANCEL:
|
---|
188 | WinDismissDlg(hwnd, 0);
|
---|
189 | break;
|
---|
190 |
|
---|
191 | case DID_OK:
|
---|
192 | {
|
---|
193 | LINKCMDS *temphead = NULL, *info, *last = NULL, *temptail = NULL;
|
---|
194 | SHORT sSelect, numitems;
|
---|
195 |
|
---|
196 | sSelect = 0;
|
---|
197 | numitems = (SHORT) WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
198 | LM_QUERYITEMCOUNT,
|
---|
199 | MPVOID, MPVOID);
|
---|
200 | while (numitems) {
|
---|
201 | info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
202 | LM_QUERYITEMHANDLE,
|
---|
203 | MPFROMSHORT(sSelect++),
|
---|
204 | MPVOID);
|
---|
205 | if (info) {
|
---|
206 | if (!temphead) {
|
---|
207 | temphead = info;
|
---|
208 | info->prev = NULL;
|
---|
209 | }
|
---|
210 | else {
|
---|
211 | last->next = info;
|
---|
212 | info->prev = last;
|
---|
213 | }
|
---|
214 | temptail = info;
|
---|
215 | last = info;
|
---|
216 | info->next = NULL;
|
---|
217 | }
|
---|
218 | numitems--;
|
---|
219 | }
|
---|
220 | sSelect = 0;
|
---|
221 | numitems = (SHORT) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
222 | LM_QUERYITEMCOUNT,
|
---|
223 | MPVOID, MPVOID);
|
---|
224 | while (numitems) {
|
---|
225 | info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
226 | LM_QUERYITEMHANDLE,
|
---|
227 | MPFROMSHORT(sSelect++),
|
---|
228 | MPVOID);
|
---|
229 | if (info) {
|
---|
230 | if (!temphead) {
|
---|
231 | temphead = info;
|
---|
232 | info->prev = NULL;
|
---|
233 | }
|
---|
234 | else {
|
---|
235 | last->next = info;
|
---|
236 | info->prev = last;
|
---|
237 | }
|
---|
238 | temptail = info;
|
---|
239 | last = info;
|
---|
240 | info->next = NULL;
|
---|
241 | }
|
---|
242 | numitems--;
|
---|
243 | }
|
---|
244 | cmdhead = temphead;
|
---|
245 | cmdtail = temptail;
|
---|
246 | }
|
---|
247 | WinDismissDlg(hwnd, 1);
|
---|
248 | break;
|
---|
249 |
|
---|
250 | case IDM_HELP:
|
---|
251 | if (hwndHelp)
|
---|
252 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
|
---|
253 | MPFROM2SHORT(HELP_REORDERCOMMANDS, 0),
|
---|
254 | MPFROMSHORT(HM_RESOURCEID));
|
---|
255 | break;
|
---|
256 |
|
---|
257 | case RE_ADD:
|
---|
258 | {
|
---|
259 | SHORT sSelect, x;
|
---|
260 | LINKCMDS *info;
|
---|
261 |
|
---|
262 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
263 | LM_QUERYSELECTION,
|
---|
264 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
265 | while (sSelect >= 0) {
|
---|
266 | info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
267 | LM_QUERYITEMHANDLE,
|
---|
268 | MPFROMSHORT(sSelect), MPVOID);
|
---|
269 | if (info) {
|
---|
270 | x = (SHORT) WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
271 | LM_INSERTITEM,
|
---|
272 | MPFROM2SHORT(LIT_END, 0),
|
---|
273 | MPFROMP(info->title));
|
---|
274 | if (x >= 0) {
|
---|
275 | WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
276 | LM_SETITEMHANDLE,
|
---|
277 | MPFROMSHORT(x), MPFROMP(info));
|
---|
278 | WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX, LM_DELETEITEM,
|
---|
279 | MPFROMSHORT(sSelect), MPVOID);
|
---|
280 | }
|
---|
281 | }
|
---|
282 | else
|
---|
283 | WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX, LM_SELECTITEM,
|
---|
284 | MPFROMSHORT(sSelect), MPFROMSHORT(FALSE));
|
---|
285 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
286 | LM_QUERYSELECTION,
|
---|
287 | MPFROMSHORT(LIT_FIRST),
|
---|
288 | MPVOID);
|
---|
289 | }
|
---|
290 | }
|
---|
291 | break;
|
---|
292 |
|
---|
293 | case RE_REMOVE:
|
---|
294 | {
|
---|
295 | SHORT sSelect, x;
|
---|
296 | LINKCMDS *info;
|
---|
297 |
|
---|
298 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
299 | LM_QUERYSELECTION,
|
---|
300 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
301 | while (sSelect >= 0) {
|
---|
302 | info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
303 | LM_QUERYITEMHANDLE,
|
---|
304 | MPFROMSHORT(sSelect), MPVOID);
|
---|
305 | if (info) {
|
---|
306 | x = (SHORT) WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
307 | LM_INSERTITEM,
|
---|
308 | MPFROM2SHORT(LIT_END, 0),
|
---|
309 | MPFROMP(info->title));
|
---|
310 | if (x >= 0) {
|
---|
311 | WinSendDlgItemMsg(hwnd, RE_ADDLISTBOX,
|
---|
312 | LM_SETITEMHANDLE,
|
---|
313 | MPFROMSHORT(x), MPFROMP(info));
|
---|
314 | WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX, LM_DELETEITEM,
|
---|
315 | MPFROMSHORT(sSelect), MPVOID);
|
---|
316 | }
|
---|
317 | }
|
---|
318 | else
|
---|
319 | WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX, LM_SELECTITEM,
|
---|
320 | MPFROMSHORT(sSelect), MPFROMSHORT(FALSE));
|
---|
321 | sSelect = (USHORT) WinSendDlgItemMsg(hwnd, RE_REMOVELISTBOX,
|
---|
322 | LM_QUERYSELECTION,
|
---|
323 | MPFROMSHORT(LIT_FIRST),
|
---|
324 | MPVOID);
|
---|
325 | }
|
---|
326 | }
|
---|
327 | break;
|
---|
328 | }
|
---|
329 | return 0;
|
---|
330 | }
|
---|
331 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
332 | }
|
---|
333 |
|
---|
334 | CHAR *command_title(INT cx)
|
---|
335 | {
|
---|
336 | static CHAR duh[] = "???";
|
---|
337 | LINKCMDS *info;
|
---|
338 | INT x = 0;
|
---|
339 |
|
---|
340 | if (!cmdloaded)
|
---|
341 | load_commands();
|
---|
342 | info = cmdhead;
|
---|
343 | while (info) {
|
---|
344 | if (x == cx)
|
---|
345 | return info->title;
|
---|
346 | info = info->next;
|
---|
347 | }
|
---|
348 | return duh;
|
---|
349 | }
|
---|
350 |
|
---|
351 | VOID free_commands(VOID)
|
---|
352 | {
|
---|
353 | LINKCMDS *info, *next;
|
---|
354 |
|
---|
355 | info = cmdhead;
|
---|
356 | while (info) {
|
---|
357 | next = info->next;
|
---|
358 | xfree(info->title, pszSrcFile, __LINE__);
|
---|
359 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
360 | xfree(info->env, pszSrcFile, __LINE__);
|
---|
361 | free(info);
|
---|
362 | info = next;
|
---|
363 | }
|
---|
364 | free(pszCommandsList);
|
---|
365 | cmdhead = cmdtail = NULL;
|
---|
366 | }
|
---|
367 |
|
---|
368 | VOID load_commands(VOID)
|
---|
369 | {
|
---|
370 | FILE *fp;
|
---|
371 | LINKCMDS *info;
|
---|
372 | PSZ pszCmdLine;
|
---|
373 | CHAR title[100];
|
---|
374 | CHAR flags[34];
|
---|
375 | //CHAR *p;
|
---|
376 | ULONG size;
|
---|
377 |
|
---|
378 |
|
---|
379 | size = sizeof(BOOL) * 300;
|
---|
380 | PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.UsedCommandIDs", &UsedCommandIDs,
|
---|
381 | &size);
|
---|
382 | size = sizeof(BOOL) * 40;
|
---|
383 | PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.UsedHotKeyIDs", &UsedHotKeyIDs,
|
---|
384 | &size);
|
---|
385 | size = sizeof(BOOL);
|
---|
386 | PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.LoadCommandsFromINI",
|
---|
387 | &fLoadCommandsFromINI, &size);
|
---|
388 | if (!fLoadCommandsFromINI) {
|
---|
389 | if (cmdhead)
|
---|
390 | free_commands();
|
---|
391 | cmdloaded = TRUE;
|
---|
392 | pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
393 | pszCommandsList = xmallocz(ulSizeCommandsList, pszSrcFile, __LINE__);
|
---|
394 | if (pszCmdLine) {
|
---|
395 | BldFullPathName(pszCmdLine, pFM2SaveDirectory, PCSZ_COMMANDSDAT);
|
---|
396 | fp = _fsopen(pszCmdLine, "r", SH_DENYWR);
|
---|
397 | if (fp) {
|
---|
398 | while (!feof(fp)) {
|
---|
399 | if (!xfgets_bstripcr(title, sizeof(title), fp, pszSrcFile, __LINE__))
|
---|
400 | break;
|
---|
401 | if (!*title || *title == ';')
|
---|
402 | continue;
|
---|
403 | if (!xfgets_bstripcr(pszCmdLine, MaxComLineStrg, fp, pszSrcFile, __LINE__))
|
---|
404 | break; /* error! */
|
---|
405 | if (!xfgets_bstripcr(flags, sizeof(flags), fp, pszSrcFile, __LINE__))
|
---|
406 | break;
|
---|
407 | flags[34] = 0;
|
---|
408 | if (!pszCmdLine)
|
---|
409 | continue;
|
---|
410 | info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__);
|
---|
411 | if (info) {
|
---|
412 | # ifdef FORTIFY
|
---|
413 | Fortify_SetOwner(info, 1);
|
---|
414 | Fortify_SetScope(info, 1);
|
---|
415 | # endif
|
---|
416 | info->pszCmdLine = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
|
---|
417 |
|
---|
418 | if (pszCommandsList) {
|
---|
419 | strcpy(pszCommandsList + strlen(pszCommandsList), title);
|
---|
420 | strcpy(pszCommandsList + strlen(pszCommandsList), ";");
|
---|
421 | }
|
---|
422 | info->title = xstrdup(title, pszSrcFile, __LINE__);
|
---|
423 | info->flags = atol(flags);
|
---|
424 | if (!info->pszCmdLine || !info->title) {
|
---|
425 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
426 | xfree(info->title, pszSrcFile, __LINE__);
|
---|
427 | free(info);
|
---|
428 | break;
|
---|
429 | }
|
---|
430 | # ifdef FORTIFY
|
---|
431 | Fortify_SetOwner(info->pszCmdLine, 1);
|
---|
432 | Fortify_SetScope(info->pszCmdLine, 1);
|
---|
433 | Fortify_SetOwner(info->title, 1);
|
---|
434 | Fortify_SetScope(info->title, 1);
|
---|
435 | # endif
|
---|
436 | if (!cmdhead)
|
---|
437 | cmdhead = info;
|
---|
438 | else {
|
---|
439 | cmdtail->next = info;
|
---|
440 | info->prev = cmdtail;
|
---|
441 | }
|
---|
442 | cmdtail = info;
|
---|
443 | }
|
---|
444 | }
|
---|
445 | free(pszCmdLine);
|
---|
446 | fclose(fp);
|
---|
447 | if (pszCommandsList) {
|
---|
448 | ulSizeCommandsList = strlen(pszCommandsList) + 1;
|
---|
449 | }
|
---|
450 | }
|
---|
451 | }
|
---|
452 | }
|
---|
453 | load_inicommands();
|
---|
454 | }
|
---|
455 |
|
---|
456 | /**
|
---|
457 | * load_inicommand loads the data from the ini file into an info struct
|
---|
458 | * after COMMANDS.DAT has been loaded; It generates new IDs where necessary
|
---|
459 | * it saves the environment from the old ini key and deletes it as needed
|
---|
460 | **/
|
---|
461 |
|
---|
462 | VOID load_inicommands(VOID)
|
---|
463 | {
|
---|
464 | LINKCMDS *info;;
|
---|
465 | INT x = 0;
|
---|
466 | INT y = 0;
|
---|
467 | ULONG ID = 0;
|
---|
468 | ULONG HotKeyID = 0;
|
---|
469 | CHAR env[ENVIRONMENT_SIZE];
|
---|
470 | CHAR key[120];
|
---|
471 | CHAR szTitle[100];
|
---|
472 | ULONG size;
|
---|
473 | CHAR *p, *pp;
|
---|
474 | PSZ pszCmdLine;
|
---|
475 | ULONG flags;
|
---|
476 |
|
---|
477 | # ifdef FORTIFY
|
---|
478 | Fortify_EnterScope();
|
---|
479 | # endif
|
---|
480 | pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
481 | if (pszCmdLine) {
|
---|
482 | if (fLoadCommandsFromINI) {
|
---|
483 | if (cmdhead)
|
---|
484 | free_commands();
|
---|
485 | cmdloaded = TRUE;
|
---|
486 | size = sizeof(ULONG);
|
---|
487 | PrfQueryProfileData(fmprof, FM3Str, "COMMANDS.SizeSortOrder",
|
---|
488 | &ulSizeCommandsList, &size);
|
---|
489 | pszCommandsList = xmallocz(ulSizeCommandsList, pszSrcFile, __LINE__);
|
---|
490 | if (pszCommandsList) {
|
---|
491 | PrfQueryProfileString(fmprof, FM3Str, "COMMANDS.SortOrder",
|
---|
492 | NullStr, pszCommandsList, ulSizeCommandsList);
|
---|
493 | p = pszCommandsList;
|
---|
494 | while (*p == ';')
|
---|
495 | p++;
|
---|
496 | while (*p) {
|
---|
497 | *szTitle = 0;
|
---|
498 | pp = szTitle;
|
---|
499 | while (*p && *p != ';')
|
---|
500 | *pp++ = *p++;
|
---|
501 | *pp = 0;
|
---|
502 | while (*p == ';')
|
---|
503 | p++;
|
---|
504 | if (*szTitle) {
|
---|
505 | bstripcr(szTitle);
|
---|
506 | sprintf(key, "COMMAND.%sID", szTitle);
|
---|
507 | size = sizeof(ULONG);
|
---|
508 | PrfQueryProfileData(fmprof, FM3Str, key, &ID, &size);
|
---|
509 | sprintf(key, "COMMAND.%sHotKeyID", szTitle);
|
---|
510 | size = sizeof(ULONG);
|
---|
511 | PrfQueryProfileData(fmprof, FM3Str, key, &HotKeyID, &size);
|
---|
512 | sprintf(key, "COMMAND.%sflags", szTitle);
|
---|
513 | size = sizeof(ULONG);
|
---|
514 | PrfQueryProfileData(fmprof, FM3Str, key, &flags, &size);
|
---|
515 | sprintf(key, "COMMAND.%senv", szTitle);
|
---|
516 | PrfQueryProfileString(fmprof, FM3Str, key, NullStr, env, sizeof(env));
|
---|
517 | sprintf(key, "COMMAND.%sCmdLine", szTitle);
|
---|
518 | PrfQueryProfileString(fmprof, FM3Str, key, NullStr, pszCmdLine, MaxComLineStrg);
|
---|
519 | }
|
---|
520 | info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__);
|
---|
521 | if (info) {
|
---|
522 | # ifdef FORTIFY
|
---|
523 | Fortify_SetOwner(info, 1);
|
---|
524 | Fortify_SetScope(info, 1);
|
---|
525 | # endif
|
---|
526 | info->pszCmdLine = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
|
---|
527 | info->title = xstrdup(szTitle, pszSrcFile, __LINE__);
|
---|
528 | info->flags = flags;
|
---|
529 | if (env != NullStr)
|
---|
530 | info->env = xstrdup(env, pszSrcFile, __LINE__);
|
---|
531 | info->ID = ID;
|
---|
532 | info->HotKeyID = HotKeyID;
|
---|
533 | if (!info->pszCmdLine || !info->title) {
|
---|
534 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
535 | xfree(info->title, pszSrcFile, __LINE__);
|
---|
536 | xfree(info->env, pszSrcFile, __LINE__);
|
---|
537 | free(info);
|
---|
538 | break;
|
---|
539 | }
|
---|
540 | if (!cmdhead)
|
---|
541 | cmdhead = info;
|
---|
542 | else {
|
---|
543 | cmdtail->next = info;
|
---|
544 | info->prev = cmdtail;
|
---|
545 | }
|
---|
546 | cmdtail = info;
|
---|
547 | }
|
---|
548 | }
|
---|
549 | }
|
---|
550 | }
|
---|
551 | else {
|
---|
552 | info = cmdhead;
|
---|
553 | while (info) {
|
---|
554 | bstripcr(info->title);
|
---|
555 | sprintf(key, "COMMAND.%sID", info->title);
|
---|
556 | size = sizeof(ULONG);
|
---|
557 | PrfQueryProfileData(fmprof, FM3Str, key, &ID, &size);
|
---|
558 | sprintf(key, "COMMAND.%sHotKeyID", info->title);
|
---|
559 | size = sizeof(ULONG);
|
---|
560 | PrfQueryProfileData(fmprof, FM3Str, key, &HotKeyID, &size);
|
---|
561 | sprintf(key, "COMMAND.%senv", info->title);
|
---|
562 | PrfQueryProfileString(fmprof, FM3Str, key, NullStr, env, sizeof(env));
|
---|
563 | if (ID != 0) {
|
---|
564 | if (env != NullStr)
|
---|
565 | info->env = xstrdup(env, pszSrcFile, __LINE__);
|
---|
566 | info->ID = ID;
|
---|
567 | info->HotKeyID = HotKeyID;
|
---|
568 | }
|
---|
569 | //This updates the old commands.dat file to the new format
|
---|
570 | //assigning the IDs based on file order or on next available ID
|
---|
571 | else {
|
---|
572 | for (x = 0; x < 300; x++) {
|
---|
573 | if (!UsedCommandIDs[x]) {
|
---|
574 | ID = info->ID = IDM_COMMANDSTART + x;
|
---|
575 | UsedCommandIDs[x] = TRUE;
|
---|
576 | for (y = 0; y < 40; y++) {
|
---|
577 | if (!UsedHotKeyIDs[y]) {
|
---|
578 | HotKeyID = info->HotKeyID = IDM_COMMANDNUM0 + y;
|
---|
579 | UsedHotKeyIDs[y] = TRUE;
|
---|
580 | break;
|
---|
581 | }
|
---|
582 | }
|
---|
583 | break;
|
---|
584 | }
|
---|
585 | if (x == 299)
|
---|
586 | saymsg(MB_OK | MB_ICONEXCLAMATION , HWND_DESKTOP,
|
---|
587 | GetPString(IDS_COMMANDSLIMITTITLETEXT),
|
---|
588 | GetPString(IDS_COMMANDSLIMITREACHEDTEXT ));
|
---|
589 | }
|
---|
590 | PrfQueryProfileString(fmprof, FM3Str, info->pszCmdLine, NullStr, env, sizeof(env));
|
---|
591 | info->env = xstrdup(env, pszSrcFile, __LINE__);
|
---|
592 | }
|
---|
593 | ID = 0;
|
---|
594 | HotKeyID = 0;
|
---|
595 | info = info->next;
|
---|
596 | }
|
---|
597 | fLoadCommandsFromINI = TRUE;
|
---|
598 | save_commands();
|
---|
599 | }
|
---|
600 | free(pszCmdLine);
|
---|
601 | }
|
---|
602 | }
|
---|
603 |
|
---|
604 | VOID save_commands(VOID)
|
---|
605 | {
|
---|
606 | LINKCMDS *info;
|
---|
607 | CHAR key[120];
|
---|
608 |
|
---|
609 | if (!cmdloaded || !cmdhead)
|
---|
610 | return;
|
---|
611 |
|
---|
612 | info = cmdhead;
|
---|
613 | pszCommandsList[0] = 0;
|
---|
614 | while (info) {
|
---|
615 | sprintf(key, "COMMAND.%sflags", info->title);
|
---|
616 | PrfWriteProfileData(fmprof, FM3Str, key, &info->flags, sizeof(ULONG));
|
---|
617 | sprintf(key, "COMMAND.%sCmdLine", info->title);
|
---|
618 | PrfWriteProfileString(fmprof, FM3Str, key, info->pszCmdLine);
|
---|
619 | bstripcr(info->title);
|
---|
620 | sprintf(key, "COMMAND.%sID", info->title);
|
---|
621 | PrfWriteProfileData(fmprof, FM3Str, key, &info->ID, sizeof(INT));
|
---|
622 | sprintf(key, "COMMAND.%sHotKeyID", info->title);
|
---|
623 | PrfWriteProfileData(fmprof, FM3Str, key, &info->HotKeyID, sizeof(INT));
|
---|
624 | if (info->env != NullStr) {
|
---|
625 | sprintf(key, "COMMAND.%senv", info->title);
|
---|
626 | PrfWriteProfileString(fmprof, FM3Str, key, info->env);
|
---|
627 | }
|
---|
628 | if ((strlen(pszCommandsList) + strlen(info->title) + 1) > ulSizeCommandsList)
|
---|
629 | pszCommandsList = xrealloc(pszCommandsList,
|
---|
630 | ulSizeCommandsList + strlen(info->title) + 1,
|
---|
631 | pszSrcFile, __LINE__);
|
---|
632 | strcpy(pszCommandsList + strlen(pszCommandsList), info->title);
|
---|
633 | strcpy(pszCommandsList + strlen(pszCommandsList), ";");
|
---|
634 | info = info->next;
|
---|
635 | } // while info
|
---|
636 | PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.UsedCommandIDs", &UsedCommandIDs,
|
---|
637 | sizeof(BOOL) * 300);
|
---|
638 | PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.UsedHotKeyIDs", &UsedHotKeyIDs,
|
---|
639 | sizeof(BOOL) * 40);
|
---|
640 | ulSizeCommandsList = strlen(pszCommandsList) + 1;
|
---|
641 | PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.SizeSortOrder",
|
---|
642 | &ulSizeCommandsList, sizeof(ULONG));
|
---|
643 | PrfWriteProfileString(fmprof, FM3Str, "COMMANDS.SortOrder", pszCommandsList);
|
---|
644 | PrfWriteProfileData(fmprof, FM3Str, "COMMANDS.LoadCommandsFromINI",
|
---|
645 | &fLoadCommandsFromINI, sizeof(BOOL));
|
---|
646 | }
|
---|
647 |
|
---|
648 | //== add_command() Add command to list ==
|
---|
649 |
|
---|
650 | LINKCMDS *add_command(COMMAND *addme, BOOL fDontCheckHotKey)
|
---|
651 | {
|
---|
652 | LINKCMDS *info;
|
---|
653 | INT x;
|
---|
654 | INT y;
|
---|
655 | APIRET ret;
|
---|
656 |
|
---|
657 | if (!addme || !*addme->pszCmdLine || !*addme->title)
|
---|
658 | return NULL; // No data
|
---|
659 | # ifdef FORTIFY
|
---|
660 | Fortify_EnterScope();
|
---|
661 | # endif
|
---|
662 | info = cmdhead;
|
---|
663 | while (info) {
|
---|
664 | if (!stricmp(info->title, addme->title))
|
---|
665 | return NULL; // Got a dup
|
---|
666 | info = info->next;
|
---|
667 | }
|
---|
668 | if (!fDontCheckHotKey && UsedHotKeyIDs[addme->HotKeyID - IDM_COMMANDNUM0]) {
|
---|
669 | info = cmdhead;
|
---|
670 | while (info) {
|
---|
671 | if (info->HotKeyID == addme->HotKeyID) { //avoid assigning hot key to multiple commands
|
---|
672 | ret = saymsg(MB_YESNOCANCEL, HWND_DESKTOP, NullStr,
|
---|
673 | GetPString(IDS_DUPLICATEHOTKEYTEXT));
|
---|
674 | if (ret == MBID_YES) {
|
---|
675 | info->HotKeyID = 0;
|
---|
676 | UsedHotKeyIDs[addme->HotKeyID - IDM_COMMANDNUM0] = FALSE;
|
---|
677 | break;
|
---|
678 | }
|
---|
679 | else if (ret == MBID_NO) {
|
---|
680 | addme->HotKeyID = 0;
|
---|
681 | break;
|
---|
682 | }
|
---|
683 | else
|
---|
684 | return NULL;
|
---|
685 | }
|
---|
686 | info = info->next;
|
---|
687 | }
|
---|
688 | }
|
---|
689 | info = xmallocz(sizeof(LINKCMDS), pszSrcFile, __LINE__);
|
---|
690 | if (!info)
|
---|
691 | return NULL;
|
---|
692 | info->pszCmdLine = xstrdup(addme->pszCmdLine, pszSrcFile, __LINE__);
|
---|
693 | info->title = xstrdup(addme->title, pszSrcFile, __LINE__);
|
---|
694 | info->HotKeyID = addme->HotKeyID;
|
---|
695 | info->ID = addme->ID;
|
---|
696 | if (info->HotKeyID >= IDM_COMMANDNUM0 && info->HotKeyID <= IDM_COMMANDNUM39) {
|
---|
697 | UsedHotKeyIDs[info->HotKeyID - IDM_COMMANDNUM0] = TRUE;
|
---|
698 | }
|
---|
699 | else
|
---|
700 | info->HotKeyID = 0;
|
---|
701 | if (!info->ID) {
|
---|
702 | //profile updated by save_commands
|
---|
703 | for (x = 0; x < 300; x++) {
|
---|
704 | if (!UsedCommandIDs[x]) {
|
---|
705 | info->ID = IDM_COMMANDSTART + x;
|
---|
706 | UsedCommandIDs[x] = TRUE;
|
---|
707 | if (!info->HotKeyID && !fDontCheckHotKey) {
|
---|
708 | for (y = 0; y < 40; y++) {
|
---|
709 | if (!UsedHotKeyIDs[y]) {
|
---|
710 | info->HotKeyID = IDM_COMMANDNUM0 + y;
|
---|
711 | UsedHotKeyIDs[y] = TRUE;
|
---|
712 | break;
|
---|
713 | }
|
---|
714 | }
|
---|
715 | }
|
---|
716 | break;
|
---|
717 | }
|
---|
718 | if (x == 299)
|
---|
719 | saymsg(MB_OK | MB_ICONEXCLAMATION , HWND_DESKTOP,
|
---|
720 | GetPString(IDS_COMMANDSLIMITTITLETEXT),
|
---|
721 | GetPString(IDS_COMMANDSLIMITREACHEDTEXT ));
|
---|
722 | }
|
---|
723 | }
|
---|
724 | if (addme->flags)
|
---|
725 | info->flags = addme->flags;
|
---|
726 | if (addme->env)
|
---|
727 | info->env = xstrdup(addme->env, pszSrcFile, __LINE__);
|
---|
728 | if (!info->pszCmdLine || !info->title || !info->ID) {
|
---|
729 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
730 | xfree(info->title, pszSrcFile, __LINE__);
|
---|
731 | xfree(info->env, pszSrcFile, __LINE__);
|
---|
732 | free(info);
|
---|
733 | return NULL;
|
---|
734 | }
|
---|
735 | if (!cmdhead) /* only item in list */
|
---|
736 | cmdhead = cmdtail = info;
|
---|
737 | else {
|
---|
738 | /* place at tail */
|
---|
739 | cmdtail->next = info;
|
---|
740 | info->prev = cmdtail;
|
---|
741 | cmdtail = info;
|
---|
742 | }
|
---|
743 | pszCommandsList = xrealloc(pszCommandsList, ulSizeCommandsList + strlen(info->title) + 1,
|
---|
744 | pszSrcFile, __LINE__);
|
---|
745 | if (pszCommandsList) {
|
---|
746 | strcpy(pszCommandsList + strlen(pszCommandsList), info->title);
|
---|
747 | strcpy(pszCommandsList + strlen(pszCommandsList), ";");
|
---|
748 | ulSizeCommandsList = ulSizeCommandsList + strlen(info->title) + 1;
|
---|
749 | }
|
---|
750 | else {
|
---|
751 | pszCommandsList = xmallocz(ulSizeCommandsList, pszSrcFile, __LINE__);
|
---|
752 | if (pszCommandsList)
|
---|
753 | PrfQueryProfileString(fmprof, FM3Str, "COMMANDS.SortOrder",
|
---|
754 | NullStr, pszCommandsList, ulSizeCommandsList);
|
---|
755 | return 0;
|
---|
756 | }
|
---|
757 | return info;
|
---|
758 | }
|
---|
759 |
|
---|
760 | BOOL kill_command(CHAR * killme)
|
---|
761 | {
|
---|
762 | LINKCMDS *info;
|
---|
763 |
|
---|
764 | if (killme && *killme) {
|
---|
765 | info = cmdhead;
|
---|
766 | while (info) {
|
---|
767 | if (!stricmp(info->title, killme)) {
|
---|
768 | UsedCommandIDs[info->ID - IDM_COMMANDSTART] = FALSE;
|
---|
769 | if (info->HotKeyID)
|
---|
770 | UsedHotKeyIDs[info->HotKeyID - IDM_COMMANDNUM0] = FALSE;
|
---|
771 | if (info == cmdhead) {
|
---|
772 | cmdhead = info->next;
|
---|
773 | if (info == cmdtail)
|
---|
774 | cmdtail = info->prev;
|
---|
775 | }
|
---|
776 | else {
|
---|
777 | if (info->next)
|
---|
778 | (info->next)->prev = info->prev;
|
---|
779 | if (info->prev)
|
---|
780 | (info->prev)->next = info->next;
|
---|
781 | if (info == cmdtail)
|
---|
782 | cmdtail = info->prev;
|
---|
783 | }
|
---|
784 | xfree(info->pszCmdLine, pszSrcFile, __LINE__);
|
---|
785 | xfree(info->title, pszSrcFile, __LINE__);
|
---|
786 | xfree(info->env, pszSrcFile, __LINE__);
|
---|
787 | free(info);
|
---|
788 | return TRUE;
|
---|
789 | }
|
---|
790 | info = info->next;
|
---|
791 | }
|
---|
792 | }
|
---|
793 | # ifdef FORTIFY
|
---|
794 | Fortify_LeaveScope();
|
---|
795 | # endif
|
---|
796 | return FALSE;
|
---|
797 | }
|
---|
798 |
|
---|
799 | BOOL QueryCommandSettings(HWND hwnd, COMMAND *temp)
|
---|
800 | {
|
---|
801 | PSZ pszWorkBuf;
|
---|
802 | APIRET ret;
|
---|
803 | CHAR env[ENVIRONMENT_SIZE];
|
---|
804 | INT x;
|
---|
805 |
|
---|
806 | pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
807 | if (!pszWorkBuf) {
|
---|
808 | return FALSE; //already complained
|
---|
809 | }
|
---|
810 | WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp->pszCmdLine);
|
---|
811 | NormalizeCmdLine(pszWorkBuf, temp->pszCmdLine);
|
---|
812 | memcpy(temp->pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
|
---|
813 | free(pszWorkBuf);
|
---|
814 | if (fCancelAction) {
|
---|
815 | fCancelAction = FALSE;
|
---|
816 | return FALSE;
|
---|
817 | }
|
---|
818 | if (!strchr(temp->pszCmdLine, '%')) {
|
---|
819 | ret = saymsg(MB_YESNO,
|
---|
820 | HWND_DESKTOP,
|
---|
821 | NullStr,
|
---|
822 | GetPString(IDS_TOACTONSELECTEDTEXT));
|
---|
823 | if (ret == MBID_YES)
|
---|
824 | strcat(temp->pszCmdLine, " %a");
|
---|
825 | }
|
---|
826 | WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp->title), temp->title);
|
---|
827 | bstripcr(temp->title);
|
---|
828 | temp->flags = CheckExecutibleFlags(hwnd, 3);
|
---|
829 | *env = 0;
|
---|
830 | WinQueryDlgItemText(hwnd, CMD_ENVIRON, ENVIRONMENT_SIZE - 1, env);
|
---|
831 | bstripcr(env);
|
---|
832 | if (*env)
|
---|
833 | strcpy(temp->env, env);
|
---|
834 | x = (SHORT) WinSendDlgItemMsg(hwnd, CMD_HOTKEY,
|
---|
835 | LM_QUERYSELECTION,
|
---|
836 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
837 | if (x < 40)
|
---|
838 | temp->HotKeyID = x + IDM_COMMANDNUM0;
|
---|
839 | else
|
---|
840 | temp->HotKeyID = 0;
|
---|
841 | //DbgMsg(pszSrcFile, __LINE__, "info %i", temp->HotKeyID);
|
---|
842 | return TRUE;
|
---|
843 | }
|
---|
844 |
|
---|
845 | MRESULT EXPENTRY CommandDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
846 | {
|
---|
847 | SHORT x, y;
|
---|
848 | LINKCMDS *info;
|
---|
849 |
|
---|
850 | # ifdef FORTIFY
|
---|
851 | Fortify_EnterScope();
|
---|
852 | # endif
|
---|
853 | switch (msg) {
|
---|
854 | case WM_INITDLG:
|
---|
855 | WinSendDlgItemMsg(hwnd, CMD_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
856 | WinSendDlgItemMsg(hwnd, CMD_CL, EM_SETTEXTLIMIT,
|
---|
857 | MPFROM2SHORT(MaxComLineStrg - 1, 0), MPVOID);
|
---|
858 | WinSendDlgItemMsg(hwnd, CMD_TITLE, EM_SETTEXTLIMIT,
|
---|
859 | MPFROM2SHORT(99, 0), MPVOID);
|
---|
860 | WinSetDlgItemText(hwnd, CMD_CL, NullStr);
|
---|
861 | WinSetDlgItemText(hwnd, CMD_TITLE, NullStr);
|
---|
862 | WinCheckButton(hwnd, CMD_DEFAULT, TRUE);
|
---|
863 | WinCheckButton(hwnd, CMD_PROMPT, FALSE);
|
---|
864 | WinCheckButton(hwnd, CMD_ONCE, FALSE);
|
---|
865 | info = cmdhead;
|
---|
866 | while (info) {
|
---|
867 | x = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX, LM_INSERTITEM,
|
---|
868 | MPFROM2SHORT(LIT_END, 0),
|
---|
869 | MPFROMP(info->title));
|
---|
870 | if (x >= 0)
|
---|
871 | WinSendDlgItemMsg(hwnd, CMD_LISTBOX, LM_SETITEMHANDLE,
|
---|
872 | MPFROMSHORT(x), MPFROMP(info));
|
---|
873 | info = info->next;
|
---|
874 | }
|
---|
875 | WinSendDlgItemMsg(hwnd, CMD_LISTBOX, LM_SELECTITEM,
|
---|
876 | MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
877 | {
|
---|
878 | PFNWP oldproc;
|
---|
879 |
|
---|
880 | oldproc = WinSubclassWindow(WinWindowFromID(hwnd, CMD_CL),
|
---|
881 | (PFNWP) CommandTextProc);
|
---|
882 | if (oldproc)
|
---|
883 | WinSetWindowPtr(WinWindowFromID(hwnd, CMD_CL), QWL_USER, (PVOID) oldproc);
|
---|
884 | }
|
---|
885 | break;
|
---|
886 |
|
---|
887 | case WM_CONTROL:
|
---|
888 | if (SHORT1FROMMP(mp1) == CMD_LISTBOX) {
|
---|
889 | switch (SHORT2FROMMP(mp1)) {
|
---|
890 | case LN_ENTER:
|
---|
891 | case LN_SELECT:
|
---|
892 | x = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
|
---|
893 | LM_QUERYSELECTION,
|
---|
894 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
895 | if (x >= 0) {
|
---|
896 | info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
|
---|
897 | LM_QUERYITEMHANDLE,
|
---|
898 | MPFROMSHORT(x), MPVOID);
|
---|
899 | if (!info) {
|
---|
900 | Runtime_Error(pszSrcFile, __LINE__, "LM_QUERYITEMHANDLE");
|
---|
901 | break;
|
---|
902 | }
|
---|
903 | WinSetDlgItemText(hwnd, CMD_CL, info->pszCmdLine);
|
---|
904 | if (!(info->flags & 1023))
|
---|
905 | WinCheckButton(hwnd, CMD_DEFAULT, TRUE);
|
---|
906 | else {
|
---|
907 | if (info->flags & FULLSCREEN)
|
---|
908 | WinCheckButton(hwnd, CMD_FULLSCREEN, TRUE);
|
---|
909 | else if (info->flags & MINIMIZED)
|
---|
910 | WinCheckButton(hwnd, CMD_MINIMIZED, TRUE);
|
---|
911 | else if (info->flags & MAXIMIZED)
|
---|
912 | WinCheckButton(hwnd, CMD_MAXIMIZED, TRUE);
|
---|
913 | else if (info->flags & INVISIBLE)
|
---|
914 | WinCheckButton(hwnd, CMD_INVISIBLE, TRUE);
|
---|
915 | }
|
---|
916 | WinCheckButton(hwnd, CMD_PROMPT, ((info->flags & PROMPT) != 0));
|
---|
917 | WinCheckButton(hwnd, CMD_KEEP, ((info->flags & KEEP) != 0));
|
---|
918 | WinCheckButton(hwnd, CMD_ONCE, ((info->flags & ONCE) != 0));
|
---|
919 | WinSetDlgItemText(hwnd, CMD_TITLE, info->title);
|
---|
920 | if (info->env)
|
---|
921 | WinSetDlgItemText(hwnd, CMD_ENVIRON, info->env);
|
---|
922 | else
|
---|
923 | WinSetDlgItemText(hwnd, CMD_ENVIRON, NullStr);
|
---|
924 | for (x = 0; x < 40; x++) {
|
---|
925 | CHAR s[CCHMAXPATH + 24];
|
---|
926 |
|
---|
927 | sprintf(s, "%s%s%s",
|
---|
928 | x < IDM_COMMANDNUM20 - IDM_COMMANDNUM0 ? "Ctrl+" : NullStr,
|
---|
929 | x > IDM_COMMANDNUM19 - IDM_COMMANDNUM0 ? "Alt+" : NullStr,
|
---|
930 | (x > IDM_COMMANDNUM9 - IDM_COMMANDNUM0 &&
|
---|
931 | x < IDM_COMMANDNUM20 - IDM_COMMANDNUM0) ||
|
---|
932 | x > IDM_COMMANDNUM29 - IDM_COMMANDNUM0 ? "Shift+" : NullStr);
|
---|
933 | sprintf(&s[strlen(s)], "%d", (x % 10) + 1 == 10 ? 0 : (x % 10) + 1);
|
---|
934 | sprintf(&s[strlen(s)], " %s", UsedHotKeyIDs[x] ? "(in use)" : NullStr);
|
---|
935 | WinSendMsg(WinWindowFromID(hwnd, CMD_HOTKEY), LM_INSERTITEM,
|
---|
936 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
937 | if (x == 39)
|
---|
938 | WinSendMsg(WinWindowFromID(hwnd, CMD_HOTKEY), LM_INSERTITEM,
|
---|
939 | MPFROM2SHORT(LIT_END, 0), MPFROMP("none"));
|
---|
940 | if (info->HotKeyID == x + IDM_COMMANDNUM0)
|
---|
941 | WinSendMsg(WinWindowFromID(hwnd, CMD_HOTKEY), LM_SELECTITEM,
|
---|
942 | MPFROM2SHORT(x, 0), MPFROMLONG(TRUE));
|
---|
943 | if (x == 39 && info->HotKeyID == 0)
|
---|
944 | WinSendMsg(WinWindowFromID(hwnd, CMD_HOTKEY), LM_SELECTITEM,
|
---|
945 | MPFROM2SHORT(x + 1, 0), MPFROMLONG(TRUE));
|
---|
946 | } // for
|
---|
947 | }
|
---|
948 | break;
|
---|
949 | }
|
---|
950 | }
|
---|
951 | return 0;
|
---|
952 |
|
---|
953 | case WM_COMMAND:
|
---|
954 | switch (SHORT1FROMMP(mp1)) {
|
---|
955 | case CMD_FIND:
|
---|
956 | {
|
---|
957 | CHAR filename[CCHMAXPATH + 9], szfilename[CCHMAXPATH + 9];
|
---|
958 |
|
---|
959 | *filename = 0;
|
---|
960 | if (insert_filename(hwnd, filename, 2, FALSE) && *filename) {
|
---|
961 | BldQuotedFileName(szfilename, filename);
|
---|
962 | WinSetDlgItemText(hwnd, CMD_CL, szfilename);
|
---|
963 | }
|
---|
964 | }
|
---|
965 | break;
|
---|
966 |
|
---|
967 | case CMD_REORDER:
|
---|
968 | if (!cmdhead || !cmdhead->next) {
|
---|
969 | Runtime_Error(pszSrcFile, __LINE__, "no cmd");
|
---|
970 | break;
|
---|
971 | }
|
---|
972 | if (WinDlgBox(HWND_DESKTOP, hwnd, ReOrderProc, FM3ModHandle,
|
---|
973 | RE_FRAME, MPVOID)) {
|
---|
974 | WinSendDlgItemMsg(hwnd, CMD_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
975 | WinSetDlgItemText(hwnd, CMD_CL, NullStr);
|
---|
976 | WinSetDlgItemText(hwnd, CMD_TITLE, NullStr);
|
---|
977 | info = cmdhead;
|
---|
978 | while (info) {
|
---|
979 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
980 | CMD_LISTBOX,
|
---|
981 | LM_INSERTITEM,
|
---|
982 | MPFROM2SHORT(LIT_END, 0),
|
---|
983 | MPFROMP(info->title));
|
---|
984 | if (x >= 0)
|
---|
985 | WinSendDlgItemMsg(hwnd,
|
---|
986 | CMD_LISTBOX,
|
---|
987 | LM_SETITEMHANDLE,
|
---|
988 | MPFROMSHORT(x), MPFROMP(info));
|
---|
989 | info = info->next;
|
---|
990 | }
|
---|
991 | WinSendDlgItemMsg(hwnd,
|
---|
992 | CMD_LISTBOX,
|
---|
993 | LM_SELECTITEM, MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
994 | WinCheckButton(hwnd, CMD_DEFAULT, TRUE);
|
---|
995 | WinCheckButton(hwnd, CMD_PROMPT, FALSE);
|
---|
996 | WinCheckButton(hwnd, CMD_ONCE, FALSE);
|
---|
997 | save_commands();
|
---|
998 | }
|
---|
999 | break;
|
---|
1000 |
|
---|
1001 | case DID_OK:
|
---|
1002 | {
|
---|
1003 | COMMAND *temp;
|
---|
1004 | BOOL fDontCheckHotKey = FALSE;
|
---|
1005 |
|
---|
1006 | temp = xmallocz(sizeof(COMMAND), pszSrcFile, __LINE__);
|
---|
1007 | if (!temp)
|
---|
1008 | break; //already complained
|
---|
1009 | temp->pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
1010 | if (!temp->pszCmdLine) {
|
---|
1011 | free (temp);
|
---|
1012 | break; //already complained
|
---|
1013 | }
|
---|
1014 | if (QueryCommandSettings(hwnd, temp)){
|
---|
1015 | if (temp->HotKeyID == 0)
|
---|
1016 | fDontCheckHotKey = TRUE;
|
---|
1017 | info = add_command(temp, fDontCheckHotKey);
|
---|
1018 | }
|
---|
1019 | else {
|
---|
1020 | free(temp->pszCmdLine);
|
---|
1021 | free(temp);
|
---|
1022 | break;
|
---|
1023 | }
|
---|
1024 | free(temp->pszCmdLine);
|
---|
1025 | free(temp);
|
---|
1026 | save_commands();
|
---|
1027 | WinDismissDlg(hwnd, 0);
|
---|
1028 | break;
|
---|
1029 | }
|
---|
1030 |
|
---|
1031 | case DID_CANCEL:
|
---|
1032 | WinDismissDlg(hwnd, 0);
|
---|
1033 | break;
|
---|
1034 |
|
---|
1035 | case IDM_HELP:
|
---|
1036 | if (hwndHelp)
|
---|
1037 | WinSendMsg(hwndHelp,
|
---|
1038 | HM_DISPLAY_HELP,
|
---|
1039 | MPFROM2SHORT(HELP_COMMAND, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
1040 | break;
|
---|
1041 |
|
---|
1042 | case CMD_ADD:
|
---|
1043 | {
|
---|
1044 | COMMAND *temp;
|
---|
1045 | BOOL fDontCheckHotKey = FALSE;
|
---|
1046 |
|
---|
1047 | temp = xmallocz(sizeof(COMMAND), pszSrcFile, __LINE__);
|
---|
1048 | if (!temp)
|
---|
1049 | break; //already complained
|
---|
1050 | temp->pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
1051 | if (!temp->pszCmdLine) {
|
---|
1052 | free (temp);
|
---|
1053 | break; //already complained
|
---|
1054 | }
|
---|
1055 | if (!QueryCommandSettings(hwnd, temp)) {
|
---|
1056 | free(temp->pszCmdLine);
|
---|
1057 | free(temp);
|
---|
1058 | break;
|
---|
1059 | }
|
---|
1060 | else {
|
---|
1061 | if (temp->HotKeyID == 0)
|
---|
1062 | fDontCheckHotKey = TRUE;
|
---|
1063 | info = add_command(temp, fDontCheckHotKey);
|
---|
1064 | if (!info) {
|
---|
1065 | saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
|
---|
1066 | GetPString(IDS_CANTADDCOMMANDTEXTDUP), temp->title);
|
---|
1067 | free(temp->pszCmdLine);
|
---|
1068 | free(temp);
|
---|
1069 | break;
|
---|
1070 | }
|
---|
1071 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
1072 | CMD_LISTBOX,
|
---|
1073 | LM_INSERTITEM,
|
---|
1074 | MPFROM2SHORT(LIT_END, 0),
|
---|
1075 | MPFROMP(temp->title));
|
---|
1076 | if (x >= 0) {
|
---|
1077 | WinSendDlgItemMsg(hwnd,
|
---|
1078 | CMD_LISTBOX,
|
---|
1079 | LM_SETITEMHANDLE,
|
---|
1080 | MPFROMSHORT(x), MPFROMP(info));
|
---|
1081 | WinSendDlgItemMsg(hwnd,
|
---|
1082 | CMD_LISTBOX,
|
---|
1083 | LM_SELECTITEM,
|
---|
1084 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
1085 | }
|
---|
1086 | save_commands();
|
---|
1087 | }
|
---|
1088 | free(temp->pszCmdLine);
|
---|
1089 | free(temp);
|
---|
1090 | break;
|
---|
1091 | }
|
---|
1092 |
|
---|
1093 | case CMD_DELETE:
|
---|
1094 | {
|
---|
1095 | CHAR temp[100];
|
---|
1096 | CHAR keyID[120];
|
---|
1097 | CHAR keyHotKeyID[120];
|
---|
1098 | CHAR keyenv[120];
|
---|
1099 |
|
---|
1100 | WinQueryDlgItemText(hwnd, CMD_TITLE, 100, temp);
|
---|
1101 | bstripcr(temp);
|
---|
1102 | if (!kill_command(temp))
|
---|
1103 | Runtime_Error(pszSrcFile, __LINE__, "kill_command");
|
---|
1104 | else {
|
---|
1105 | sprintf(keyID, "COMMAND.%sID", temp);
|
---|
1106 | sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp);
|
---|
1107 | sprintf(keyenv, "COMMAND.%senv", temp);
|
---|
1108 | PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, 0);
|
---|
1109 | PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, 0);
|
---|
1110 | PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL);
|
---|
1111 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
1112 | CMD_LISTBOX,
|
---|
1113 | LM_QUERYSELECTION,
|
---|
1114 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
1115 | if (x >= 0) {
|
---|
1116 | WinSendDlgItemMsg(hwnd,
|
---|
1117 | CMD_LISTBOX,
|
---|
1118 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
1119 | WinSendDlgItemMsg(hwnd,
|
---|
1120 | CMD_LISTBOX,
|
---|
1121 | LM_SELECTITEM,
|
---|
1122 | MPFROMSHORT(0), MPFROMSHORT(TRUE));
|
---|
1123 | }
|
---|
1124 | save_commands();
|
---|
1125 | }
|
---|
1126 | }
|
---|
1127 | break;
|
---|
1128 |
|
---|
1129 | case CMD_REPLACE:
|
---|
1130 | {
|
---|
1131 | COMMAND *temp;
|
---|
1132 | CHAR keyID[120];
|
---|
1133 | CHAR keyHotKeyID[120];
|
---|
1134 | CHAR keyenv[120];
|
---|
1135 | INT ID = 0;
|
---|
1136 | INT HotKeyID = 0;
|
---|
1137 | ULONG size;
|
---|
1138 | BOOL fDontCheckHotKey = FALSE;
|
---|
1139 |
|
---|
1140 | // Query the dialog
|
---|
1141 | temp = xmallocz(sizeof(COMMAND), pszSrcFile, __LINE__);
|
---|
1142 | if (!temp)
|
---|
1143 | break; //already complained
|
---|
1144 | temp->pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
1145 | if (!temp->pszCmdLine) {
|
---|
1146 | free (temp);
|
---|
1147 | break; //already complained
|
---|
1148 | }
|
---|
1149 | if (!QueryCommandSettings(hwnd, temp)) {
|
---|
1150 | free(temp->pszCmdLine);
|
---|
1151 | free(temp);
|
---|
1152 | break;
|
---|
1153 | }
|
---|
1154 | //remember item location in the list
|
---|
1155 | y = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
1156 | CMD_LISTBOX,
|
---|
1157 | LM_QUERYSELECTION,
|
---|
1158 | MPFROMSHORT(LIT_CURSOR), MPVOID);
|
---|
1159 | //Delete
|
---|
1160 | sprintf(keyID, "COMMAND.%sID", temp->title);
|
---|
1161 | sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp->title);
|
---|
1162 | sprintf(keyenv, "COMMAND.%senv", temp->title);
|
---|
1163 | PrfQueryProfileData(fmprof, FM3Str, keyID, &ID, &size);
|
---|
1164 | PrfQueryProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, &size);
|
---|
1165 | temp->ID = ID;
|
---|
1166 | if (temp->HotKeyID == HotKeyID || temp->HotKeyID == 0)
|
---|
1167 | fDontCheckHotKey = TRUE;
|
---|
1168 | if (kill_command(temp->title)) {
|
---|
1169 | PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, 0);
|
---|
1170 | PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, 0);
|
---|
1171 | PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL);
|
---|
1172 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
1173 | CMD_LISTBOX,
|
---|
1174 | LM_QUERYSELECTION,
|
---|
1175 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
1176 | if (x >= 0) {
|
---|
1177 | WinSendDlgItemMsg(hwnd,
|
---|
1178 | CMD_LISTBOX,
|
---|
1179 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
1180 | WinSendDlgItemMsg(hwnd,
|
---|
1181 | CMD_LISTBOX,
|
---|
1182 | LM_SELECTITEM,
|
---|
1183 | MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
|
---|
1184 | }
|
---|
1185 | } // then do an add
|
---|
1186 | info = add_command(temp, fDontCheckHotKey);
|
---|
1187 | if (!info) {
|
---|
1188 | saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
|
---|
1189 | GetPString(IDS_CANTADDCOMMANDTEXT),
|
---|
1190 | temp->title);
|
---|
1191 | }
|
---|
1192 | else {
|
---|
1193 | //put item back in original place
|
---|
1194 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
1195 | CMD_LISTBOX,
|
---|
1196 | LM_INSERTITEM,
|
---|
1197 | MPFROM2SHORT(y, 0),
|
---|
1198 | MPFROMP(temp->title));
|
---|
1199 | if (x >= 0) {
|
---|
1200 | LINKCMDS *temphead = NULL,*last = NULL, *temptail = NULL;
|
---|
1201 | SHORT numitems, sSelect = 0;
|
---|
1202 |
|
---|
1203 | WinSendDlgItemMsg(hwnd,
|
---|
1204 | CMD_LISTBOX,
|
---|
1205 | LM_SETITEMHANDLE,
|
---|
1206 | MPFROMSHORT(x), MPFROMP(info));
|
---|
1207 | WinSendDlgItemMsg(hwnd,
|
---|
1208 | CMD_LISTBOX,
|
---|
1209 | LM_SELECTITEM,
|
---|
1210 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
1211 | //then reorder
|
---|
1212 | numitems = (SHORT) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
|
---|
1213 | LM_QUERYITEMCOUNT,
|
---|
1214 | MPVOID, MPVOID);
|
---|
1215 |
|
---|
1216 | while (numitems) {
|
---|
1217 |
|
---|
1218 |
|
---|
1219 | info = (LINKCMDS *) WinSendDlgItemMsg(hwnd, CMD_LISTBOX,
|
---|
1220 | LM_QUERYITEMHANDLE,
|
---|
1221 | MPFROMSHORT(sSelect++),
|
---|
1222 | MPVOID);
|
---|
1223 | if (info) {
|
---|
1224 | if (!temphead) {
|
---|
1225 | temphead = info;
|
---|
1226 | info->prev = NULL;
|
---|
1227 | }
|
---|
1228 | else {
|
---|
1229 | last->next = info;
|
---|
1230 | info->prev = last;
|
---|
1231 | }
|
---|
1232 | temptail = info;
|
---|
1233 | last = info;
|
---|
1234 | info->next = NULL;
|
---|
1235 | }
|
---|
1236 | numitems--;
|
---|
1237 | }
|
---|
1238 | cmdhead = temphead;
|
---|
1239 | cmdtail = temptail;
|
---|
1240 | save_commands();
|
---|
1241 | }
|
---|
1242 | }
|
---|
1243 | xfree(temp->pszCmdLine, pszSrcFile, __LINE__);
|
---|
1244 | xfree(temp, pszSrcFile, __LINE__);
|
---|
1245 | }
|
---|
1246 | break;
|
---|
1247 | }
|
---|
1248 | return 0;
|
---|
1249 | }
|
---|
1250 | # ifdef FORTIFY
|
---|
1251 | Fortify_LeaveScope();
|
---|
1252 | # endif
|
---|
1253 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
1254 | }
|
---|
1255 |
|
---|
1256 | VOID RunCommand(HWND hwnd, INT cx)
|
---|
1257 | {
|
---|
1258 | INT x;
|
---|
1259 | CHAR **list;
|
---|
1260 | LINKCMDS *info;
|
---|
1261 |
|
---|
1262 | list = BuildList(hwnd);
|
---|
1263 | x = 0;
|
---|
1264 | info = cmdhead;
|
---|
1265 | while (info) {
|
---|
1266 | if (cx < 4300) {
|
---|
1267 | if (info->ID == cx)
|
---|
1268 | break;
|
---|
1269 | }
|
---|
1270 | else {
|
---|
1271 | if (info->HotKeyID == cx)
|
---|
1272 | break;
|
---|
1273 | }
|
---|
1274 | info = info->next;
|
---|
1275 | }
|
---|
1276 | if (info) {
|
---|
1277 |
|
---|
1278 | INT flags;
|
---|
1279 |
|
---|
1280 | x--;
|
---|
1281 | flags = info->flags;
|
---|
1282 | if (!(flags & FULLSCREEN))
|
---|
1283 | flags |= WINDOWED;
|
---|
1284 | if (flags & KEEP)
|
---|
1285 | flags |= SEPARATEKEEP;
|
---|
1286 | else
|
---|
1287 | flags |= SEPARATE;
|
---|
1288 | flags &= ~(KEEP | DIEAFTER);
|
---|
1289 | if (!strchr(info->pszCmdLine, '%')) {
|
---|
1290 | CHAR *fakelist[2];
|
---|
1291 |
|
---|
1292 | *fakelist = "C";
|
---|
1293 | fakelist[1] = NULL;
|
---|
1294 | ExecOnList(hwnd,
|
---|
1295 | info->pszCmdLine,
|
---|
1296 | flags, NULL, info->env != NullStr ? info->env : NULL,
|
---|
1297 | fakelist, GetPString(IDS_EXECCMDTITLETEXT),
|
---|
1298 | pszSrcFile, __LINE__);
|
---|
1299 | }
|
---|
1300 | else if ((flags & ONCE) && list && list[0]) {
|
---|
1301 |
|
---|
1302 | CHAR *fakelist[2];
|
---|
1303 | INT cntr;
|
---|
1304 |
|
---|
1305 | flags &= (~ONCE);
|
---|
1306 | for (cntr = 0; list[cntr]; cntr++) {
|
---|
1307 | *fakelist = list[cntr];
|
---|
1308 | fakelist[1] = NULL;
|
---|
1309 | ExecOnList(hwnd,
|
---|
1310 | info->pszCmdLine,
|
---|
1311 | flags, NULL, info->env != NullStr ? info->env : NULL,
|
---|
1312 | fakelist, GetPString(IDS_EXECCMDTITLETEXT),
|
---|
1313 | pszSrcFile, __LINE__);
|
---|
1314 | }
|
---|
1315 | }
|
---|
1316 | else if (list && list[0])
|
---|
1317 | ExecOnList(hwnd,
|
---|
1318 | info->pszCmdLine,
|
---|
1319 | flags, NULL, info->env != NullStr ? info->env : NULL,
|
---|
1320 | list, GetPString(IDS_EXECCMDTITLETEXT),
|
---|
1321 | pszSrcFile, __LINE__);
|
---|
1322 | else
|
---|
1323 | return;
|
---|
1324 | }
|
---|
1325 | FreeList(list);
|
---|
1326 | DosPostEventSem(CompactSem);
|
---|
1327 | }
|
---|
1328 |
|
---|
1329 | VOID EditCommands(HWND hwnd)
|
---|
1330 | {
|
---|
1331 | static CHAR stop = 0;
|
---|
1332 |
|
---|
1333 | if (stop)
|
---|
1334 | return;
|
---|
1335 | stop++;
|
---|
1336 | if (!cmdloaded)
|
---|
1337 | load_commands();
|
---|
1338 | WinDlgBox(HWND_DESKTOP,
|
---|
1339 | hwnd, CommandDlgProc, FM3ModHandle, CMD_FRAME, MPFROMP(&hwnd));
|
---|
1340 | stop = 0;
|
---|
1341 | }
|
---|
1342 |
|
---|
1343 | #pragma alloc_text(COMMAND,command_title,free_commands,add_command,kill_command)
|
---|
1344 | #pragma alloc_text(COMMAND,CommandDlgProc,EditCommands,ReOrderProc,CommandTextProc)
|
---|