Changeset 507 for trunk/dll/command.c


Ignore:
Timestamp:
Sep 25, 2006, 3:04:31 AM (19 years ago)
Author:
root
Message:

Add replace command and update okay to add if changed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/command.c

    r445 r507  
    1414  29 Jul 06 SHL Use xfgets_bstripcr
    1515  15 Aug 06 SHL Better can't add message
     16  18 Sep 06 GKY Add replace command and update okay to add if changed
    1617
    1718***********************************************************************/
     
    639640          break;
    640641
    641         case DID_OK:
     642          case DID_OK:
     643         {
     644            x = (SHORT)WinSendDlgItemMsg(hwnd,
     645                                           CMD_LISTBOX,
     646                                           LM_QUERYSELECTION,
     647                                           MPVOID,
     648                                           MPVOID);
     649            if(x==LIT_NONE)
     650             x = (SHORT) WinSendDlgItemMsg(hwnd,
     651                                           CMD_LISTBOX,
     652                                          LM_SELECTITEM,
     653                                          MPFROMSHORT(0),
     654                                          MPFROMSHORT(TRUE));
     655            }
     656          {
     657            COMMAND temp;
     658
     659            memset(&temp,0,sizeof(COMMAND));
     660            WinQueryDlgItemText(hwnd,CMD_CL,sizeof(temp.cl),temp.cl);
     661            bstrip(temp.cl);
     662            WinQueryDlgItemText(hwnd,CMD_TITLE,sizeof(temp.title),temp.title);
     663            if(WinQueryButtonCheckstate(hwnd,CMD_DEFAULT))
     664              temp.flags = 0;
     665            else if(WinQueryButtonCheckstate(hwnd,CMD_FULLSCREEN))
     666              temp.flags = FULLSCREEN;
     667            else if(WinQueryButtonCheckstate(hwnd,CMD_MINIMIZED))
     668              temp.flags = MINIMIZED;
     669            else if(WinQueryButtonCheckstate(hwnd,CMD_MAXIMIZED))
     670              temp.flags = MAXIMIZED;
     671            else if(WinQueryButtonCheckstate(hwnd,CMD_INVISIBLE))
     672              temp.flags = INVISIBLE;
     673            if(WinQueryButtonCheckstate(hwnd,CMD_KEEP))
     674              temp.flags |= KEEP;
     675            if(WinQueryButtonCheckstate(hwnd,CMD_PROMPT))
     676              temp.flags |= PROMPT;
     677            if(WinQueryButtonCheckstate(hwnd,CMD_ONCE))
     678              temp.flags |= ONCE;
     679            info = add_command(&temp);
     680            if (!info)
     681                WinDismissDlg(hwnd,0);
     682                /*{
     683             /* saymsg(MB_ENTER,
     684                     hwnd,
     685                     GetPString(IDS_ERRORTEXT),
     686                     // GetPString(IDS_CANTADDCOMMANDTEXT),
     687                     "Can't add %s to command list", temp.title);       // fixme to be in fm3dll.str
     688            }  */
     689            else {
     690              CHAR env[1002];
     691
     692              *env = 0;
     693              WinQueryDlgItemText(hwnd,CMD_ENVIRON,1000,env);
     694              bstripcr(env);
     695              if (*env) {
     696                PrfWriteProfileString(fmprof,
     697                                      FM3Str,
     698                                      temp.cl,
     699                                      env);
     700              }
     701              x = (SHORT)WinSendDlgItemMsg(hwnd,
     702                                           CMD_LISTBOX,
     703                                           LM_INSERTITEM,
     704                                           MPFROM2SHORT(LIT_END,0),
     705                                           MPFROMP(temp.title));
     706              if(x >= 0) {
     707                WinSendDlgItemMsg(hwnd,
     708                                  CMD_LISTBOX,
     709                                  LM_SETITEMHANDLE,
     710                                  MPFROMSHORT(x),
     711                                  MPFROMP(info));
     712                WinSendDlgItemMsg(hwnd,
     713                                  CMD_LISTBOX,
     714                                  LM_SELECTITEM,
     715                                  MPFROMSHORT(x),
     716                                  MPFROMSHORT(TRUE));
     717                save_commands();
     718              }
     719            }
     720          }
    642721          x = (SHORT)WinSendDlgItemMsg(hwnd,
    643722                                       CMD_LISTBOX,
     
    661740
    662741        case CMD_ADD:
     742          {
     743            COMMAND temp;
     744
     745            memset(&temp,0,sizeof(COMMAND));
     746            WinQueryDlgItemText(hwnd,CMD_CL,sizeof(temp.cl),temp.cl);
     747            bstrip(temp.cl);
     748            WinQueryDlgItemText(hwnd,CMD_TITLE,sizeof(temp.title),temp.title);
     749            if(WinQueryButtonCheckstate(hwnd,CMD_DEFAULT))
     750              temp.flags = 0;
     751            else if(WinQueryButtonCheckstate(hwnd,CMD_FULLSCREEN))
     752              temp.flags = FULLSCREEN;
     753            else if(WinQueryButtonCheckstate(hwnd,CMD_MINIMIZED))
     754              temp.flags = MINIMIZED;
     755            else if(WinQueryButtonCheckstate(hwnd,CMD_MAXIMIZED))
     756              temp.flags = MAXIMIZED;
     757            else if(WinQueryButtonCheckstate(hwnd,CMD_INVISIBLE))
     758              temp.flags = INVISIBLE;
     759            if(WinQueryButtonCheckstate(hwnd,CMD_KEEP))
     760              temp.flags |= KEEP;
     761            if(WinQueryButtonCheckstate(hwnd,CMD_PROMPT))
     762              temp.flags |= PROMPT;
     763            if(WinQueryButtonCheckstate(hwnd,CMD_ONCE))
     764              temp.flags |= ONCE;
     765            info = add_command(&temp);
     766            if (!info) {
     767              saymsg(MB_ENTER,
     768                     hwnd,
     769                     GetPString(IDS_ERRORTEXT),
     770                     // GetPString(IDS_CANTADDCOMMANDTEXT),
     771                     "Can't add %s to command list It has a duplicate title", temp.title);      // fixme to be in fm3dll.str
     772            }
     773            else {
     774              CHAR env[1002];
     775
     776              *env = 0;
     777              WinQueryDlgItemText(hwnd,CMD_ENVIRON,1000,env);
     778              bstripcr(env);
     779              if (*env) {
     780                PrfWriteProfileString(fmprof,
     781                                      FM3Str,
     782                                      temp.cl,
     783                                      env);
     784              }
     785              x = (SHORT)WinSendDlgItemMsg(hwnd,
     786                                           CMD_LISTBOX,
     787                                           LM_INSERTITEM,
     788                                           MPFROM2SHORT(LIT_END,0),
     789                                           MPFROMP(temp.title));
     790              if(x >= 0) {
     791                WinSendDlgItemMsg(hwnd,
     792                                  CMD_LISTBOX,
     793                                  LM_SETITEMHANDLE,
     794                                  MPFROMSHORT(x),
     795                                  MPFROMP(info));
     796                WinSendDlgItemMsg(hwnd,
     797                                  CMD_LISTBOX,
     798                                  LM_SELECTITEM,
     799                                  MPFROMSHORT(x),
     800                                  MPFROMSHORT(TRUE));
     801                save_commands();
     802              }
     803            }
     804          }
     805          break;
     806
     807        case CMD_DELETE:
     808          {
     809            CHAR temp[34];
     810
     811            WinQueryDlgItemText(hwnd,CMD_TITLE,34,temp);
     812            bstrip(temp);
     813            if (!kill_command(temp))
     814              Runtime_Error(pszSrcFile, __LINE__, "kill_command");
     815            else {
     816              x = (SHORT)WinSendDlgItemMsg(hwnd,
     817                                           CMD_LISTBOX,
     818                                           LM_QUERYSELECTION,
     819                                           MPFROMSHORT(LIT_FIRST),
     820                                           MPVOID);
     821              if(x >= 0) {
     822                WinSendDlgItemMsg(hwnd,
     823                                  CMD_LISTBOX,
     824                                  LM_DELETEITEM,
     825                                  MPFROMSHORT(x),
     826                                  MPVOID);
     827                WinSendDlgItemMsg(hwnd,
     828                                  CMD_LISTBOX,
     829                                  LM_SELECTITEM,
     830                                  MPFROMSHORT(LIT_NONE),
     831                                  MPFROMSHORT(FALSE));
     832              }
     833              save_commands();
     834            }
     835          }
     836          break;
     837        case CMD_REPLACE:
     838          {
     839            CHAR temp[34];
     840
     841            WinQueryDlgItemText(hwnd,CMD_TITLE,34,temp);
     842            bstrip(temp);
     843            if (!kill_command(temp))
     844              Runtime_Error(pszSrcFile, __LINE__, "kill_command");
     845            else {
     846              x = (SHORT)WinSendDlgItemMsg(hwnd,
     847                                           CMD_LISTBOX,
     848                                           LM_QUERYSELECTION,
     849                                           MPFROMSHORT(LIT_FIRST),
     850                                           MPVOID);
     851              if(x >= 0) {
     852                WinSendDlgItemMsg(hwnd,
     853                                  CMD_LISTBOX,
     854                                  LM_DELETEITEM,
     855                                  MPFROMSHORT(x),
     856                                  MPVOID);
     857                WinSendDlgItemMsg(hwnd,
     858                                  CMD_LISTBOX,
     859                                  LM_SELECTITEM,
     860                                  MPFROMSHORT(LIT_NONE),
     861                                  MPFROMSHORT(FALSE));
     862              }
     863              save_commands();
     864            }
     865          }
    663866          {
    664867            COMMAND temp;
     
    725928          }
    726929          break;
    727 
    728         case CMD_DELETE:
    729           {
    730             CHAR temp[34];
    731 
    732             WinQueryDlgItemText(hwnd,CMD_TITLE,34,temp);
    733             bstrip(temp);
    734             if (!kill_command(temp))
    735               Runtime_Error(pszSrcFile, __LINE__, "kill_command");
    736             else {
    737               x = (SHORT)WinSendDlgItemMsg(hwnd,
    738                                            CMD_LISTBOX,
    739                                            LM_QUERYSELECTION,
    740                                            MPFROMSHORT(LIT_FIRST),
    741                                            MPVOID);
    742               if(x >= 0) {
    743                 WinSendDlgItemMsg(hwnd,
    744                                   CMD_LISTBOX,
    745                                   LM_DELETEITEM,
    746                                   MPFROMSHORT(x),
    747                                   MPVOID);
    748                 WinSendDlgItemMsg(hwnd,
    749                                   CMD_LISTBOX,
    750                                   LM_SELECTITEM,
    751                                   MPFROMSHORT(LIT_NONE),
    752                                   MPFROMSHORT(FALSE));
    753               }
    754               save_commands();
    755             }
    756           }
    757           break;
    758930      }
    759931      return 0;
Note: See TracChangeset for help on using the changeset viewer.