Changeset 1488 for trunk/dll


Ignore:
Timestamp:
Dec 22, 2009, 12:42:55 AM (16 years ago)
Author:
Gregg Young
Message:

Fixed commands so reordering them in commands.dat no longer changes their ID or hot key assignment; added 20 new hot keys; the environment information is now used when executing a command; some code clean up in command.c; added CheckExecutibleFlags to systemf.c the eliminate repetative code in assoc.c, command.c & cmdline.c

Location:
trunk/dll
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/assoc.c

    r1479 r1488  
    2121  24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
    2222  15 Nov 09 GKY Add check for attempt to open zero byte file (avoids MMPM trying to play them)
     23  21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c
    2324
    2425**************************************************************************************/
     
    755756        }
    756757        bstrip(temp.mask);
    757         bstrip(temp.pszCmdLine);
    758         if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
     758        bstrip(temp.pszCmdLine);
     759        temp.flags = CheckExecutibleFlags(hwnd, 1);
     760        /*if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
    759761          temp.flags = 0;
    760762        else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
     
    771773          temp.flags |= DIEAFTER;
    772774        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    773           temp.flags |= PROMPT;
     775          temp.flags |= PROMPT;*/
    774776        if (fCancelAction){
    775777          fCancelAction = FALSE;
     
    830832        }
    831833        bstrip(temp.mask);
    832         bstrip(temp.pszCmdLine);
    833         if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
     834        bstrip(temp.pszCmdLine);
     835        temp.flags = CheckExecutibleFlags(hwnd, 1);
     836        /*if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
    834837          temp.flags = 0;
    835838        else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
     
    846849          temp.flags |= DIEAFTER;
    847850        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    848           temp.flags |= PROMPT;
     851          temp.flags |= PROMPT;*/
    849852        if (fCancelAction){
    850853          fCancelAction = FALSE;
     
    934937        }
    935938        bstrip(temp.mask);
    936         bstrip(temp.pszCmdLine);
    937         if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
     939        bstrip(temp.pszCmdLine);
     940        temp.flags = CheckExecutibleFlags(hwnd, 1);
     941        /*if (WinQueryButtonCheckstate(hwnd, ASS_DEFAULT))
    938942          temp.flags = 0;
    939943        else if (WinQueryButtonCheckstate(hwnd, ASS_FULLSCREEN))
     
    950954          temp.flags |= DIEAFTER;
    951955        if (WinQueryButtonCheckstate(hwnd, ASS_PROMPT))
    952           temp.flags |= PROMPT;
     956          temp.flags |= PROMPT;*/
    953957        if (fCancelAction){
    954958          fCancelAction = FALSE;
  • trunk/dll/cmdline.c

    r1482 r1488  
    2626                aren't user settable; realappname should be used for setting applicable to
    2727                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
    2829
    2930***********************************************************************/
     
    718719      ex = INSTDATA(hwnd);
    719720      WinQueryDlgItemText(hwnd, EXEC_CL, 1000, ex->commandline);
    720       ex->flags = 0;
     721      ex->flags = CheckExecutibleFlags(hwnd, 2);
     722      /*ex->flags = 0;
    721723      if (WinQueryButtonCheckstate(hwnd, EXEC_MINIMIZED))
    722724        ex->flags |= MINIMIZED;
     
    732734        ex->flags |= SEPARATEKEEP;
    733735      else
    734         ex->flags |= SEPARATE;
     736        ex->flags |= SEPARATE;*/
    735737      strset(ex->environment, 0);
    736738      WinQueryDlgItemText(hwnd, EXEC_ENVIRON, 1000, ex->environment);
  • trunk/dll/command.c

    r1487 r1488  
    2828  24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
    2929  15 Oct 08 GKY Prevent asking to add %a on NormalizeCmdLine abort
     30  21 Dec 09 GKY Fix the environment so it can be saved, deleted and used consistently.
     31  21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command.
     32                Added load_inicommand to load the IDs from the ini file.
     33  21 Dec 09 GKY Added 20 new hot keys for commands.
     34  21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c
    3035
    3136***********************************************************************/
     
    6267#include "fortify.h"
    6368
     69VOID load_inicommands(VOID);
     70
    6471typedef struct
    6572{
    6673  PSZ pszCmdLine;
    6774  CHAR title[100];
     75  CHAR env[1002];
    6876  ULONG flags;
    6977  ULONG ID;
     
    7785static PSZ pszSrcFile = __FILE__;
    7886static LINKCMDS *cmdtail;
    79 static INT CommandDatVersion = 0;
     87static BOOL UsedCommandIDs[300];
     88static BOOL UsedHotKeyIDs[40];
    8089
    8190#pragma data_seg(GLOBAL2)
    8291LINKCMDS *cmdhead;
    8392BOOL cmdloaded;
    84 BOOL UsedCommandIDs[300];
    85 BOOL UsedHotKeyIDs[20];
    8693
    8794MRESULT EXPENTRY CommandTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     
    338345    xfree(info->title, pszSrcFile, __LINE__);
    339346    xfree(info->pszCmdLine, pszSrcFile, __LINE__);
     347    xfree(info->env, pszSrcFile, __LINE__);
    340348    free(info);
    341349    info = next;
     
    349357  LINKCMDS *info;
    350358  PSZ pszCmdLine;
    351   CHAR *p;
    352359  CHAR title[100];
    353360  CHAR flags[34];
    354   CHAR ID[34];
    355   CHAR HotKeyID[34];
     361  ULONG size;
    356362
    357363  if (cmdhead)
    358364    free_commands();
     365  PrfQueryProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs,
     366                      &size);
     367  PrfQueryProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs,
     368                        &size);
    359369  cmdloaded = TRUE;
    360370  pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     
    363373    fp = _fsopen(pszCmdLine, "r", SH_DENYWR);
    364374    if (fp) {
    365       xfgets(title, sizeof(title), fp, pszSrcFile, __LINE__);
    366       lstrip(title);
    367       if (!strnicmp(title, "Version", 7) && !CommandDatVersion) {
    368         p = title + 7;
    369         while (*p == ' ')
    370           p++;
    371         bstripcr(p);
    372         CommandDatVersion = atol(p);
    373       }
    374375      while (!feof(fp)) {
    375376        if (!xfgets_bstripcr(title, sizeof(title), fp, pszSrcFile, __LINE__))
    376377          break;
    377         title[strlen(title)] = 0;                       // Match size to entry file max
     378        //title[strlen(title)] = 0;  // Match size to entry file max? Not needed as bstripcr does this? GKY 21 Dec 09
    378379        if (!*title || *title == ';')
    379380          continue;
     
    381382          break;                                /* error! */
    382383        if (!xfgets_bstripcr(flags, sizeof(flags), fp, pszSrcFile, __LINE__))
    383           break;                                /* error! */
    384         if (CommandDatVersion) {
    385           if (!xfgets_bstripcr(ID, sizeof(ID), fp, pszSrcFile, __LINE__))
    386             break;                              /* error! */
    387           ID[34] = 0;
    388           if (!xfgets_bstripcr(HotKeyID, sizeof(HotKeyID), fp, pszSrcFile, __LINE__))
    389             break;                              /* error! */
    390           ID[34] = 0;
    391         }
    392         pszCmdLine[strlen(pszCmdLine)] = 0;                     // fixme to know why chopped this way?
    393         //bstripcr(pszCmdLine);
     384          break;
     385        //pszCmdLine[strlen(pszCmdLine)] = 0;      // fixme to know why chopped this way? Not needed as bstripcr does this? GKY 21 Dec 09
    394386        flags[34] = 0;
    395         //bstripcr(flags);
    396387        if (!pszCmdLine)
    397388          continue;
     
    405396          info->title = xstrdup(title, pszSrcFile, __LINE__);
    406397          info->flags = atol(flags);
    407           if (CommandDatVersion) {
    408             info->ID = atol(ID);
    409             info->HotKeyID = atol(HotKeyID);
    410           }
    411398          if (!info->pszCmdLine || !info->title) {
    412399            xfree(info->pszCmdLine, pszSrcFile, __LINE__);
     
    432419      free(pszCmdLine);
    433420      fclose(fp);
    434     }
     421      load_inicommands();
     422    }
     423  }
     424}
     425
     426/**
     427 * load_inicommand loads the data from the ini file into an info struct
     428 * after COMMANDS.DAT has been loaded; It generates new IDs where necessary
     429 * it saves the environment from the old ini key and deletes it as needed
     430 **/
     431
     432VOID load_inicommands(VOID)
     433{
     434  LINKCMDS *info;;
     435  INT x = 0;
     436  INT y = 0;
     437  ULONG ID = 0;
     438  ULONG HotKeyID = 0;
     439  CHAR env[1002];
     440  CHAR keyID[120];
     441  CHAR keyHotKeyID[120];
     442  CHAR keyenv[120];
     443  ULONG size;
     444
     445  if (!cmdloaded || !cmdhead)
     446    return;
     447  info = cmdhead;
     448  while (info) {
     449    bstripcr(info->title);
     450    sprintf(keyID, "COMMAND.%sID", info->title);
     451    sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", info->title);
     452    sprintf(keyenv, "COMMAND.%senv", info->title);
     453    size = sizeof(ULONG);
     454    PrfQueryProfileData(fmprof, FM3Str, keyID, &ID, &size);
     455    size = sizeof(ULONG);
     456    PrfQueryProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, &size);
     457    PrfQueryProfileString(fmprof, FM3Str, keyenv, NullStr, env, sizeof(env));
     458    if (ID) {
     459      if (env != NullStr)
     460        info->env = xstrdup(env, pszSrcFile, __LINE__);
     461      info->ID = ID;
     462      info->HotKeyID = HotKeyID;
     463    }
     464    //This updates the old commands.dat file to the new format
     465    //assigning the IDs based on file order or on next available ID if
     466    //COMMAND.DAT is hand edited.
     467    else {
     468      for (x = 0; x < 300; x++) {
     469        if (!UsedCommandIDs[x]) {
     470          ID = info->ID = IDM_COMMANDSTART + x;
     471          UsedCommandIDs[x] = TRUE;
     472          for (y = 0; y < 40; y++) {
     473            if (!UsedHotKeyIDs[y]) {
     474              HotKeyID = info->HotKeyID = IDM_COMMANDNUM0 + y;
     475              UsedHotKeyIDs[y] = TRUE;
     476              break;
     477            }
     478          }
     479          break;
     480        }
     481        if (x == 299)
     482          saymsg(MB_OK | MB_ICONEXCLAMATION , HWND_DESKTOP,
     483                 GetPString(IDS_COMMANDSLIMITTITLETEXT),
     484                 GetPString(IDS_COMMANDSLIMITREACHEDTEXT ));
     485      }
     486      PrfQueryProfileString(fmprof, FM3Str, info->pszCmdLine, NullStr, env, sizeof(env));
     487      info->env = env;
     488      if (env != NullStr)
     489        PrfWriteProfileString(fmprof, FM3Str, info->pszCmdLine, NULL);
     490      if (info->env)
     491        strcpy(env, info->env);
     492      ID = info->ID;
     493      HotKeyID = info->HotKeyID;
     494      PrfWriteProfileData(fmprof, FM3Str, keyID, &ID, sizeof(INT));
     495      PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, sizeof(INT));
     496      if (env != NullStr)
     497        PrfWriteProfileString(fmprof, FM3Str, keyenv, env);
     498      PrfWriteProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs,
     499                      sizeof(BOOL) * 300);
     500      PrfWriteProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs,
     501                        sizeof(BOOL) * 40);
     502    }
     503    ID = 0;
     504    HotKeyID = 0;
     505    info = info->next;
    435506  }
    436507}
     
    442513  CHAR s[CCHMAXPATH + 14];
    443514  INT x = 0;
     515  INT ID = 0;
     516  INT HotKeyID = 0;
     517  CHAR env[1002];
     518  CHAR keyID[120];
     519  CHAR keyHotKeyID[120];
     520  CHAR keyenv[120];
    444521
    445522  if (!cmdloaded || !cmdhead)
     
    451528  fp = xfopen(s, "w", pszSrcFile, __LINE__);
    452529  if (fp) {
    453     //Adds line for version tracking
    454     fprintf(fp,"Version 2\n");
    455     fputs(GetPString(IDS_COMMANDFILETEXT), fp);
    456     info = cmdhead;
    457530    while (info) {
    458       //This updates the old commands.dat file to the new format
    459       //assigning the IDs based on file order
    460       if (!info->ID) {
    461         info->ID = IDM_COMMANDSTART + x;
    462         UsedCommandIDs[x] = TRUE;
    463         if (x < 20) {
    464           info->HotKeyID = IDM_COMMANDNUM0 + x;
    465           UsedHotKeyIDs[x] = TRUE;
    466         }
    467       }
    468         fprintf(fp, ";\n%0.99s\n%0.*s\n%lu\n%lu\n%lu\n",
    469                 info->title, MaxComLineStrg, info->pszCmdLine,
    470                 info->flags, info->ID, info->HotKeyID);
    471       //else
    472       //  fprintf(fp,
    473       //          ";\n%0.99s\n%0.*s\n%lu\n",
    474       //          info->title, MaxComLineStrg, info->pszCmdLine, info->flags);
     531      fprintf(fp, ";\n%0.99s\n%0.*s\n%lu\n",
     532              info->title, MaxComLineStrg, info->pszCmdLine, info->flags);
     533     
     534      if (info->env)
     535        strcpy(env, info->env);
     536      ID = info->ID;
     537      HotKeyID = info->HotKeyID;
     538      bstripcr(info->title);
     539      sprintf(keyID, "COMMAND.%sID", info->title);
     540      sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", info->title);
     541      sprintf(keyenv, "COMMAND.%senv", info->title);
     542      PrfWriteProfileData(fmprof, FM3Str, keyID, &ID, sizeof(INT));
     543      PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, sizeof(INT));
     544      if (env != NullStr)
     545        PrfWriteProfileString(fmprof, FM3Str, keyenv, env);
    475546      x++;
    476547      info = info->next;
    477     } // while
     548    } // while info
    478549    PrfWriteProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs,
    479550                        sizeof(BOOL) * 300);
    480551    PrfWriteProfileData(fmprof, FM3Str, "UsedHotKeyIDs", &UsedHotKeyIDs,
    481                         sizeof(BOOL) * 20);
     552                        sizeof(BOOL) * 40);
    482553    fclose(fp);
    483554  } // if (fp)
     
    489560{
    490561  LINKCMDS *info;
    491   ULONG size;
    492562  INT x;
     563  INT y;
    493564
    494565  if (!addme || !*addme->pszCmdLine || !*addme->title)
     
    498569    if (!stricmp(info->title, addme->title))
    499570      return NULL;                      // Got a dup
     571    if (addme->HotKeyID && info->HotKeyID && info->HotKeyID == addme->HotKeyID)
     572      info->HotKeyID = 0;  //avoid assigning hot key to multiple commands
    500573    info = info->next;
    501574  }
     
    506579  info->title = xstrdup(addme->title, pszSrcFile, __LINE__);
    507580  info->HotKeyID = addme->HotKeyID;
     581  if (info->HotKeyID >= IDM_COMMANDNUM0 && info->HotKeyID <= IDM_COMMANDNUM19)
     582    UsedHotKeyIDs[info->HotKeyID - IDM_COMMANDNUM0] = TRUE;
     583  else
     584    info->HotKeyID = 0;
    508585  if (!info->ID) {
    509     PrfQueryProfileData(fmprof, FM3Str, "UsedCommandIDs", &UsedCommandIDs,
    510                         &size); //profile updated by save_commands
     586    //profile updated by save_commands
    511587    for (x = 0; x < 300; x++) {
    512588      if (!UsedCommandIDs[x]) {
    513589        info->ID = IDM_COMMANDSTART + x;
    514590        UsedCommandIDs[x] = TRUE;
     591        for (y = 0; y < 40; y++) {
     592          if (!UsedHotKeyIDs[y]) {
     593            info->HotKeyID = IDM_COMMANDNUM0 + y;
     594            UsedHotKeyIDs[y] = TRUE;
     595            break;
     596            }
     597          }
    515598        break;
    516599      }
     600      if (x == 299)
     601        saymsg(MB_OK | MB_ICONEXCLAMATION , HWND_DESKTOP,
     602               GetPString(IDS_COMMANDSLIMITTITLETEXT),
     603               GetPString(IDS_COMMANDSLIMITREACHEDTEXT ));
    517604    }
    518605  }
    519606  if (addme->flags)
    520607    info->flags = addme->flags;
     608  if (addme->env)
     609    info->env = xstrdup(addme->env, pszSrcFile, __LINE__);
    521610  if (!info->pszCmdLine || !info->title || !info->ID) {
    522611    xfree(info->pszCmdLine, pszSrcFile, __LINE__);
     612    xfree(info->title, pszSrcFile, __LINE__);
    523613    xfree(info->title, pszSrcFile, __LINE__);
    524614    free(info);
     
    561651        }
    562652        xfree(info->pszCmdLine, pszSrcFile, __LINE__);
    563         xfree(info->title, pszSrcFile, __LINE__);
     653        xfree(info->title, pszSrcFile, __LINE__);
     654        xfree(info->env, pszSrcFile, __LINE__);
    564655        free(info);
    565656        return TRUE;
     
    642733          WinCheckButton(hwnd, CMD_KEEP, ((info->flags & KEEP) != 0));
    643734          WinCheckButton(hwnd, CMD_ONCE, ((info->flags & ONCE) != 0));
    644           WinSetDlgItemText(hwnd, CMD_TITLE, info->title);
    645           {
    646             CHAR env[1002];
    647             ULONG size;
    648 
    649             *env = 0;
    650             size = sizeof(env) - 1;
    651             if (PrfQueryProfileData(fmprof, FM3Str, info->pszCmdLine, env, &size) &&
    652                 *env)
    653               WinSetDlgItemText(hwnd, CMD_ENVIRON, env);
    654             else
    655               WinSetDlgItemText(hwnd, CMD_ENVIRON, NullStr);
    656           }
     735          WinSetDlgItemText(hwnd, CMD_TITLE, info->title);
     736          if (info->env)
     737            WinSetDlgItemText(hwnd, CMD_ENVIRON, info->env);
     738          else
     739            WinSetDlgItemText(hwnd, CMD_ENVIRON, NullStr);
    657740        }
    658741        break;
     
    724807        PSZ pszWorkBuf;
    725808        APIRET ret;
     809        CHAR env[1002];
    726810
    727811        memset(&temp, 0, sizeof(COMMAND));
     
    746830            strcat(temp.pszCmdLine, " %a");
    747831        }
    748         WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    749         if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     832        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
     833        bstripcr(temp.title);
     834        temp.flags = CheckExecutibleFlags(hwnd, 3);
     835        /*if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
    750836          temp.flags = 0;
    751837        else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
     
    762848          temp.flags |= PROMPT;
    763849        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    764           temp.flags |= ONCE;
     850          temp.flags |= ONCE;*/
     851        *env = 0;
     852        WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
     853        bstripcr(env);
     854        if (*env) {
     855          strcpy(temp.env, env);
     856          }
    765857        if (fCancelAction){
    766858          fCancelAction = FALSE;
     
    771863          info = add_command(&temp);
    772864        if (!info)
    773         {
    774           WinDismissDlg(hwnd, 0);
    775           /*saymsg(MB_ENTER, hwnd,
    776            GetPString(IDS_ERRORTEXT),
    777                  GetPString(IDS_CANTADDCOMMANDTEXT),
    778                  temp.title);*/
    779          }
     865          WinDismissDlg(hwnd, 0);
     866        else {
     867          x = (SHORT) WinSendDlgItemMsg(hwnd,
     868                                        CMD_LISTBOX,
     869                                        LM_INSERTITEM,
     870                                        MPFROM2SHORT(LIT_END, 0),
     871                                        MPFROMP(temp.title));
     872          if (x >= 0) {
     873            WinSendDlgItemMsg(hwnd,
     874                              CMD_LISTBOX,
     875                              LM_SETITEMHANDLE,
     876                              MPFROMSHORT(x), MPFROMP(info));
     877            WinSendDlgItemMsg(hwnd,
     878                              CMD_LISTBOX,
     879                              LM_SELECTITEM,
     880                              MPFROMSHORT(x), MPFROMSHORT(TRUE));
     881          }
     882        }
     883        save_commands();
     884        load_commands();
     885        free(temp.pszCmdLine);
     886      }
     887      x = (SHORT) WinSendDlgItemMsg(hwnd,
     888                                    CMD_LISTBOX,
     889                                    LM_QUERYSELECTION,
     890                                    MPFROMSHORT(LIT_FIRST), MPVOID);
     891      save_commands();
     892      WinDismissDlg(hwnd, 0);
     893      break;
     894
     895    case DID_CANCEL:
     896      WinDismissDlg(hwnd, 0);
     897      break;
     898
     899    case IDM_HELP:
     900      if (hwndHelp)
     901        WinSendMsg(hwndHelp,
     902                   HM_DISPLAY_HELP,
     903                   MPFROM2SHORT(HELP_COMMAND, 0), MPFROMSHORT(HM_RESOURCEID));
     904      break;
     905
     906    case CMD_ADD:
     907      {
     908        COMMAND temp;
     909        PSZ pszWorkBuf;
     910        APIRET ret;
     911        CHAR env[1002];
     912
     913        memset(&temp, 0, sizeof(COMMAND));
     914        temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
     915        if (!temp.pszCmdLine)
     916          break; //already complained
     917        pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
     918        if (!pszWorkBuf) {
     919          free(temp.pszCmdLine);
     920          break; //already complained
     921        }
     922        WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine);
     923        NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
     924        memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
     925        free(pszWorkBuf);
     926        if (!strchr(temp.pszCmdLine, '%') && !fCancelAction){
     927          ret = saymsg(MB_YESNO,
     928                       HWND_DESKTOP,
     929                       NullStr,
     930                       GetPString(IDS_TOACTONSELECTEDTEXT));
     931          if (ret == MBID_YES)
     932            strcat(temp.pszCmdLine, " %a");
     933        }
     934        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
     935        bstripcr(temp.title);
     936        temp.flags = CheckExecutibleFlags(hwnd, 3);
     937        /*if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     938          temp.flags = 0;
     939        else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
     940          temp.flags = FULLSCREEN;
     941        else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))
     942          temp.flags = MINIMIZED;
     943        else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))
     944          temp.flags = MAXIMIZED;
     945        else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))
     946          temp.flags = INVISIBLE;
     947        if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))
     948          temp.flags |= KEEP;
     949        if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))
     950          temp.flags |= PROMPT;
     951        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
     952          temp.flags |= ONCE;*/
     953        *env = 0;
     954        WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
     955        bstripcr(env);
     956        if (*env) {
     957          strcpy(temp.env, env);
     958          }
     959        if (fCancelAction){
     960          fCancelAction = FALSE;
     961          free(temp.pszCmdLine);
     962          break;
     963        }
     964        else
     965          info = add_command(&temp);
     966        if (!info) {
     967          saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
     968                 GetPString(IDS_CANTADDCOMMANDTEXTDUP), temp.title);
     969        }
    780970        else {
    781           CHAR env[1002];
    782 
    783           *env = 0;
    784           WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
    785           bstripcr(env);
    786           if (*env) {
    787             PrfWriteProfileString(fmprof, FM3Str, temp.pszCmdLine, env);
    788           }
    789971          x = (SHORT) WinSendDlgItemMsg(hwnd,
    790972                                        CMD_LISTBOX,
     
    806988        free(temp.pszCmdLine);
    807989      }
    808       x = (SHORT) WinSendDlgItemMsg(hwnd,
    809                                     CMD_LISTBOX,
    810                                     LM_QUERYSELECTION,
    811                                     MPFROMSHORT(LIT_FIRST), MPVOID);
    812       WinDismissDlg(hwnd, 0);
    813       break;
    814 
    815     case DID_CANCEL:
    816       WinDismissDlg(hwnd, 0);
    817       break;
    818 
    819     case IDM_HELP:
    820       if (hwndHelp)
    821         WinSendMsg(hwndHelp,
    822                    HM_DISPLAY_HELP,
    823                    MPFROM2SHORT(HELP_COMMAND, 0), MPFROMSHORT(HM_RESOURCEID));
    824       break;
    825 
    826     case CMD_ADD:
    827       {
    828         COMMAND temp;
    829         PSZ pszWorkBuf;
    830         APIRET ret;
    831 
    832         memset(&temp, 0, sizeof(COMMAND));
    833         temp.pszCmdLine = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
    834         if (!temp.pszCmdLine)
    835           break; //already complained
    836         pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
    837         if (!pszWorkBuf) {
    838           free(temp.pszCmdLine);
    839           break; //already complained
    840         }
    841         WinQueryDlgItemText(hwnd, CMD_CL, MaxComLineStrg, temp.pszCmdLine);
    842         NormalizeCmdLine(pszWorkBuf, temp.pszCmdLine);
    843         memcpy(temp.pszCmdLine, pszWorkBuf, strlen(pszWorkBuf) + 1);
    844         free(pszWorkBuf);
    845         if (!strchr(temp.pszCmdLine, '%') && !fCancelAction){
    846           ret = saymsg(MB_YESNO,
    847                        HWND_DESKTOP,
    848                        NullStr,
    849                        GetPString(IDS_TOACTONSELECTEDTEXT));
    850           if (ret == MBID_YES)
    851             strcat(temp.pszCmdLine, " %a");
    852         }
    853         WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    854         if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
    855           temp.flags = 0;
    856         else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
    857           temp.flags = FULLSCREEN;
    858         else if (WinQueryButtonCheckstate(hwnd, CMD_MINIMIZED))
    859           temp.flags = MINIMIZED;
    860         else if (WinQueryButtonCheckstate(hwnd, CMD_MAXIMIZED))
    861           temp.flags = MAXIMIZED;
    862         else if (WinQueryButtonCheckstate(hwnd, CMD_INVISIBLE))
    863           temp.flags = INVISIBLE;
    864         if (WinQueryButtonCheckstate(hwnd, CMD_KEEP))
    865           temp.flags |= KEEP;
    866         if (WinQueryButtonCheckstate(hwnd, CMD_PROMPT))
    867           temp.flags |= PROMPT;
    868         if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    869           temp.flags |= ONCE;
    870         if (fCancelAction){
    871           fCancelAction = FALSE;
    872           free(temp.pszCmdLine);
    873           break;
    874         }
    875         else
    876           info = add_command(&temp);
    877         if (!info) {
    878           saymsg(MB_ENTER, hwnd, GetPString(IDS_ERRORTEXT),
    879                  GetPString(IDS_CANTADDCOMMANDTEXTDUP), temp.title);
    880         }
    881         else {
    882           CHAR env[1002];
    883 
    884           *env = 0;
    885           WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
    886           bstripcr(env);
    887           if (*env) {
    888             PrfWriteProfileString(fmprof, FM3Str, temp.title, env);
    889           }
    890           x = (SHORT) WinSendDlgItemMsg(hwnd,
    891                                         CMD_LISTBOX,
    892                                         LM_INSERTITEM,
    893                                         MPFROM2SHORT(LIT_END, 0),
    894                                         MPFROMP(temp.title));
    895           if (x >= 0) {
    896             WinSendDlgItemMsg(hwnd,
    897                               CMD_LISTBOX,
    898                               LM_SETITEMHANDLE,
    899                               MPFROMSHORT(x), MPFROMP(info));
    900             WinSendDlgItemMsg(hwnd,
    901                               CMD_LISTBOX,
    902                               LM_SELECTITEM,
    903                               MPFROMSHORT(x), MPFROMSHORT(TRUE));
    904             save_commands();
    905           }
    906         }
    907         free(temp.pszCmdLine);
    908       }
    909990      break;
    910991
    911992    case CMD_DELETE:
    912993      {
    913         CHAR temp[100];
     994        CHAR temp[100];
     995        CHAR keyID[120];
     996        CHAR keyHotKeyID[120];
     997        CHAR keyenv[120];
    914998
    915999        WinQueryDlgItemText(hwnd, CMD_TITLE, 100, temp);
    916         bstrip(temp);
    917         PrfWriteProfileString(fmprof, FM3Str, temp, NULL);
     1000        bstripcr(temp);
     1001        sprintf(keyID, "COMMAND.%sID", temp);
     1002        sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp);
     1003        sprintf(keyenv, "COMMAND.%senv", temp);
     1004        PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, NULL);
     1005        PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, NULL);
     1006        PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL);
    9181007        if (!kill_command(temp))
    9191008          Runtime_Error(pszSrcFile, __LINE__, "kill_command");
     
    9321021                              MPFROMSHORT(LIT_NONE), MPFROMSHORT(FALSE));
    9331022          }
    934           save_commands();
     1023          save_commands();
    9351024        }
    9361025      }
     
    9421031        COMMAND temp;
    9431032        APIRET ret;
     1033        CHAR keyID[120];
     1034        CHAR keyHotKeyID[120];
     1035        CHAR keyenv[120];
     1036        CHAR env[1002];
     1037        INT ID = 0;
     1038        INT HotKeyID = 0;
     1039        ULONG size;
    9441040
    9451041        pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
     
    9761072                                      MPFROMSHORT(LIT_CURSOR), MPVOID);
    9771073        WinQueryDlgItemText(hwnd, CMD_TITLE, sizeof(temp.title), temp.title);
    978         bstrip(temp.title);
    979         PrfWriteProfileString(fmprof, FM3Str, temp.title, NULL);
     1074        bstripcr(temp.title);
     1075        sprintf(keyID, "COMMAND.%sID", temp.title);
     1076        sprintf(keyHotKeyID, "COMMAND.%sHotKeyID", temp.title);
     1077        sprintf(keyenv, "COMMAND.%senv", temp.title);
     1078        PrfQueryProfileData(fmprof, FM3Str, keyID, &ID, &size);
     1079        PrfQueryProfileData(fmprof, FM3Str, keyHotKeyID, &HotKeyID, &size);
     1080        PrfQueryProfileString(fmprof, FM3Str, keyenv, NullStr, env, sizeof(env));
     1081        temp.ID = ID;
     1082        temp.HotKeyID = HotKeyID;
     1083        if (env != NullStr)
     1084          strcpy(temp.env, env);
     1085        PrfWriteProfileData(fmprof, FM3Str, keyID, NULL, NULL);
     1086        PrfWriteProfileData(fmprof, FM3Str, keyHotKeyID, NULL, NULL);
     1087        PrfWriteProfileString(fmprof, FM3Str, keyenv, NULL);
    9801088        if (kill_command(temp.title)){
    9811089          x = (SHORT) WinSendDlgItemMsg(hwnd,
     
    9931101          }
    9941102        } // then do an add
    995         if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
     1103        temp.flags = CheckExecutibleFlags(hwnd, 3);
     1104        /*if (WinQueryButtonCheckstate(hwnd, CMD_DEFAULT))
    9961105          temp.flags = 0;
    9971106        else if (WinQueryButtonCheckstate(hwnd, CMD_FULLSCREEN))
     
    10081117          temp.flags |= PROMPT;
    10091118        if (WinQueryButtonCheckstate(hwnd, CMD_ONCE))
    1010           temp.flags |= ONCE;
     1119          temp.flags |= ONCE;*/
     1120        *env = 0;
     1121        WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
     1122        bstripcr(env);
     1123        if (*env)
     1124          strcpy(temp.env, env);
     1125        if (!*env && temp.env != NullStr)
     1126          strcpy(temp.env, NullStr);
    10111127        info = add_command(&temp);
    10121128        if (!info) {
     
    10171133
    10181134        else {
    1019           CHAR env[1002];
    1020 
    1021           *env = 0;
    1022           WinQueryDlgItemText(hwnd, CMD_ENVIRON, 1000, env);
    1023           bstripcr(env);
    1024           if (*env) {
    1025             PrfWriteProfileString(fmprof, FM3Str, temp.title, env);
    1026           } //put item back in original place
     1135          //put item back in original place
    10271136          x = (SHORT) WinSendDlgItemMsg(hwnd,
    10281137                                        CMD_LISTBOX,
     
    10891198  LINKCMDS *info;
    10901199
    1091   DbgMsg(pszSrcFile, __LINE__,"ID %i", cx);
    10921200  list = BuildList(hwnd);
    10931201  x = 0;
    10941202  info = cmdhead;
    10951203  while (info) {
    1096     //x++;
    10971204    if (cx < 4300) {
    10981205      if (info->ID == cx)
     
    11081215
    11091216    INT flags;
    1110     CHAR env[1002];
    11111217
    11121218    x--;
     
    11191225      flags |= SEPARATE;
    11201226    flags &= ~(KEEP | DIEAFTER);
    1121     PrfQueryProfileString(fmprof, FM3Str, info->title, NullStr, env, sizeof(env));
    11221227    if (!strchr(info->pszCmdLine, '%')) {
    11231228      CHAR *fakelist[2];
     
    11271232      ExecOnList(hwnd,
    11281233                 info->pszCmdLine,
    1129                  flags, env, fakelist, GetPString(IDS_EXECCMDTITLETEXT),
     1234                 flags, info->env != NullStr ? info->env : NULL,
     1235                 fakelist, GetPString(IDS_EXECCMDTITLETEXT),
    11301236                 pszSrcFile, __LINE__);
    11311237    }
     
    11411247        ExecOnList(hwnd,
    11421248                   info->pszCmdLine,
    1143                    flags, env, fakelist, GetPString(IDS_EXECCMDTITLETEXT),
     1249                   flags, info->env != NullStr ? info->env : NULL,
     1250                   fakelist, GetPString(IDS_EXECCMDTITLETEXT),
    11441251                   pszSrcFile, __LINE__);
    11451252      }
     
    11481255      ExecOnList(hwnd,
    11491256                 info->pszCmdLine,
    1150                  flags, env, list, GetPString(IDS_EXECCMDTITLETEXT),
     1257                 flags, info->env != NullStr ? info->env : NULL,
     1258                 list, GetPString(IDS_EXECCMDTITLETEXT),
    11511259                 pszSrcFile, __LINE__);
    11521260    else
  • trunk/dll/command.h

    r1486 r1488  
    1111  01 Mar 08 GKY Move from fm3dll.h to here
    1212  22 Jun 08 GKY Moved free_commands here for fortify checking
     13  21 Dec 09 GKY Fix the environment so it can be saved, deleted and used consistently.
    1314
    1415***********************************************************************/
     
    3132  PSZ pszCmdLine;
    3233  CHAR *title;
     34  CHAR *env;
    3335  ULONG flags;
    3436  ULONG ID;
  • trunk/dll/fm3dll2.h

    r1486 r1488  
    3131  15 Sep 09 SHL Add rescan progress timer
    3232  22 Nov 09 GKY Add LVM.EXE to partition submenu
     33  21 Dec 09 GKY Added 20 new hot keys for commands.
    3334
    3435  Align with spaces only - no tabs please
     
    524525#define IDM_COMMANDNUM18    4319
    525526#define IDM_COMMANDNUM19    4320
     527#define IDM_COMMANDNUM20    4321
     528#define IDM_COMMANDNUM21    4322
     529#define IDM_COMMANDNUM22    4323
     530#define IDM_COMMANDNUM23    4324
     531#define IDM_COMMANDNUM24    4325
     532#define IDM_COMMANDNUM25    4326
     533#define IDM_COMMANDNUM26    4327
     534#define IDM_COMMANDNUM27    4328
     535#define IDM_COMMANDNUM28    4329
     536#define IDM_COMMANDNUM29    4330
     537#define IDM_COMMANDNUM30    4331
     538#define IDM_COMMANDNUM31    4332
     539#define IDM_COMMANDNUM32    4333
     540#define IDM_COMMANDNUM33    4334
     541#define IDM_COMMANDNUM34    4335
     542#define IDM_COMMANDNUM35    4336
     543#define IDM_COMMANDNUM36    4337
     544#define IDM_COMMANDNUM37    4338
     545#define IDM_COMMANDNUM38    4339
     546#define IDM_COMMANDNUM39    4340
    526547
    527548#define IDM_QUICKTOOLSTART  4899
  • trunk/dll/fm3res.rc

    r1480 r1488  
    4848  15 Nov 09 GKY Add ZEROBYTETEXT
    4949  22 Nov 09 GKY Add LVM.EXE to partition submenu
     50  21 Dec 09 GKY Added 20 new hot keys for commands.
     51  21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command.
     52                Added load_inicommand to load the IDs from the ini file.(new error strings)
    5053
    5154***********************************************************************/
     
    614617  "(",        IDM_COMMANDNUM18,       SHIFT,CONTROL
    615618  ")",        IDM_COMMANDNUM19,       SHIFT,CONTROL
     619  "1",        IDM_COMMANDNUM20,       ALT
     620  "2",        IDM_COMMANDNUM21,       ALT
     621  "3",        IDM_COMMANDNUM22,       ALT
     622  "4",        IDM_COMMANDNUM23,       ALT
     623  "5",        IDM_COMMANDNUM24,       ALT
     624  "6",        IDM_COMMANDNUM25,       ALT
     625  "7",        IDM_COMMANDNUM26,       ALT
     626  "8",        IDM_COMMANDNUM27,       ALT
     627  "9",        IDM_COMMANDNUM28,       ALT
     628  "0",        IDM_COMMANDNUM29,       ALT
     629  "!",        IDM_COMMANDNUM30,       SHIFT,ALT
     630  "@",        IDM_COMMANDNUM31,       SHIFT,ALT
     631  "#",        IDM_COMMANDNUM32,       SHIFT,ALT
     632  "$",        IDM_COMMANDNUM33,       SHIFT,ALT
     633  "%",        IDM_COMMANDNUM34,       SHIFT,ALT
     634  94,         IDM_COMMANDNUM35,       CHAR,SHIFT,ALT
     635  "&",        IDM_COMMANDNUM36,       SHIFT,ALT
     636  "*",        IDM_COMMANDNUM37,       SHIFT,ALT
     637  "(",        IDM_COMMANDNUM38,       SHIFT,ALT
     638  ")",        IDM_COMMANDNUM39,       SHIFT,ALT
    616639  "k",        IDM_HELPKEYS,           CONTROL
    617640  "O",        IDM_OPENWALK,           CONTROL,SHIFT
     
    670693  "(",        IDM_COMMANDNUM18,       SHIFT,CONTROL
    671694  ")",        IDM_COMMANDNUM19,       SHIFT,CONTROL
     695  "1",        IDM_COMMANDNUM20,       ALT
     696  "2",        IDM_COMMANDNUM21,       ALT
     697  "3",        IDM_COMMANDNUM22,       ALT
     698  "4",        IDM_COMMANDNUM23,       ALT
     699  "5",        IDM_COMMANDNUM24,       ALT
     700  "6",        IDM_COMMANDNUM25,       ALT
     701  "7",        IDM_COMMANDNUM26,       ALT
     702  "8",        IDM_COMMANDNUM27,       ALT
     703  "9",        IDM_COMMANDNUM28,       ALT
     704  "0",        IDM_COMMANDNUM29,       ALT
     705  "!",        IDM_COMMANDNUM30,       SHIFT,ALT
     706  "@",        IDM_COMMANDNUM31,       SHIFT,ALT
     707  "#",        IDM_COMMANDNUM32,       SHIFT,ALT
     708  "$",        IDM_COMMANDNUM33,       SHIFT,ALT
     709  "%",        IDM_COMMANDNUM34,       SHIFT,ALT
     710  94,         IDM_COMMANDNUM35,       CHAR,SHIFT,ALT
     711  "&",        IDM_COMMANDNUM36,       SHIFT,ALT
     712  "*",        IDM_COMMANDNUM37,       SHIFT,ALT
     713  "(",        IDM_COMMANDNUM38,       SHIFT,ALT
     714  ")",        IDM_COMMANDNUM39,       SHIFT,ALT
    672715  "k",        IDM_HELPKEYS,           CONTROL
    673716  "T",        IDM_SETTARGET,          CONTROL,SHIFT
     
    24682511    IDS_MISSINGTEXT                       "Some text is missing"
    24692512    IDS_TOOLHELPTEXTBLANK                 "You need to provide both button text & help."
     2513    IDS_COMMANDSLIMITTITLETEXT            "Commands Limit Has Been Reached"
     2514    IDS_COMMANDSLIMITREACHEDTEXT          "You have used all the IDs (300) available for user added commands. You must delete an existing command before adding a new one."
    24702515    IDS_COLSELECTEDHELP                   "This window shows you how many objects\rand how many bytes are selected.\rDrop on me to collect objects.\rClick me for the select menu."
    24712516    IDS_COLTOTALSHELP                     "This window shows you how many objects\rand how many bytes are in the Collector.\rDrop on me to collect objects."
  • trunk/dll/fm3str.h

    r1479 r1488  
    3838  15 Sep 09 SHL Add ids for rescan progress messages
    3939  15 Nov 09 GKY Add ZEROBYTETEXT (58)
     40  21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command.
     41                Added load_inicommand to load the IDs from the ini file.(new error strings)
    4042
    4143***********************************************************************/
     
    149151#define IDS_10SYSTEMVIOTEXT                                   106
    150152#define IDS_10SYSTEMMONOTEXT                                  107
     153#define IDS_COMMANDSLIMITTITLETEXT                            108
     154#define IDS_COMMANDSLIMITREACHEDTEXT                          109
    151155#define IDS_COLSELECTEDHELP                                   110
    152156#define IDS_COLTOTALSHELP                                     111
  • trunk/dll/misc.c

    r1486 r1488  
    6363  22 Jul 09 GKY Check if drives support EAs add driveflag for this
    6464  22 Jul 09 GKY Allow .LONGNAME to be displayed for FAT drives.
     65  21 Dec 09 GKY Allow command menu reorder without changing the "ID" or hot key for a command.
     66                Added load_inicommand to load the IDs from the ini file.
    6567
    6668***********************************************************************/
     
    13201322                                  MPVOID, MPVOID);
    13211323    WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM, MPFROMSHORT(-1), MPVOID);
    1322     //for (x = 0; x < numitems; x++)
    13231324    info = cmdhead;
    13241325    while (info) {
    13251326      WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
    13261327                 MPFROMSHORT((SHORT) (info->ID)), MPVOID);
     1328      x++;
    13271329      info = info->next;
     1330    }
     1331    while (numitems != MIT_ERROR) { // Delete items that were deleted from commands since the ID is gone
     1332      numitems = (SHORT) WinSendMsg(mit.hwndSubMenu, MM_ITEMIDFROMPOSITION,
     1333                                    MPFROMSHORT((SHORT) 1), MPVOID);
     1334      WinSendMsg(mit.hwndSubMenu, MM_DELETEITEM,
     1335                 MPFROMSHORT(numitems), MPVOID);
    13281336    }
    13291337    if (hwndCnr && cmdhead) {
     
    13321340      while (info) {
    13331341
    1334         CHAR s[CCHMAXPATH + 24];
     1342        CHAR s[CCHMAXPATH + 24];
    13351343
    13361344        sprintf(s,
    1337                 "%s {%i} %s%s",
     1345                "%s {%i} %s%s%s",
    13381346                info->title, info->ID,
    1339                 info->HotKeyID ? "\tCtrl + " : NullStr,
    1340                 info->HotKeyID && info->HotKeyID > 4310 ? "Shift + " : NullStr);
     1347                info->HotKeyID && info->HotKeyID < IDM_COMMANDNUM20 ? "\tCtrl + " : NullStr,
     1348                info->HotKeyID && info->HotKeyID > IDM_COMMANDNUM19 ? "\tAlt + " : NullStr,
     1349                info->HotKeyID && ((info->HotKeyID > IDM_COMMANDNUM9 &&
     1350                                   info->HotKeyID < IDM_COMMANDNUM20) ||
     1351                info->HotKeyID > IDM_COMMANDNUM29) ? "Shift + " : NullStr);
    13411352        if (info->HotKeyID)
    13421353          sprintf(&s[strlen(s)], "%d",
    1343                   (((info->HotKeyID - 4301) % 10) + 1) == 10 ? 0 :
    1344                   ((info->HotKeyID - 4301) % 10) + 1);
    1345         mi.id = info->ID; //IDM_COMMANDSTART + x;
     1354                  (((info->HotKeyID - IDM_COMMANDNUM0) % 10) + 1) == 10 ? 0 :
     1355                   ((info->HotKeyID - IDM_COMMANDNUM0) % 10) + 1);
     1356        mi.id = info->ID;
    13461357        mi.afAttribute = (info->flags & ONCE ? MIA_CHECKED : 0) |
    13471358                         (info->flags & PROMPT ? MIA_FRAMED : 0);
    13481359        mi.afStyle = MIS_TEXT;
    1349         if (!(x % 24) && x && info->next)
     1360        if (!(x % 20) && x && info->next)
    13501361          mi.afStyle |= MIS_BREAK;
    13511362        WinSendMsg(mit.hwndSubMenu, MM_INSERTITEM, MPFROMP(&mi), MPFROMP(s));
  • trunk/dll/systemf.c

    r1480 r1488  
    2727                Dos/Win programs from being inserted into the execute dialog with message why.
    2828  12 Jul 09 GKY Allow FM/2 to load in high memory
     29  21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c
    2930
    3031***********************************************************************/
     
    6465static PSZ pszSrcFile = __FILE__;
    6566
     67     
    6668//static HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
    6769//          PROGTYPE * progt, ULONG fl, char *formatstring, ...);
     70
     71/**
     72 * CheckExecutibleFlags checks the dialog controls and returns the appropriate
     73 * flags to be passed the runemf
     74 */
     75
     76ULONG CheckExecutibleFlags(HWND hwnd, INT caller)
     77{
     78  /**
     79   * caller indicates the dialog calling the function:
     80   * 1 = Associations (ASS_)
     81   * 2 = CmdLine      (EXEC_)
     82   * 3 = Commands     (CMD_)
     83   **/
     84
     85  ULONG flags = 0;
     86
     87  if (caller != 2 &&
     88      WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_DEFAULT : ASS_DEFAULT))
     89    flags = 0;
     90  else if (WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_FULLSCREEN :
     91                                    caller == 1 ? ASS_FULLSCREEN : EXEC_FULLSCREEN))
     92    flags = FULLSCREEN;
     93  else if (WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_MINIMIZED :
     94                                    caller == 1 ? ASS_MINIMIZED : EXEC_MINIMIZED))
     95    flags = MINIMIZED;
     96  else if (WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_MAXIMIZED :
     97                                    caller == 1 ? ASS_MAXIMIZED : EXEC_MAXIMIZED))
     98    flags = MAXIMIZED;
     99  else if (WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_INVISIBLE :
     100                                    caller == 1 ? ASS_INVISIBLE : EXEC_INVISIBLE))
     101    flags = INVISIBLE;
     102  if (WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_KEEP : caller == 1 ? ASS_KEEP :
     103                               EXEC_KEEP))
     104    flags |= caller == 2 ? SEPARATEKEEP : KEEP;
     105  else if (caller == 2)
     106    flags |= SEPARATE;
     107  if (caller !=2 && WinQueryButtonCheckstate(hwnd, caller == 3 ? CMD_PROMPT : ASS_PROMPT))
     108    flags |= PROMPT;
     109  if (caller == 3 && WinQueryButtonCheckstate(hwnd, CMD_ONCE))
     110    flags |= ONCE;
     111  if (caller == 1 && WinQueryButtonCheckstate(hwnd, ASS_DIEAFTER))
     112    flags |= DIEAFTER;
     113  return flags;
     114}
    68115
    69116/**
  • trunk/dll/systemf.h

    r1394 r1488  
    1010
    1111  Change log
     12  21 Dec 09 GKY Added CheckExecutibleFlags to streamline code in command.c assoc.c & cmdline.c
    1213
    1314***********************************************************************/
     
    4849EXECARGS;
    4950
     51ULONG CheckExecutibleFlags(HWND hwnd, INT caller);
    5052INT ExecOnList(HWND hwnd, PSZ command, INT flags, PSZ tpath,
    5153               PSZ *list, PCSZ prompt, PCSZ pszCallingFile, UINT uiLineNumber);
Note: See TracChangeset for help on using the changeset viewer.