[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: cmdline.c 1082 2008-07-19 22:37:36Z gyoung $
|
---|
| 5 |
|
---|
[345] | 6 | User defined commands support
|
---|
| 7 |
|
---|
[123] | 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1082] | 9 | Copyright (c) 2004, 2008 Steven H.Levine
|
---|
[123] | 10 |
|
---|
[186] | 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 12 | 05 Jun 05 SHL Use QWL_USER
|
---|
[345] | 13 | 22 Jul 06 SHL Check more run time errors
|
---|
[406] | 14 | 29 Jul 06 SHL Use xfgets_bstripcr
|
---|
[574] | 15 | 22 Mar 07 GKY Use QWL_USER
|
---|
[697] | 16 | 16 Jun 07 SHL Update for OpenWatcom
|
---|
[793] | 17 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[985] | 18 | 29 Feb 08 GKY Use xfree where appropriate
|
---|
[1004] | 19 | 20 Apr 08 GKY New variable names; Save and Load command lines of user set length
|
---|
[1082] | 20 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
|
---|
[123] | 21 |
|
---|
| 22 | ***********************************************************************/
|
---|
| 23 |
|
---|
[2] | 24 | #include <stdlib.h>
|
---|
| 25 | #include <string.h>
|
---|
| 26 | #include <share.h>
|
---|
[689] | 27 | #include <io.h> // unlink
|
---|
[345] | 28 |
|
---|
[907] | 29 | #define INCL_DOS
|
---|
| 30 | #define INCL_WIN
|
---|
| 31 | #define INCL_LONGLONG // dircnrs.h
|
---|
| 32 |
|
---|
[2] | 33 | #include "fm3dlg.h"
|
---|
| 34 | #include "fm3str.h"
|
---|
| 35 | #include "mle.h"
|
---|
[907] | 36 | #include "errutil.h" // Dos_Error...
|
---|
| 37 | #include "strutil.h" // GetPString
|
---|
| 38 | #include "fm3dll.h"
|
---|
[1004] | 39 | #include "pathutil.h" // MaxCmdLineStr
|
---|
[1039] | 40 | #include "fortify.h"
|
---|
[2] | 41 |
|
---|
[345] | 42 | static PSZ pszSrcFile = __FILE__;
|
---|
| 43 |
|
---|
[1004] | 44 | #define MAXNUMCMDLINES 250
|
---|
[2] | 45 |
|
---|
[1004] | 46 | typedef struct LINKCMDLINES
|
---|
[551] | 47 | {
|
---|
[1004] | 48 | CHAR *cmdline;
|
---|
| 49 | struct LINKCMDLINES *next;
|
---|
[551] | 50 | }
|
---|
[1004] | 51 | LINKCMDLINES;
|
---|
[2] | 52 |
|
---|
[1004] | 53 | static LINKCMDLINES *DoItYourselfCmdLine = NULL, *MiniCmdLine = NULL;
|
---|
| 54 | static BOOL DoItYourselfLoaded = FALSE, MiniLoaded = FALSE;
|
---|
[2] | 55 |
|
---|
[1004] | 56 | VOID load_cmdlines(BOOL DoItYourself)
|
---|
[345] | 57 | {
|
---|
[1004] | 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 | */
|
---|
[2] | 63 |
|
---|
[551] | 64 | FILE *fp;
|
---|
[1004] | 65 | LINKCMDLINES *info, *last = NULL, *CmdLineHead;
|
---|
| 66 | PSZ pszCmdLine;
|
---|
| 67 | //CHAR s[1024];
|
---|
[551] | 68 | INT x = 0;
|
---|
[2] | 69 |
|
---|
[1004] | 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;
|
---|
[1082] | 77 | BldFullPathName(pszCmdLine, pFM2SaveDirectory, (DoItYourself) ? "CMDLINES.DAT" : "CMDMINI.DAT");
|
---|
| 78 | /*save_dir2(pszCmdLine);
|
---|
[1004] | 79 | if (pszCmdLine[strlen(pszCmdLine) - 1] != '\\')
|
---|
| 80 | strcat(pszCmdLine, "\\");
|
---|
[1082] | 81 | strcat(pszCmdLine, (DoItYourself) ? "CMDLINES.DAT" : "CMDMINI.DAT");*/
|
---|
[1004] | 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)
|
---|
[1039] | 93 | free(info);
|
---|
[1004] | 94 | else {
|
---|
| 95 | info->next = NULL;
|
---|
| 96 | if (!CmdLineHead)
|
---|
| 97 | CmdLineHead = info;
|
---|
| 98 | else
|
---|
| 99 | last->next = info;
|
---|
| 100 | last = info;
|
---|
| 101 | }
|
---|
| 102 | }
|
---|
| 103 | }
|
---|
[2] | 104 | }
|
---|
[1004] | 105 | fclose(fp);
|
---|
[2] | 106 | }
|
---|
[1039] | 107 | free(pszCmdLine);
|
---|
[2] | 108 | }
|
---|
[1004] | 109 | if (DoItYourself)
|
---|
| 110 | DoItYourselfCmdLine = CmdLineHead;
|
---|
[2] | 111 | else
|
---|
[1004] | 112 | MiniCmdLine = CmdLineHead;
|
---|
[2] | 113 | }
|
---|
| 114 |
|
---|
[1004] | 115 | VOID save_cmdlines(BOOL DoItYourself)
|
---|
[345] | 116 | {
|
---|
[1004] | 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 | */
|
---|
[2] | 122 |
|
---|
[1004] | 123 | LINKCMDLINES *info, *CmdLineHead;
|
---|
[551] | 124 | FILE *fp;
|
---|
[1004] | 125 | PSZ pszCmdLine;
|
---|
| 126 | //CHAR s[CCHMAXPATH + 14];
|
---|
[2] | 127 |
|
---|
[1004] | 128 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
| 129 | if ((DoItYourself && !DoItYourselfLoaded) || (!DoItYourself && !MiniLoaded))
|
---|
[2] | 130 | return;
|
---|
[1004] | 131 | pszCmdLine = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
| 132 | if (!pszCmdLine)
|
---|
| 133 | return;
|
---|
[1082] | 134 | BldFullPathName(pszCmdLine, pFM2SaveDirectory, (DoItYourself) ? "CMDLINES.DAT" : "CMDMINI.DAT");
|
---|
| 135 | /*save_dir2(pszCmdLine);
|
---|
[1004] | 136 | if (pszCmdLine[strlen(pszCmdLine) - 1] != '\\')
|
---|
| 137 | strcat(pszCmdLine, "\\");
|
---|
[1082] | 138 | strcat(pszCmdLine, (DoItYourself) ? "CMDLINES.DAT" : "CMDMINI.DAT");*/
|
---|
[1004] | 139 | if (CmdLineHead) {
|
---|
| 140 | fp = xfopen(pszCmdLine, "w", pszSrcFile, __LINE__);
|
---|
[345] | 141 | if (fp) {
|
---|
[551] | 142 | fputs(GetPString(IDS_COMMANDFILE2TEXT), fp);
|
---|
[1004] | 143 | info = CmdLineHead;
|
---|
[551] | 144 | while (info) {
|
---|
[1004] | 145 | fprintf(fp, "%0.*s\n", 1000, info->cmdline);
|
---|
[551] | 146 | info = info->next;
|
---|
[2] | 147 | }
|
---|
| 148 | fclose(fp);
|
---|
| 149 | }
|
---|
| 150 | }
|
---|
| 151 | else
|
---|
[1004] | 152 | unlink(pszCmdLine);
|
---|
| 153 | if (DoItYourself)
|
---|
| 154 | DoItYourselfCmdLine = CmdLineHead;
|
---|
[2] | 155 | else
|
---|
[1004] | 156 | MiniCmdLine = CmdLineHead;
|
---|
[2] | 157 | }
|
---|
| 158 |
|
---|
[1004] | 159 | BOOL add_cmdline(CHAR *cmdline, BOOL DoItYourself)
|
---|
[345] | 160 | {
|
---|
[1004] | 161 | LINKCMDLINES *info, *last = NULL, *CmdLineHead;
|
---|
[551] | 162 | INT x = 0;
|
---|
[2] | 163 |
|
---|
[1004] | 164 | if (!cmdline || !*cmdline)
|
---|
[2] | 165 | return FALSE;
|
---|
[1004] | 166 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
| 167 | if ((DoItYourself && !DoItYourselfLoaded) || (!DoItYourself && !MiniLoaded))
|
---|
| 168 | load_cmdlines(DoItYourself);
|
---|
| 169 | info = CmdLineHead;
|
---|
[345] | 170 | while (info) {
|
---|
[1004] | 171 | if (!stricmp(info->cmdline, cmdline))
|
---|
[2] | 172 | return FALSE;
|
---|
| 173 | last = info;
|
---|
| 174 | info = info->next;
|
---|
| 175 | x++;
|
---|
| 176 | }
|
---|
[1004] | 177 | info = xmalloc(sizeof(LINKCMDLINES), pszSrcFile, __LINE__);
|
---|
[345] | 178 | if (info) {
|
---|
[1004] | 179 | info->cmdline = xstrdup(cmdline, pszSrcFile, __LINE__);
|
---|
| 180 | if (!info->cmdline)
|
---|
[1009] | 181 | xfree(info, pszSrcFile, __LINE__);
|
---|
[345] | 182 | else {
|
---|
[2] | 183 | info->next = NULL;
|
---|
[1004] | 184 | if (!CmdLineHead)
|
---|
| 185 | CmdLineHead = info;
|
---|
[2] | 186 | else
|
---|
[551] | 187 | last->next = info;
|
---|
[1004] | 188 | if (x > MAXNUMCMDLINES) {
|
---|
| 189 | info = CmdLineHead;
|
---|
| 190 | CmdLineHead = CmdLineHead->next;
|
---|
[1039] | 191 | free(info);
|
---|
[2] | 192 | }
|
---|
[1004] | 193 | if (DoItYourself)
|
---|
| 194 | DoItYourselfCmdLine = CmdLineHead;
|
---|
[2] | 195 | else
|
---|
[1004] | 196 | MiniCmdLine = CmdLineHead;
|
---|
[2] | 197 | return TRUE;
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 | return FALSE;
|
---|
| 201 | }
|
---|
| 202 |
|
---|
[1004] | 203 | BOOL remove_cmdline(CHAR *cmdline, BOOL DoItYourself)
|
---|
[345] | 204 | {
|
---|
[1004] | 205 | LINKCMDLINES *info, *last = NULL, *CmdLineHead;
|
---|
[2] | 206 |
|
---|
[1004] | 207 | if (!cmdline || !*cmdline)
|
---|
[2] | 208 | return FALSE;
|
---|
[1004] | 209 | if ((DoItYourself && !DoItYourselfLoaded) || (!DoItYourself && !MiniLoaded))
|
---|
| 210 | load_cmdlines(DoItYourself);
|
---|
| 211 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
| 212 | info = CmdLineHead;
|
---|
[551] | 213 | while (info) {
|
---|
[1004] | 214 | if (!stricmp(info->cmdline, cmdline)) {
|
---|
[551] | 215 | if (last)
|
---|
| 216 | last->next = info->next;
|
---|
[2] | 217 | else
|
---|
[1004] | 218 | CmdLineHead = info->next;
|
---|
[1009] | 219 | xfree(info->cmdline, pszSrcFile, __LINE__);
|
---|
[1039] | 220 | free(info);
|
---|
[1004] | 221 | if (DoItYourself)
|
---|
| 222 | DoItYourselfCmdLine = CmdLineHead;
|
---|
[2] | 223 | else
|
---|
[1004] | 224 | MiniCmdLine = CmdLineHead;
|
---|
[2] | 225 | return TRUE;
|
---|
| 226 | }
|
---|
| 227 | last = info;
|
---|
| 228 | info = info->next;
|
---|
| 229 | }
|
---|
| 230 | return FALSE;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
[1004] | 233 | VOID free_cmdlines(BOOL DoItYourself)
|
---|
[345] | 234 | {
|
---|
[1004] | 235 | LINKCMDLINES *info, *next, *CmdLineHead;
|
---|
[2] | 236 |
|
---|
[1004] | 237 | CmdLineHead = (DoItYourself) ? DoItYourselfCmdLine : MiniCmdLine;
|
---|
| 238 | info = CmdLineHead;
|
---|
[551] | 239 | while (info) {
|
---|
[2] | 240 | next = info->next;
|
---|
[1009] | 241 | xfree(info->cmdline, pszSrcFile, __LINE__);
|
---|
[1039] | 242 | free(info);
|
---|
[2] | 243 | info = next;
|
---|
| 244 | }
|
---|
[1004] | 245 | CmdLineHead = NULL;
|
---|
| 246 | if (DoItYourself)
|
---|
| 247 | DoItYourselfCmdLine = CmdLineHead;
|
---|
[2] | 248 | else
|
---|
[1004] | 249 | MiniCmdLine = CmdLineHead;
|
---|
[2] | 250 | DosPostEventSem(CompactSem);
|
---|
| 251 | }
|
---|
| 252 |
|
---|
[551] | 253 | MRESULT EXPENTRY CmdBtnSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[345] | 254 | {
|
---|
[551] | 255 | switch (msg) {
|
---|
| 256 | case WM_MOUSEMOVE:
|
---|
| 257 | {
|
---|
| 258 | ULONG strid = 0;
|
---|
[2] | 259 |
|
---|
[551] | 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;
|
---|
[2] | 288 | }
|
---|
[551] | 289 | if (strid)
|
---|
| 290 | BubbleHelp(hwnd, TRUE, FALSE, FALSE, GetPString(strid));
|
---|
| 291 | }
|
---|
| 292 | break;
|
---|
[2] | 293 | }
|
---|
[551] | 294 | return PFNWPButton(hwnd, msg, mp1, mp2);
|
---|
[2] | 295 | }
|
---|
| 296 |
|
---|
[551] | 297 | MRESULT EXPENTRY CmdListSubProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[345] | 298 | {
|
---|
[574] | 299 | PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 300 |
|
---|
[551] | 301 | switch (msg) {
|
---|
| 302 | case WM_MOUSEMOVE:
|
---|
| 303 | if (hwndBubble)
|
---|
| 304 | WinDestroyWindow(hwndBubble);
|
---|
| 305 | break;
|
---|
[2] | 306 |
|
---|
[551] | 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);
|
---|
[2] | 317 | }
|
---|
[551] | 318 | }
|
---|
| 319 | break;
|
---|
[2] | 320 | }
|
---|
[551] | 321 | return oldproc(hwnd, msg, mp1, mp2);
|
---|
[2] | 322 | }
|
---|
| 323 |
|
---|
[551] | 324 | MRESULT EXPENTRY CmdLineDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[345] | 325 | {
|
---|
[2] | 326 | EXECARGS *ex;
|
---|
| 327 |
|
---|
[551] | 328 | switch (msg) {
|
---|
| 329 | case WM_INITDLG:
|
---|
| 330 | ex = (EXECARGS *) mp2;
|
---|
[574] | 331 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) ex);
|
---|
[551] | 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, "\\");
|
---|
[2] | 392 | }
|
---|
| 393 | else
|
---|
[551] | 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 | }
|
---|
[697] | 418 | if (DosQueryAppType(executable, &apptype) ||
|
---|
[551] | 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 | }
|
---|
[2] | 502 | else
|
---|
[551] | 503 | WinSetDlgItemText(hwnd,
|
---|
| 504 | EXEC_WARNING2, GetPString(IDS_UNKNOWNDEFAULTTEXT));
|
---|
| 505 | }
|
---|
| 506 | return 0;
|
---|
[2] | 507 |
|
---|
[551] | 508 | case WM_ADJUSTWINDOWPOS:
|
---|
| 509 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
| 510 | break;
|
---|
[2] | 511 |
|
---|
[551] | 512 | case UM_SETDIR:
|
---|
| 513 | PaintRecessedWindow(WinWindowFromID(hwnd,
|
---|
| 514 | EXEC_WARNING2),
|
---|
| 515 | (HPS) 0, FALSE, FALSE);
|
---|
| 516 | return 0;
|
---|
[2] | 517 |
|
---|
[551] | 518 | case UM_RESCAN:
|
---|
| 519 | WinSendDlgItemMsg(hwnd, EXEC_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1004] | 520 | if (!DoItYourselfLoaded)
|
---|
[551] | 521 | load_cmdlines(TRUE);
|
---|
| 522 | {
|
---|
[1004] | 523 | LINKCMDLINES *info;
|
---|
[2] | 524 |
|
---|
[1004] | 525 | info = DoItYourselfCmdLine;
|
---|
[551] | 526 | while (info) {
|
---|
| 527 | WinSendDlgItemMsg(hwnd,
|
---|
| 528 | EXEC_LISTBOX,
|
---|
| 529 | LM_INSERTITEM,
|
---|
[1004] | 530 | MPFROM2SHORT(LIT_END, 0), MPFROMP(info->cmdline));
|
---|
[551] | 531 | info = info->next;
|
---|
[2] | 532 | }
|
---|
[551] | 533 | }
|
---|
| 534 | return 0;
|
---|
[2] | 535 |
|
---|
[551] | 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 | }
|
---|
[2] | 546 | break;
|
---|
[551] | 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];
|
---|
[2] | 569 |
|
---|
[551] | 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;
|
---|
[2] | 595 |
|
---|
[551] | 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:
|
---|
[2] | 604 | {
|
---|
[551] | 605 | SHORT x;
|
---|
| 606 | CHAR cmdline[1001];
|
---|
[2] | 607 |
|
---|
[551] | 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 | }
|
---|
[2] | 635 | }
|
---|
[551] | 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 | }
|
---|
[2] | 692 | }
|
---|
[551] | 693 | break;
|
---|
[2] | 694 |
|
---|
[551] | 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;
|
---|
[2] | 719 |
|
---|
[551] | 720 | case DID_CANCEL:
|
---|
| 721 | WinDismissDlg(hwnd, 0);
|
---|
| 722 | break;
|
---|
[2] | 723 |
|
---|
[551] | 724 | case EXEC_ABORT:
|
---|
| 725 | WinDismissDlg(hwnd, 2);
|
---|
| 726 | break;
|
---|
[2] | 727 |
|
---|
[551] | 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;
|
---|
[2] | 736 |
|
---|
[551] | 737 | case WM_DESTROY:
|
---|
| 738 | break;
|
---|
[2] | 739 | }
|
---|
[551] | 740 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 741 | }
|
---|
| 742 |
|
---|
[551] | 743 | MRESULT EXPENTRY CmdLine2DlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
[345] | 744 | {
|
---|
[551] | 745 | switch (msg) {
|
---|
| 746 | case WM_INITDLG:
|
---|
| 747 | if (!mp2) {
|
---|
| 748 | WinDismissDlg(hwnd, 0);
|
---|
[2] | 749 | break;
|
---|
[551] | 750 | }
|
---|
[574] | 751 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
[551] | 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 | };
|
---|
[2] | 757 |
|
---|
[551] | 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;
|
---|
[2] | 772 |
|
---|
[551] | 773 | case UM_RESCAN:
|
---|
| 774 | WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
[1004] | 775 | if (!MiniLoaded)
|
---|
[551] | 776 | load_cmdlines(FALSE);
|
---|
| 777 | {
|
---|
[1004] | 778 | LINKCMDLINES *info;
|
---|
[551] | 779 |
|
---|
[1004] | 780 | info = MiniCmdLine;
|
---|
[551] | 781 | while (info) {
|
---|
| 782 | WinSendDlgItemMsg(hwnd, EXEC2_LISTBOX, LM_INSERTITEM,
|
---|
[1004] | 783 | MPFROM2SHORT(LIT_END, 0), MPFROMP(info->cmdline));
|
---|
[551] | 784 | info = info->next;
|
---|
[2] | 785 | }
|
---|
[551] | 786 | }
|
---|
| 787 | return 0;
|
---|
[2] | 788 |
|
---|
[551] | 789 | case WM_CONTROL:
|
---|
| 790 | switch (SHORT1FROMMP(mp1)) {
|
---|
| 791 | case EXEC2_LISTBOX:
|
---|
| 792 | switch (SHORT2FROMMP(mp1)) {
|
---|
| 793 | case LN_ENTER:
|
---|
| 794 | {
|
---|
| 795 | SHORT x;
|
---|
[574] | 796 | CHAR *cmdline = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[2] | 797 |
|
---|
[551] | 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;
|
---|
[2] | 811 | }
|
---|
[551] | 812 | break;
|
---|
| 813 | }
|
---|
| 814 | return 0;
|
---|
[2] | 815 |
|
---|
[551] | 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 | {
|
---|
[574] | 825 | char *cmdline = WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 826 | ULONG strid = 0;
|
---|
[2] | 827 |
|
---|
[551] | 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];
|
---|
[2] | 865 |
|
---|
[551] | 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 | }
|
---|
[2] | 893 | }
|
---|
[551] | 894 | break;
|
---|
| 895 | case DID_CANCEL:
|
---|
| 896 | WinDismissDlg(hwnd, 0);
|
---|
| 897 | break;
|
---|
| 898 | }
|
---|
| 899 | return 0;
|
---|
[2] | 900 |
|
---|
[551] | 901 | case WM_DESTROY:
|
---|
| 902 | break;
|
---|
[2] | 903 | }
|
---|
[551] | 904 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
[2] | 905 | }
|
---|
[793] | 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)
|
---|