1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: cmdline.c 1673 2012-12-30 18:51:01Z gyoung $
|
---|
5 |
|
---|
6 | User defined commands support
|
---|
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 | 05 Jun 05 SHL Use QWL_USER
|
---|
13 | 22 Jul 06 SHL Check more run time errors
|
---|
14 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
15 | 22 Mar 07 GKY Use QWL_USER
|
---|
16 | 16 Jun 07 SHL Update for OpenWatcom
|
---|
17 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
18 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
19 | 20 Apr 08 GKY New variable names; Save and Load command lines of user set length
|
---|
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 | 28 Jun 09 GKY Added AddBackslashToPath() to remove repeatative code.
|
---|
23 | 13 Dec 09 GKY Fixed separate paramenters. Please note that appname should be used in
|
---|
24 | profile calls for user settings that work and are setable in more than one
|
---|
25 | miniapp; FM3Str should be used for setting only relavent to FM/2 or that
|
---|
26 | aren't user settable; realappname should be used for setting applicable to
|
---|
27 | one or more miniapp but not to FM/2
|
---|
28 | 21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c
|
---|
29 | 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
|
---|
30 | 23 Oct 10 GKY Changes to populate and utilize a HELPTABLE for context specific help
|
---|
31 |
|
---|
32 | ***********************************************************************/
|
---|
33 |
|
---|
34 | #include <stdlib.h>
|
---|
35 | #include <string.h>
|
---|
36 | #include <share.h>
|
---|
37 | #include <io.h> // unlink
|
---|
38 |
|
---|
39 | #define INCL_DOS
|
---|
40 | #define INCL_WIN
|
---|
41 | #define INCL_LONGLONG // dircnrs.h
|
---|
42 |
|
---|
43 | #include "fm3dll.h"
|
---|
44 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
45 | #include "arccnrs.h" // Data declaration(s)
|
---|
46 | #include "fm2cmd.h" // Data declaration(s)
|
---|
47 | #include "notebook.h" // Data declaration(s)
|
---|
48 | #include "init.h" // Data declaration(s)
|
---|
49 | #include "newview.h" // Data declarations
|
---|
50 | #include "fm3dlg.h"
|
---|
51 | #include "fm3str.h"
|
---|
52 | #include "mle.h"
|
---|
53 | #include "errutil.h" // Dos_Error...
|
---|
54 | #include "strutil.h" // GetPString
|
---|
55 | #include "mainwnd.h" // BubbleHelp
|
---|
56 | #include "cmdline.h" // CmdLineDlgProc, CmdLine2DlgProc
|
---|
57 | #include "chklist.h" // PosOverOkay
|
---|
58 | #include "pathutil.h" // MaxCmdLineStr
|
---|
59 | #include "strips.h" // bstrip
|
---|
60 | #include "misc.h" // CheckDriveSpaceAvail
|
---|
61 | #include "srchpath.h" // searchpath
|
---|
62 | #include "wrappers.h" // xfgets_bstripcr
|
---|
63 | #include "valid.h" // IsFile
|
---|
64 | #include "dirs.h" // save_dir2
|
---|
65 | #include "systemf.h"
|
---|
66 | #include "fortify.h"
|
---|
67 |
|
---|
68 | #define MAXNUMCMDLINES 250
|
---|
69 |
|
---|
70 | typedef struct LINKCMDLINES
|
---|
71 | {
|
---|
72 | CHAR *cmdline;
|
---|
73 | struct LINKCMDLINES *next;
|
---|
74 | }
|
---|
75 | LINKCMDLINES;
|
---|
76 |
|
---|
77 | static LINKCMDLINES *DoItYourselfCmdLine = NULL, *MiniCmdLine = NULL;
|
---|
78 | static BOOL DoItYourselfLoaded = FALSE, MiniLoaded = FALSE;
|
---|
79 |
|
---|
80 | // Data definitions
|
---|
81 | static PSZ pszSrcFile = __FILE__;
|
---|
82 |
|
---|
83 | #pragma data_seg(GLOBAL1)
|
---|
84 | BOOL fSaveBigCmds;
|
---|
85 |
|
---|
86 |
|
---|
87 | VOID load_cmdlines(BOOL DoItYourself)
|
---|
88 | {
|
---|
89 | /** load linked list of cmdlines from CMDLINES.DAT file
|
---|
90 | * if DoItYourself = TRUE (main command line dialog)
|
---|
91 | * else load from CMDMINI.DAT (mini command line at
|
---|
92 | * bottom of main window).
|
---|
93 | */
|
---|
94 |
|
---|
95 | FILE *fp;
|
---|
96 | LINKCMDLINES *info, *last = NULL, *CmdLineHead;
|
---|
97 | PSZ pszCmdLine;
|
---|
98 | //CHAR s[1024];
|
---|
99 | INT x = 0;
|
---|
100 | CHAR *moder = "r";
|
---|
101 |
|
---|
102 | pszCmdLine = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
103 | if (pszCmdLine) {
|
---|
104 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
105 | if (DoItYourself)
|
---|
106 | DoItYourselfLoaded = TRUE;
|
---|
107 | else
|
---|
108 | MiniLoaded = TRUE;
|
---|
109 | BldFullPathName(pszCmdLine, pFM2SaveDirectory,
|
---|
110 | (DoItYourself) ? PCSZ_CMDLINESDAT : PCSZ_CMDMINIDAT);
|
---|
111 | fp = xfsopen(pszCmdLine, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
|
---|
112 | if (fp) {
|
---|
113 | while (x < MAXNUMCMDLINES && !feof(fp)) {
|
---|
114 | if (!xfgets_bstripcr(pszCmdLine, MaxComLineStrg, fp, pszSrcFile, __LINE__))
|
---|
115 | break;
|
---|
116 | if (pszCmdLine && *pszCmdLine != ';') {
|
---|
117 | info = xmalloc(sizeof(LINKCMDLINES), pszSrcFile, __LINE__);
|
---|
118 | if (info) {
|
---|
119 | x++;
|
---|
120 | info->cmdline = xstrdup(pszCmdLine, pszSrcFile, __LINE__);
|
---|
121 | if (!info->cmdline)
|
---|
122 | free(info);
|
---|
123 | else {
|
---|
124 | info->next = NULL;
|
---|
125 | if (!CmdLineHead)
|
---|
126 | CmdLineHead = info;
|
---|
127 | else
|
---|
128 | last->next = info;
|
---|
129 | last = info;
|
---|
130 | }
|
---|
131 | }
|
---|
132 | }
|
---|
133 | }
|
---|
134 | fclose(fp);
|
---|
135 | }
|
---|
136 | free(pszCmdLine);
|
---|
137 | }
|
---|
138 | if (DoItYourself)
|
---|
139 | DoItYourselfCmdLine = CmdLineHead;
|
---|
140 | else
|
---|
141 | MiniCmdLine = CmdLineHead;
|
---|
142 | }
|
---|
143 |
|
---|
144 | VOID save_cmdlines(BOOL DoItYourself)
|
---|
145 | {
|
---|
146 | /** save linked list of cmdlines from CMDLINES.DAT file
|
---|
147 | * if DoItYourself = TRUE (main command line dialog)
|
---|
148 | * else load from CMDMINI.DAT (mini command line at
|
---|
149 | * bottom of main window).
|
---|
150 | */
|
---|
151 |
|
---|
152 | LINKCMDLINES *info, *CmdLineHead;
|
---|
153 | FILE *fp;
|
---|
154 | PSZ pszCmdLine;
|
---|
155 | //CHAR s[CCHMAXPATH + 14];
|
---|
156 | CHAR *modew = "w";
|
---|
157 |
|
---|
158 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
159 | if ((DoItYourself && !DoItYourselfLoaded) || (!DoItYourself && !MiniLoaded))
|
---|
160 | return;
|
---|
161 | pszCmdLine = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
162 | if (!pszCmdLine)
|
---|
163 | return;
|
---|
164 | BldFullPathName(pszCmdLine, pFM2SaveDirectory,
|
---|
165 | (DoItYourself) ? PCSZ_CMDLINESDAT : PCSZ_CMDMINIDAT);
|
---|
166 | if (CheckDriveSpaceAvail(pszCmdLine, ullDATFileSpaceNeeded, 1) == 2)
|
---|
167 | return; //already gave error msg
|
---|
168 | if (CmdLineHead) {
|
---|
169 | fp = xfopen(pszCmdLine, modew, pszSrcFile, __LINE__, FALSE);
|
---|
170 | if (fp) {
|
---|
171 | fputs(GetPString(IDS_COMMANDFILE2TEXT), fp);
|
---|
172 | info = CmdLineHead;
|
---|
173 | while (info) {
|
---|
174 | fprintf(fp, "%0.*s\n", 1000, info->cmdline);
|
---|
175 | info = info->next;
|
---|
176 | }
|
---|
177 | fclose(fp);
|
---|
178 | }
|
---|
179 | }
|
---|
180 | else
|
---|
181 | unlink(pszCmdLine);
|
---|
182 | if (DoItYourself)
|
---|
183 | DoItYourselfCmdLine = CmdLineHead;
|
---|
184 | else
|
---|
185 | MiniCmdLine = CmdLineHead;
|
---|
186 | }
|
---|
187 |
|
---|
188 | BOOL add_cmdline(CHAR *cmdline, BOOL DoItYourself)
|
---|
189 | {
|
---|
190 | LINKCMDLINES *info, *last = NULL, *CmdLineHead;
|
---|
191 | INT x = 0;
|
---|
192 |
|
---|
193 | if (!cmdline || !*cmdline)
|
---|
194 | return FALSE;
|
---|
195 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
196 | if ((DoItYourself && !DoItYourselfLoaded) || (!DoItYourself && !MiniLoaded))
|
---|
197 | load_cmdlines(DoItYourself);
|
---|
198 | info = CmdLineHead;
|
---|
199 | while (info) {
|
---|
200 | if (!stricmp(info->cmdline, cmdline))
|
---|
201 | return FALSE;
|
---|
202 | last = info;
|
---|
203 | info = info->next;
|
---|
204 | x++;
|
---|
205 | }
|
---|
206 | info = xmalloc(sizeof(LINKCMDLINES), pszSrcFile, __LINE__);
|
---|
207 | if (info) {
|
---|
208 | info->cmdline = xstrdup(cmdline, pszSrcFile, __LINE__);
|
---|
209 | if (!info->cmdline)
|
---|
210 | xfree(info, pszSrcFile, __LINE__);
|
---|
211 | else {
|
---|
212 | info->next = NULL;
|
---|
213 | if (!CmdLineHead)
|
---|
214 | CmdLineHead = info;
|
---|
215 | else
|
---|
216 | last->next = info;
|
---|
217 | if (x > MAXNUMCMDLINES) {
|
---|
218 | info = CmdLineHead;
|
---|
219 | CmdLineHead = CmdLineHead->next;
|
---|
220 | free(info);
|
---|
221 | }
|
---|
222 | if (DoItYourself)
|
---|
223 | DoItYourselfCmdLine = CmdLineHead;
|
---|
224 | else
|
---|
225 | MiniCmdLine = CmdLineHead;
|
---|
226 | return TRUE;
|
---|
227 | }
|
---|
228 | }
|
---|
229 | return FALSE;
|
---|
230 | }
|
---|
231 |
|
---|
232 | BOOL remove_cmdline(CHAR *cmdline, BOOL DoItYourself)
|
---|
233 | {
|
---|
234 | LINKCMDLINES *info, *last = NULL, *CmdLineHead;
|
---|
235 |
|
---|
236 | if (!cmdline || !*cmdline)
|
---|
237 | return FALSE;
|
---|
238 | if ((DoItYourself && !DoItYourselfLoaded) || (!DoItYourself && !MiniLoaded))
|
---|
239 | load_cmdlines(DoItYourself);
|
---|
240 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
241 | info = CmdLineHead;
|
---|
242 | while (info) {
|
---|
243 | if (!stricmp(info->cmdline, cmdline)) {
|
---|
244 | if (last)
|
---|
245 | last->next = info->next;
|
---|
246 | else
|
---|
247 | CmdLineHead = info->next;
|
---|
248 | xfree(info->cmdline, pszSrcFile, __LINE__);
|
---|
249 | free(info);
|
---|
250 | if (DoItYourself)
|
---|
251 | DoItYourselfCmdLine = CmdLineHead;
|
---|
252 | else
|
---|
253 | MiniCmdLine = CmdLineHead;
|
---|
254 | return TRUE;
|
---|
255 | }
|
---|
256 | last = info;
|
---|
257 | info = info->next;
|
---|
258 | }
|
---|
259 | return FALSE;
|
---|
260 | }
|
---|
261 |
|
---|
262 | VOID free_cmdlines(BOOL DoItYourself)
|
---|
263 | {
|
---|
264 | LINKCMDLINES *info, *next, *CmdLineHead;
|
---|
265 |
|
---|
266 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
267 | info = CmdLineHead;
|
---|
268 | while (info) {
|
---|
269 | next = info->next;
|
---|
270 | xfree(info->cmdline, pszSrcFile, __LINE__);
|
---|
271 | free(info);
|
---|
272 | info = next;
|
---|
273 | }
|
---|
274 | CmdLineHead = NULL;
|
---|
275 | if (DoItYourself)
|
---|
276 | DoItYourselfCmdLine = CmdLineHead;
|
---|
277 | else
|
---|
278 | MiniCmdLine = CmdLineHead;
|
---|
279 | DosPostEventSem(CompactSem);
|
---|
280 | }
|
---|
281 |
|
---|
282 | MRESULT EXPENTRY CmdBtnSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
283 | {
|
---|
284 | switch (msg) {
|
---|
285 | case WM_MOUSEMOVE:
|
---|
286 | {
|
---|
287 | ULONG strid = 0;
|
---|
288 |
|
---|
289 | switch (WinQueryWindowUShort(hwnd, QWS_ID)) {
|
---|
290 | case EXEC2_CLR:
|
---|
291 | strid = IDS_CMDWIPEALLHELPTEXT;
|
---|
292 | break;
|
---|
293 | case EXEC2_DEL:
|
---|
294 | strid = IDS_CMDDELHILITEHELPTEXT;
|
---|
295 | break;
|
---|
296 | case IDM_HELP:
|
---|
297 | strid = IDS_CMDHELPHELPTEXT;
|
---|
298 | break;
|
---|
299 | case DID_CANCEL:
|
---|
300 | strid = IDS_CMDCLOSEBOXHELPTEXT;
|
---|
301 | break;
|
---|
302 | case EXEC2_OPEN:
|
---|
303 | strid = IDS_CMDOPENHELPTEXT;
|
---|
304 | break;
|
---|
305 | case EXEC2_CLOSE:
|
---|
306 | strid = IDS_CMDCLOSEHELPTEXT;
|
---|
307 | break;
|
---|
308 | case EXEC2_FILTER:
|
---|
309 | strid = IDS_CMDFILTERHELPTEXT;
|
---|
310 | break;
|
---|
311 | case EXEC2_KEEP:
|
---|
312 | strid = IDS_CMDKEEPHELPTEXT;
|
---|
313 | break;
|
---|
314 | case EXEC2_SAVE:
|
---|
315 | strid = IDS_CMDSAVEHELPTEXT;
|
---|
316 | break;
|
---|
317 | }
|
---|
318 | if (strid)
|
---|
319 | BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(strid));
|
---|
320 | }
|
---|
321 | break;
|
---|
322 | }
|
---|
323 | return PFNWPButton(hwnd, msg, mp1, mp2);
|
---|
324 | }
|
---|
325 |
|
---|
326 | MRESULT EXPENTRY CmdListSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
327 | {
|
---|
328 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
329 |
|
---|
330 | switch (msg) {
|
---|
331 | case WM_MOUSEMOVE:
|
---|
332 | if (hwndBubble)
|
---|
333 | WinDestroyWindow(hwndBubble);
|
---|
334 | break;
|
---|
335 |
|
---|
336 | case WM_CHAR:
|
---|
337 | if (SHORT1FROMMP(mp1) & KC_KEYUP) {
|
---|
338 | if ((SHORT1FROMMP(mp1) & KC_VIRTUALKEY) &&
|
---|
339 | (SHORT2FROMMP(mp2)) == VK_DELETE) {
|
---|
340 | if ((SHORT1FROMMP(mp1) & KC_CTRL) != KC_CTRL)
|
---|
341 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
342 | MPFROM2SHORT(EXEC2_DEL, 0), MPVOID);
|
---|
343 | else
|
---|
344 | PostMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
|
---|
345 | MPFROM2SHORT(EXEC2_CLR, 0), MPVOID);
|
---|
346 | }
|
---|
347 | }
|
---|
348 | break;
|
---|
349 | }
|
---|
350 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
351 | }
|
---|
352 |
|
---|
353 | MRESULT EXPENTRY CmdLineDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
354 | {
|
---|
355 | EXECARGS *ex;
|
---|
356 |
|
---|
357 | switch (msg) {
|
---|
358 | case WM_INITDLG:
|
---|
359 | ex = (EXECARGS *) mp2;
|
---|
360 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) ex);
|
---|
361 | if (!ex || !ex->commandline) {
|
---|
362 | WinDismissDlg(hwnd, 0);
|
---|
363 | break;
|
---|
364 | }
|
---|
365 | if (*ex->title)
|
---|
366 | WinSetWindowText(hwnd, ex->title);
|
---|
367 | WinShowWindow(WinWindowFromID(hwnd, EXEC2_DEL), FALSE);
|
---|
368 | WinCheckButton(hwnd, EXEC_SAVECMD, fSaveBigCmds);
|
---|
369 | WinSendDlgItemMsg(hwnd, EXEC_CL, EM_SETTEXTLIMIT,
|
---|
370 | MPFROM2SHORT(1000, 0), MPVOID);
|
---|
371 | WinSetDlgItemText(hwnd, EXEC_CL, ex->commandline);
|
---|
372 | WinSetWindowPtr(WinWindowFromID(hwnd, EXEC_LISTBOX),
|
---|
373 | QWL_USER,
|
---|
374 | (PVOID) WinSubclassWindow(WinWindowFromID(hwnd,
|
---|
375 | EXEC_LISTBOX),
|
---|
376 | (PFNWP) CmdListSubProc));
|
---|
377 | if (*ex->commandline == ' ')
|
---|
378 | WinSendDlgItemMsg(hwnd, EXEC_CL, EM_SETSEL, MPFROM2SHORT(0, 0), MPVOID);
|
---|
379 | WinSendDlgItemMsg(hwnd, EXEC_CL, EM_SETINSERTMODE,
|
---|
380 | MPFROMSHORT(TRUE), MPVOID);
|
---|
381 | if (ex->flags & MINIMIZED)
|
---|
382 | WinCheckButton(hwnd, EXEC_MINIMIZED, TRUE);
|
---|
383 | else if (ex->flags & MAXIMIZED)
|
---|
384 | WinCheckButton(hwnd, EXEC_MAXIMIZED, TRUE);
|
---|
385 | else if (ex->flags & FULLSCREEN)
|
---|
386 | WinCheckButton(hwnd, EXEC_FULLSCREEN, TRUE);
|
---|
387 | else if (ex->flags & INVISIBLE)
|
---|
388 | WinCheckButton(hwnd, EXEC_INVISIBLE, TRUE);
|
---|
389 | else
|
---|
390 | WinCheckButton(hwnd, EXEC_DEFAULT, TRUE);
|
---|
391 | if ((ex->flags & SEPARATEKEEP) == SEPARATEKEEP)
|
---|
392 | WinCheckButton(hwnd, EXEC_KEEP, TRUE);
|
---|
393 | else
|
---|
394 | WinCheckButton(hwnd, EXEC_KEEP, FALSE);
|
---|
395 | MLEsetformat(WinWindowFromID(hwnd, EXEC_ENVIRON), MLFIE_NOTRANS);
|
---|
396 | MLEsetlimit(WinWindowFromID(hwnd, EXEC_ENVIRON), 1000);
|
---|
397 | WinSetDlgItemText(hwnd, EXEC_ENVIRON, ex->environment);
|
---|
398 | // WinEnableWindow(WinWindowFromID(hwnd,EXEC_ENVIRON),FALSE);
|
---|
399 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
400 | PosOverOkay(hwnd);
|
---|
401 | break;
|
---|
402 |
|
---|
403 | case UM_SETUP:
|
---|
404 | {
|
---|
405 | ULONG apptype = 0L;
|
---|
406 | CHAR executable[CCHMAXPATH], commandline[1001], *p;
|
---|
407 |
|
---|
408 | ex = INSTDATA(hwnd);
|
---|
409 | if (!ex)
|
---|
410 | return 0;
|
---|
411 | WinSetDlgItemText(hwnd, EXEC_WARNING, NullStr);
|
---|
412 | WinSetDlgItemText(hwnd, EXEC_WARNING2, NullStr);
|
---|
413 | *commandline = 0;
|
---|
414 | WinQueryDlgItemText(hwnd, EXEC_CL, 1000, commandline);
|
---|
415 | if (!*commandline)
|
---|
416 | return 0;
|
---|
417 | if (*ex->path) {
|
---|
418 | strcpy(executable, ex->path);
|
---|
419 | AddBackslashToPath(executable);
|
---|
420 | //if (executable[strlen(executable) - 1] != '\\')
|
---|
421 | // strcat(executable, "\\");
|
---|
422 | }
|
---|
423 | else
|
---|
424 | *executable = 0;
|
---|
425 | strncat(executable, commandline, CCHMAXPATH - strlen(executable));
|
---|
426 | executable[CCHMAXPATH - 1] = 0;
|
---|
427 | p = strchr(executable, ' ');
|
---|
428 | if (p)
|
---|
429 | *p = 0;
|
---|
430 | if (IsFile(executable) == -1) {
|
---|
431 | strncpy(executable, commandline, CCHMAXPATH);
|
---|
432 | executable[CCHMAXPATH - 1] = 0;
|
---|
433 | p = strchr(executable, ' ');
|
---|
434 | if (p)
|
---|
435 | *p = 0;
|
---|
436 | if (IsFile(executable) == -1) {
|
---|
437 | p = searchpath(executable);
|
---|
438 | if (*p)
|
---|
439 | strcpy(executable, p);
|
---|
440 | else {
|
---|
441 | WinSetDlgItemText(hwnd,
|
---|
442 | EXEC_WARNING2,
|
---|
443 | (CHAR *) GetPString(IDS_CANTFINDFILETEXT));
|
---|
444 | break;
|
---|
445 | }
|
---|
446 | }
|
---|
447 | }
|
---|
448 | if (DosQueryAppType(executable, &apptype) ||
|
---|
449 | (apptype && !(apptype &
|
---|
450 | (FAPPTYP_NOTWINDOWCOMPAT |
|
---|
451 | FAPPTYP_WINDOWCOMPAT |
|
---|
452 | FAPPTYP_WINDOWAPI |
|
---|
453 | FAPPTYP_BOUND |
|
---|
454 | FAPPTYP_DOS |
|
---|
455 | FAPPTYP_WINDOWSREAL |
|
---|
456 | FAPPTYP_WINDOWSPROT | FAPPTYP_32BIT | 0x1000)))) {
|
---|
457 | p = strchr(executable, '.');
|
---|
458 | if (p) {
|
---|
459 | if (!stricmp(p, PCSZ_DOTBAT) || !stricmp(p, PCSZ_DOTCMD) ||
|
---|
460 | !stricmp(p, PCSZ_DOTBTM)) {
|
---|
461 | WinSetDlgItemText(hwnd,
|
---|
462 | EXEC_WARNING2,
|
---|
463 | (CHAR *) GetPString(IDS_RUNTHRUCMDEXETEXT));
|
---|
464 | break;
|
---|
465 | }
|
---|
466 | }
|
---|
467 | WinSetDlgItemText(hwnd, EXEC_WARNING2, (CHAR *) GetPString(IDS_NOTDIRECTEXETEXT));
|
---|
468 | }
|
---|
469 | else if (apptype) { // acceptable
|
---|
470 |
|
---|
471 | CHAR s[257];
|
---|
472 |
|
---|
473 | *s = 0;
|
---|
474 | WinSetDlgItemText(hwnd, EXEC_WARNING, (CHAR *) GetPString(IDS_ACCEPTABLEAPPTEXT));
|
---|
475 | if (apptype & FAPPTYP_DOS)
|
---|
476 | strcat(s, GetPString(IDS_DOSTEXT));
|
---|
477 | if (apptype & FAPPTYP_WINDOWSREAL) {
|
---|
478 | if (*s)
|
---|
479 | strcat(s, " ");
|
---|
480 | strcat(s, GetPString(IDS_WINDOWSREALTEXT));
|
---|
481 | }
|
---|
482 | if (apptype & FAPPTYP_WINDOWSPROT) {
|
---|
483 | if (*s)
|
---|
484 | strcat(s, " ");
|
---|
485 | strcat(s, GetPString(IDS_WINDOWSPROTTEXT));
|
---|
486 | }
|
---|
487 | if (apptype & 0x1000) {
|
---|
488 | if (*s)
|
---|
489 | strcat(s, " ");
|
---|
490 | strcat(s, GetPString(IDS_WINDOWSENHTEXT));
|
---|
491 | }
|
---|
492 | if ((apptype & FAPPTYP_WINDOWAPI) == FAPPTYP_WINDOWAPI) {
|
---|
493 | if (*s)
|
---|
494 | strcat(s, " ");
|
---|
495 | strcat(s, GetPString(IDS_PMTEXT));
|
---|
496 | WinCheckButton(hwnd, EXEC_FULLSCREEN, FALSE);
|
---|
497 | WinEnableWindow(WinWindowFromID(hwnd, EXEC_FULLSCREEN), FALSE);
|
---|
498 | }
|
---|
499 | if (apptype & FAPPTYP_BOUND) {
|
---|
500 | if (*s)
|
---|
501 | strcat(s, " ");
|
---|
502 | strcat(s, GetPString(IDS_BOUNDTEXT));
|
---|
503 | }
|
---|
504 | if ((apptype & FAPPTYP_WINDOWCOMPAT) &&
|
---|
505 | !(apptype & FAPPTYP_NOTWINDOWCOMPAT)) {
|
---|
506 | if (*s)
|
---|
507 | strcat(s, " ");
|
---|
508 | strcat(s, GetPString(IDS_VIOTEXT));
|
---|
509 | }
|
---|
510 | if ((apptype & FAPPTYP_NOTWINDOWCOMPAT) &&
|
---|
511 | !(apptype & FAPPTYP_WINDOWCOMPAT)) {
|
---|
512 | if (*s)
|
---|
513 | strcat(s, " ");
|
---|
514 | strcat(s, GetPString(IDS_FULLSCREENTEXT));
|
---|
515 | }
|
---|
516 | if (apptype & FAPPTYP_32BIT) {
|
---|
517 | if (*s)
|
---|
518 | strcat(s, " ");
|
---|
519 | strcat(s, GetPString(IDS_32BITTEXT));
|
---|
520 | }
|
---|
521 | WinSetDlgItemText(hwnd, EXEC_WARNING2, s);
|
---|
522 | if ((apptype & (FAPPTYP_DOS | FAPPTYP_WINDOWSREAL |
|
---|
523 | FAPPTYP_WINDOWSPROT | 0x1000)) ||
|
---|
524 | ((apptype & FAPPTYP_WINDOWAPI) == FAPPTYP_WINDOWAPI)) {
|
---|
525 | WinCheckButton(hwnd, EXEC_KEEP, FALSE);
|
---|
526 | WinEnableWindow(WinWindowFromID(hwnd, EXEC_KEEP), FALSE);
|
---|
527 | }
|
---|
528 | if (apptype & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | 0x1000))
|
---|
529 | WinCheckButton(hwnd, EXEC_FULLSCREEN, TRUE);
|
---|
530 | }
|
---|
531 | else
|
---|
532 | WinSetDlgItemText(hwnd, EXEC_WARNING2, (CHAR *) GetPString(IDS_UNKNOWNDEFAULTTEXT));
|
---|
533 | }
|
---|
534 | return 0;
|
---|
535 |
|
---|
536 | case WM_ADJUSTWINDOWPOS:
|
---|
537 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
538 | break;
|
---|
539 |
|
---|
540 | case UM_SETDIR:
|
---|
541 | PaintRecessedWindow(WinWindowFromID(hwnd,
|
---|
542 | EXEC_WARNING2),
|
---|
543 | (HPS) 0, FALSE, FALSE);
|
---|
544 | return 0;
|
---|
545 |
|
---|
546 | case UM_RESCAN:
|
---|
547 | WinSendDlgItemMsg(hwnd, EXEC_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
548 | if (!DoItYourselfLoaded)
|
---|
549 | load_cmdlines(TRUE);
|
---|
550 | {
|
---|
551 | LINKCMDLINES *info;
|
---|
552 |
|
---|
553 | info = DoItYourselfCmdLine;
|
---|
554 | while (info) {
|
---|
555 | WinSendDlgItemMsg(hwnd,
|
---|
556 | EXEC_LISTBOX,
|
---|
557 | LM_INSERTITEM,
|
---|
558 | MPFROM2SHORT(LIT_END, 0), MPFROMP(info->cmdline));
|
---|
559 | info = info->next;
|
---|
560 | }
|
---|
561 | }
|
---|
562 | return 0;
|
---|
563 |
|
---|
564 | case WM_CONTROL:
|
---|
565 | switch (SHORT1FROMMP(mp1)) {
|
---|
566 | case EXEC_SAVECMD:
|
---|
567 | {
|
---|
568 | fSaveBigCmds = (fSaveBigCmds) ? FALSE : TRUE;
|
---|
569 | WinCheckButton(hwnd, EXEC_SAVECMD, fSaveBigCmds);
|
---|
570 | PrfWriteProfileData(fmprof, appname, "SaveBigCmds", &fSaveBigCmds, sizeof(BOOL));
|
---|
571 | }
|
---|
572 | break;
|
---|
573 | case EXEC_CL:
|
---|
574 | switch (SHORT2FROMMP(mp1)) {
|
---|
575 | case EN_KILLFOCUS:
|
---|
576 | ex = INSTDATA(hwnd);
|
---|
577 | if (!ex || !ex->dropped)
|
---|
578 | WinSendMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
579 | break;
|
---|
580 | }
|
---|
581 | break;
|
---|
582 | case EXEC_LISTBOX:
|
---|
583 | switch (SHORT2FROMMP(mp1)) {
|
---|
584 | case LN_KILLFOCUS:
|
---|
585 | ex = INSTDATA(hwnd);
|
---|
586 | if (ex) {
|
---|
587 | if (ex->dropped)
|
---|
588 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(EXEC_DROP, 0), MPVOID);
|
---|
589 | }
|
---|
590 | break;
|
---|
591 | case LN_ENTER:
|
---|
592 | {
|
---|
593 | SHORT x;
|
---|
594 | CHAR cmdline[1001];
|
---|
595 |
|
---|
596 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
597 | EXEC_LISTBOX,
|
---|
598 | LM_QUERYSELECTION,
|
---|
599 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
600 | if (x >= 0) {
|
---|
601 | *cmdline = 0;
|
---|
602 | WinSendDlgItemMsg(hwnd,
|
---|
603 | EXEC_LISTBOX,
|
---|
604 | LM_QUERYITEMTEXT,
|
---|
605 | MPFROM2SHORT(x,
|
---|
606 | sizeof(cmdline)),
|
---|
607 | MPFROMP(cmdline));
|
---|
608 | bstrip(cmdline);
|
---|
609 | if (*cmdline) {
|
---|
610 | WinSetDlgItemText(hwnd, EXEC_CL, cmdline);
|
---|
611 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(EXEC_DROP, 0), MPVOID);
|
---|
612 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
613 | }
|
---|
614 | }
|
---|
615 | }
|
---|
616 | break;
|
---|
617 | }
|
---|
618 | break;
|
---|
619 | }
|
---|
620 | return 0;
|
---|
621 |
|
---|
622 | case WM_HELP:
|
---|
623 | if (hwndHelp)
|
---|
624 | WinSendMsg(hwndHelp,
|
---|
625 | HM_DISPLAY_HELP,
|
---|
626 | MPFROM2SHORT(HELP_CMDLINE, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
627 | break;
|
---|
628 |
|
---|
629 | case WM_COMMAND:
|
---|
630 | switch (SHORT1FROMMP(mp1)) {
|
---|
631 | case EXEC2_CLR:
|
---|
632 | free_cmdlines(TRUE);
|
---|
633 | save_cmdlines(TRUE);
|
---|
634 | WinSendDlgItemMsg(hwnd, EXEC_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
635 | break;
|
---|
636 | case EXEC2_DEL:
|
---|
637 | {
|
---|
638 | SHORT x;
|
---|
639 | CHAR cmdline[1001];
|
---|
640 |
|
---|
641 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
642 | EXEC_LISTBOX,
|
---|
643 | LM_QUERYSELECTION,
|
---|
644 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
645 | if (x >= 0) {
|
---|
646 | *cmdline = 0;
|
---|
647 | WinSendDlgItemMsg(hwnd,
|
---|
648 | EXEC_LISTBOX,
|
---|
649 | LM_QUERYITEMTEXT,
|
---|
650 | MPFROM2SHORT(x, sizeof(cmdline)),
|
---|
651 | MPFROMP(cmdline));
|
---|
652 | bstrip(cmdline);
|
---|
653 | if (*cmdline) {
|
---|
654 | if (remove_cmdline(cmdline, TRUE) && fSaveBigCmds) {
|
---|
655 | save_cmdlines(TRUE);
|
---|
656 | WinSendDlgItemMsg(hwnd,
|
---|
657 | EXEC_LISTBOX,
|
---|
658 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
659 | if (x)
|
---|
660 | x--;
|
---|
661 | WinSendDlgItemMsg(hwnd,
|
---|
662 | EXEC_LISTBOX,
|
---|
663 | LM_SELECTITEM,
|
---|
664 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
665 | }
|
---|
666 | }
|
---|
667 | }
|
---|
668 | }
|
---|
669 | break;
|
---|
670 | case EXEC_DROP:
|
---|
671 | ex = INSTDATA(hwnd);
|
---|
672 | if (ex) {
|
---|
673 | if (!ex->dropped) {
|
---|
674 | *ex->tempprompt = 0;
|
---|
675 | WinQueryDlgItemText(hwnd,
|
---|
676 | EXEC_WARNING2,
|
---|
677 | sizeof(ex->tempprompt), ex->tempprompt);
|
---|
678 | WinSetDlgItemText(hwnd, EXEC_WARNING2, (CHAR *) GetPString(IDS_CMDSELCMDHELPTEXT));
|
---|
679 | ex->dropped = TRUE;
|
---|
680 | if ((SHORT) WinSendDlgItemMsg(hwnd,
|
---|
681 | EXEC_LISTBOX,
|
---|
682 | LM_QUERYITEMCOUNT,
|
---|
683 | MPVOID, MPVOID) == 0)
|
---|
684 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
685 | WinShowWindow(WinWindowFromID(hwnd, EXEC_CL), FALSE);
|
---|
686 | WinShowWindow(WinWindowFromID(hwnd, EXEC_WARNING), FALSE);
|
---|
687 | WinShowWindow(WinWindowFromID(hwnd, EXEC_DEFAULT), FALSE);
|
---|
688 | WinShowWindow(WinWindowFromID(hwnd, EXEC_MINIMIZED), FALSE);
|
---|
689 | WinShowWindow(WinWindowFromID(hwnd, EXEC_MAXIMIZED), FALSE);
|
---|
690 | WinShowWindow(WinWindowFromID(hwnd, EXEC_FULLSCREEN), FALSE);
|
---|
691 | WinShowWindow(WinWindowFromID(hwnd, EXEC_INVISIBLE), FALSE);
|
---|
692 | WinShowWindow(WinWindowFromID(hwnd, EXEC_KEEP), FALSE);
|
---|
693 | WinShowWindow(WinWindowFromID(hwnd, EXEC_ENVIRON), FALSE);
|
---|
694 | WinShowWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
|
---|
695 | WinShowWindow(WinWindowFromID(hwnd, IDM_HELP), FALSE);
|
---|
696 | WinShowWindow(WinWindowFromID(hwnd, EXEC_ABORT), FALSE);
|
---|
697 | WinShowWindow(WinWindowFromID(hwnd, DID_CANCEL), FALSE);
|
---|
698 | WinShowWindow(WinWindowFromID(hwnd, EXEC_LISTBOX), TRUE);
|
---|
699 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, EXEC_LISTBOX));
|
---|
700 | WinSetDlgItemText(hwnd, EXEC_DROP, "^");
|
---|
701 | WinShowWindow(WinWindowFromID(hwnd, EXEC2_DEL), TRUE);
|
---|
702 | }
|
---|
703 | else {
|
---|
704 | ex->dropped = FALSE;
|
---|
705 | WinSetDlgItemText(hwnd, EXEC_WARNING2, ex->tempprompt);
|
---|
706 | WinShowWindow(WinWindowFromID(hwnd, EXEC_LISTBOX), FALSE);
|
---|
707 | WinShowWindow(WinWindowFromID(hwnd, EXEC_CL), TRUE);
|
---|
708 | WinShowWindow(WinWindowFromID(hwnd, EXEC_WARNING), TRUE);
|
---|
709 | WinShowWindow(WinWindowFromID(hwnd, EXEC_DEFAULT), TRUE);
|
---|
710 | WinShowWindow(WinWindowFromID(hwnd, EXEC_MINIMIZED), TRUE);
|
---|
711 | WinShowWindow(WinWindowFromID(hwnd, EXEC_MAXIMIZED), TRUE);
|
---|
712 | WinShowWindow(WinWindowFromID(hwnd, EXEC_FULLSCREEN), TRUE);
|
---|
713 | WinShowWindow(WinWindowFromID(hwnd, EXEC_INVISIBLE), TRUE);
|
---|
714 | WinShowWindow(WinWindowFromID(hwnd, EXEC_KEEP), TRUE);
|
---|
715 | WinShowWindow(WinWindowFromID(hwnd, EXEC_ENVIRON), TRUE);
|
---|
716 | WinShowWindow(WinWindowFromID(hwnd, DID_OK), TRUE);
|
---|
717 | WinShowWindow(WinWindowFromID(hwnd, IDM_HELP), TRUE);
|
---|
718 | WinShowWindow(WinWindowFromID(hwnd, EXEC_ABORT), TRUE);
|
---|
719 | WinShowWindow(WinWindowFromID(hwnd, DID_CANCEL), TRUE);
|
---|
720 | WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, EXEC_CL));
|
---|
721 | WinSetDlgItemText(hwnd, EXEC_DROP, "v");
|
---|
722 | WinShowWindow(WinWindowFromID(hwnd, EXEC2_DEL), FALSE);
|
---|
723 | }
|
---|
724 | }
|
---|
725 | break;
|
---|
726 |
|
---|
727 | case DID_OK:
|
---|
728 | ex = INSTDATA(hwnd);
|
---|
729 | WinQueryDlgItemText(hwnd, EXEC_CL, 1000, ex->commandline);
|
---|
730 | ex->flags = CheckExecutibleFlags(hwnd, 2);
|
---|
731 | strset(ex->environment, 0);
|
---|
732 | WinQueryDlgItemText(hwnd, EXEC_ENVIRON, 1000, ex->environment);
|
---|
733 | if (add_cmdline(ex->commandline, TRUE) && fSaveBigCmds)
|
---|
734 | save_cmdlines(TRUE);
|
---|
735 | WinDismissDlg(hwnd, 1);
|
---|
736 | break;
|
---|
737 |
|
---|
738 | case DID_CANCEL:
|
---|
739 | WinDismissDlg(hwnd, 0);
|
---|
740 | break;
|
---|
741 |
|
---|
742 | case EXEC_ABORT:
|
---|
743 | WinDismissDlg(hwnd, 2);
|
---|
744 | break;
|
---|
745 |
|
---|
746 | case IDM_HELP:
|
---|
747 | if (hwndHelp)
|
---|
748 | WinSendMsg(hwndHelp,
|
---|
749 | HM_DISPLAY_HELP,
|
---|
750 | MPFROM2SHORT(HELP_CMDLINE, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
751 | break;
|
---|
752 | }
|
---|
753 | return 0;
|
---|
754 |
|
---|
755 | case WM_DESTROY:
|
---|
756 | break;
|
---|
757 | }
|
---|
758 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
759 | }
|
---|
760 |
|
---|
761 | MRESULT EXPENTRY CmdLine2DlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
762 | {
|
---|
763 | switch (msg) {
|
---|
764 | case WM_INITDLG:
|
---|
765 | if (!mp2) {
|
---|
766 | WinDismissDlg(hwnd, 0);
|
---|
767 | break;
|
---|
768 | }
|
---|
769 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
770 | {
|
---|
771 | int x;
|
---|
772 | USHORT ids[] = { IDM_HELP, EXEC2_CLR, EXEC2_DEL, EXEC2_KEEP, EXEC2_SAVE,
|
---|
773 | EXEC2_OPEN, EXEC2_CLOSE, EXEC2_FILTER, DID_CANCEL, 0
|
---|
774 | };
|
---|
775 |
|
---|
776 | WinSetWindowPtr(WinWindowFromID(hwnd, EXEC2_LISTBOX),
|
---|
777 | QWL_USER,
|
---|
778 | (PVOID) WinSubclassWindow(WinWindowFromID(hwnd,
|
---|
779 | EXEC2_LISTBOX),
|
---|
780 | (PFNWP) CmdListSubProc));
|
---|
781 | for (x = 0; ids[x]; x++)
|
---|
782 | WinSetWindowPtr(WinWindowFromID(hwnd, ids[x]),
|
---|
783 | QWL_USER,
|
---|
784 | (PVOID) WinSubclassWindow(WinWindowFromID(hwnd,
|
---|
785 | ids[x]),
|
---|
786 | (PFNWP) CmdBtnSubProc));
|
---|
787 | }
|
---|
788 | PostMsg(hwnd, UM_RESCAN, MPVOID, MPVOID);
|
---|
789 | break;
|
---|
790 |
|
---|
791 | case UM_RESCAN:
|
---|
792 | WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
793 | if (!MiniLoaded)
|
---|
794 | load_cmdlines(FALSE);
|
---|
795 | {
|
---|
796 | LINKCMDLINES *info;
|
---|
797 |
|
---|
798 | info = MiniCmdLine;
|
---|
799 | while (info) {
|
---|
800 | WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX, LM_INSERTITEM,
|
---|
801 | MPFROM2SHORT(LIT_END, 0), MPFROMP(info->cmdline));
|
---|
802 | info = info->next;
|
---|
803 | }
|
---|
804 | }
|
---|
805 | return 0;
|
---|
806 |
|
---|
807 | case WM_CONTROL:
|
---|
808 | switch (SHORT1FROMMP(mp1)) {
|
---|
809 | case EXEC2_LISTBOX:
|
---|
810 | switch (SHORT2FROMMP(mp1)) {
|
---|
811 | case LN_ENTER:
|
---|
812 | {
|
---|
813 | SHORT x;
|
---|
814 | CHAR *cmdline = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
815 |
|
---|
816 | x = (SHORT) WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX,
|
---|
817 | LM_QUERYSELECTION,
|
---|
818 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
819 | if (x >= 0) {
|
---|
820 | *cmdline = 0;
|
---|
821 | WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX, LM_QUERYITEMTEXT,
|
---|
822 | MPFROM2SHORT(x, 1000), MPFROMP(cmdline));
|
---|
823 | bstrip(cmdline);
|
---|
824 | if (*cmdline)
|
---|
825 | WinDismissDlg(hwnd, 1);
|
---|
826 | }
|
---|
827 | }
|
---|
828 | break;
|
---|
829 | }
|
---|
830 | break;
|
---|
831 | }
|
---|
832 | return 0;
|
---|
833 |
|
---|
834 | case WM_COMMAND:
|
---|
835 | switch (SHORT1FROMMP(mp1)) {
|
---|
836 | case EXEC2_KEEP:
|
---|
837 | case EXEC2_SAVE:
|
---|
838 | case EXEC2_FILTER:
|
---|
839 | case EXEC2_CLOSE:
|
---|
840 | case EXEC2_OPEN:
|
---|
841 | case IDM_HELP:
|
---|
842 | {
|
---|
843 | char *cmdline = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
844 | ULONG strid = 0;
|
---|
845 |
|
---|
846 | if (cmdline) {
|
---|
847 | switch (SHORT1FROMMP(mp1)) {
|
---|
848 | case EXEC2_OPEN:
|
---|
849 | strid = IDS_OPENCMDTEXT;
|
---|
850 | break;
|
---|
851 | case EXEC2_CLOSE:
|
---|
852 | strid = IDS_CLOSECMDTEXT;
|
---|
853 | break;
|
---|
854 | case EXEC2_FILTER:
|
---|
855 | strid = IDS_FILTERCMDTEXT;
|
---|
856 | break;
|
---|
857 | case EXEC2_SAVE:
|
---|
858 | strid = (fSaveMiniCmds) ? IDS_NOSAVECMDTEXT : IDS_SAVECMDTEXT;
|
---|
859 | break;
|
---|
860 | case EXEC2_KEEP:
|
---|
861 | strid = (fKeepCmdLine) ? IDS_NOKEEPCMDTEXT : IDS_KEEPCMDTEXT;
|
---|
862 | break;
|
---|
863 | case IDM_HELP:
|
---|
864 | strid = IDS_HELPCMDTEXT;
|
---|
865 | break;
|
---|
866 | }
|
---|
867 | if (strid) {
|
---|
868 | strcpy(cmdline, GetPString(strid));
|
---|
869 | WinDismissDlg(hwnd, 1);
|
---|
870 | }
|
---|
871 | }
|
---|
872 | break;
|
---|
873 | }
|
---|
874 | case EXEC2_CLR:
|
---|
875 | free_cmdlines(FALSE);
|
---|
876 | save_cmdlines(FALSE);
|
---|
877 | WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
878 | break;
|
---|
879 | case EXEC2_DEL:
|
---|
880 | {
|
---|
881 | SHORT x;
|
---|
882 | CHAR cmdline[1001];
|
---|
883 |
|
---|
884 | x = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
885 | EXEC2_LISTBOX,
|
---|
886 | LM_QUERYSELECTION,
|
---|
887 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
888 | if (x >= 0) {
|
---|
889 | *cmdline = 0;
|
---|
890 | WinSendDlgItemMsg(hwnd,
|
---|
891 | EXEC2_LISTBOX,
|
---|
892 | LM_QUERYITEMTEXT,
|
---|
893 | MPFROM2SHORT(x, sizeof(cmdline)),
|
---|
894 | MPFROMP(cmdline));
|
---|
895 | bstrip(cmdline);
|
---|
896 | if (*cmdline) {
|
---|
897 | if (remove_cmdline(cmdline, FALSE) && fSaveMiniCmds) {
|
---|
898 | save_cmdlines(FALSE);
|
---|
899 | WinSendDlgItemMsg(hwnd,
|
---|
900 | EXEC2_LISTBOX,
|
---|
901 | LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
|
---|
902 | if (x)
|
---|
903 | x--;
|
---|
904 | WinSendDlgItemMsg(hwnd,
|
---|
905 | EXEC2_LISTBOX,
|
---|
906 | LM_SELECTITEM,
|
---|
907 | MPFROMSHORT(x), MPFROMSHORT(TRUE));
|
---|
908 | }
|
---|
909 | }
|
---|
910 | }
|
---|
911 | }
|
---|
912 | break;
|
---|
913 | case DID_CANCEL:
|
---|
914 | WinDismissDlg(hwnd, 0);
|
---|
915 | break;
|
---|
916 | }
|
---|
917 | return 0;
|
---|
918 |
|
---|
919 | case WM_DESTROY:
|
---|
920 | break;
|
---|
921 | }
|
---|
922 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
923 | }
|
---|
924 |
|
---|
925 | #pragma alloc_text(CMDLINE1,CmdLineDlgProc,CmdListSubProc,CmdLine2DlgProc,CmdBtnSubProc)
|
---|
926 | #pragma alloc_text(CMDLINE2,save_cmdlines,load_cmdlines,add_cmdline,remove_cmdline,free_cmdlines)
|
---|