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