forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Visual Menu Editor

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code
View previous topic :: View next topic  
Author Message
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 14, 2003 9:55 pm    Post subject: Visual Menu Editor Reply with quote

A little utility I've comeup with for edit and creating menu descriptions.
Should work for VDS 3 as well.

Please read the comments for usage information. For step by step instructions,
please see the post directly after this one.

Code:


  TITLE SSMenu Editor
rem                                                                 
rem  THE FOLLOWING SCRIPT REQUIRES SSTREEVW.DLL                     
rem                                                                 

rem  This script is used to edit or create dialog menu descriptions.
rem
rem  To add a new menu, make sure the "Menu" checkbox is checked,
rem  uncheck the "Menu" checkbox for a menu item.
rem
rem  The menu's or menu item's text goes in the edit control under
rem  the "Menu" checkbox.
rem
rem  The second edit control is for the letter associated with the
rem  menu item's hot-key. (ex; "S" or "F1" or whatever). Limited to
rem  2 characters in this edit control. Then check the appropriate
rem  system key or keys associated with the hot-key. {ex; ALT or
rem  CTRL or SHIFT).
rem
rem  Then simply click the "Add" button to add the item or menu to
rem  the treeview control.
rem
rem  After you have finished designing you menus, select the
rem  "Generate Code" item from the Options menu and the dialog code
rem  will be generated and copied to the clipboard.
rem
rem  To edit a menu description, in the VDS IDE highlight and copy
rem  the menu code you wish to edit and then run SSMenu Editor. It
rem  will check the contents of the clipboard for "dialog add,menu".
rem  If it finds the "dialog add,menu" code, it will parse the menu
rem  descriptions and add the menus and menu items to the treeview
rem  control.

  external @path(%0)sstreevw.dll
 
  option fieldsep,"|"
  option decimalsep,"."
  option scale,96
  option errortrap,Error
 
  DIALOG CREATE,SSMenu Editor,-1,0,300,230,CLASS SSMENUEDIT
REM *** Modified by Dialog Designer on 3/10/03 - 03:58 ***
  dialog add,MENU,&File,E&xit|Alt+X
  dialog add,MENU,&Options,&Generate Code|F9
  treeview parent,#SSMENUEDIT
  treeview create,TVMenu,5,5,180,220,showSel|hasButtons|linesAtRoot|hasLines|border|trackSelect,CLICK
  treeview setBkColor,TVMenu,255|255|255
  dialog add,Group,Text,0,190,105,60,Menu Text
  dialog add,CHECK,ckMenu,15,200,50,15,Menu
  DIALOG ADD,EDIT,Ed1,30,200,90,20
  dialog add,Group,HotKey,70,200,80,90,Hot-key
  DIALOG ADD,EDIT,Ed2,85,205,70,20
  DIALOG ADD,CHECK,ckAlt,110,205,70,15,ALT
  DIALOG ADD,CHECK,ckCtrl,125,205,70,15,CTRL
  DIALOG ADD,CHECK,ckShift,140,205,70,15,SHIFT
  DIALOG ADD,BUTTON,Add,170,190,105,25,Add
  DIALOG ADD,BUTTON,Delete,200,190,105,25,Delete
  DIALOG ADD,LIST,L1,0,0,0,0
  dialog add,List,L2,0,0,0,0
  DIALOG SHOW
 
  %Z = @sendmsg(~Ed2,$0C5,2,0)
  dialog focus,Ed1
  list create,9
  list paste,9
  if @equal(@trim(@substr(@item(9,0),1,15),"dialog add,menu"))
    gosub ParseMenu
  end
  list close,9
 
:Evloop
  wait 0.1,event
  %E = @event()
  goto %E
 
:Timer
  if @zero(@treeview(getSelection,TVMenu))
    dialog disable,Delete
  else
    dialog enable,Delete
  end
  if @dlgtext(ckMenu)@equal(@dlgtext(Ed1),-)
    dialog disable,HotKey
  else
    dialog enable,HotKey
  end
  if @null(@dlgtext(Ed1))
    dialog disable,Add
  else
    dialog enable,Add
  end
  if @null(@dlgtext(Ed2))@equal(@len(@dlgtext(Ed2)),2)
    %%act = disable
  else
    %%act = enable
  end
  dialog %%act,ckAlt
  dialog %%act,ckCtrl
  dialog %%act,ckShift
  goto Evloop
 
:TVMenuCLICK
  %%txt = @treeview(itemText,TVMenu,@treeview(item,TVMenu))
  if @equal(%%txt,-)
    dialog set,Ed1,%%txt
  else
    parse "%%lbl;%%hotkey",%%txt
    dialog set,Ed1,%%lbl
    %P = @pos(+,%%hotkey)
    if %P
      repeat
        %P = @pos(+,%%hotkey)
        if @greater(%P,0)
          %%vk = @substr(%%hotkey,1,@pred(%P))
          %%key = @strdel(%%hotkey,1,-1)
          if @equal(%%vk,CTRL)
            dialog set,ckCtrl,1
          else
            dialog set,ckCtrl,
          end
          if @equal(%%vk,ALT)
            dialog set,ckAlt,1
          else
            dialog set,ckAlt,
          end
          if @equal(%%vk,SHIFT)
            dialog set,ckShift,1
          else
            dialog set,ckShift,
          end
          %%hotkey = @substr(%%hotkey,@succ(%P),@len(%%hotkey))
        end
      until @zero(%P)
      dialog set,Ed2,%%key
    else
      dialog set,Ed2,%%hotkey
    end
  end
  goto Evloop
 
:Generate CodeMENU
  if @null(@text(L1))
    goto Evloop
  end
  list seek,L1,0
  list create,1
  %x = 0
  %%mstr =
  repeat
    %%mstr =
    %I = @item(L1,%x)
    parse "%%pm;%%pid",%I
    %%mstr = %%pm@chr(44)
    list seek,L2,0
    %y = 0
    repeat
      list seek,L2,%y
      %J = @item(L2)
      parse "%%ci;%%hk;%%ppid",%J
      if @equal(%%pm,%%ppid)
        if @equal(%%ci,-)
          %%mstr = %%mstr%%ci@chr(44)
        else
          %%mstr = %%mstr%%ci|%%hk@chr(44)
        end
      end
      %y = @succ(%y)
    until @equal(%y,@count(L2))
    %x = @succ(%x)
    list add,1,DIALOG ADD@chr(44)MENU@chr(44)@substr(%%mstr,1,-1)
  until @equal(%x,@count(L1))
  clipboard set,@substr(@text(1),1,-2)
  if @ok()
    %Z = @msgbox("Menu description copied to clipboard.","SSMenu Editor",$000)
  else
    warn Code generation failed!
  end
  list close,1
  goto Evloop
 
:AddBUTTON
  %%text = @dlgtext(Ed1)
  %%hKey = @dlgtext(Ed2)
  if @dlgtext(ckMenu)
    %%pp = @treeview(add,TVMenu,%%text,,,1)
    treeview setbold,TVMenu,%%pp,1
    treeview select,TVMenu,%%pp
    list add,L1,%%text|%%pp
  else
    %%sel = @treeview(item,TVMenu)
    if @not(@zero(%%sel))
      if @equal(@treeview(getParent,TVMenu,%%sel),0)
        %%sKey =
        if @dlgtext(ckAlt)
          %%sKey = %%sKey"ALT+"
        end
        if @dlgtext(ckCtrl)
          %%sKey = %%sKey"CTRL+"
        end
        if @dlgtext(ckShift)
          %%sKey = %%sKey"SHIFT+"
        end
        if @dlgtext(Ed2)
          %%sKey = |%%sKey%%hKey
        end
        %%pc = @treeview(addChild,TVMenu,%%sel,%%text%%sKey,,,0)
        if @equal(@treeview(isExpanded,TVMenu,%%sel),0)
          treeview expand,TVMenu,%%sel
        end
        if @equal(@dlgtext(Ed1),-)
          %%text = %%text|
        end
        list add,L2,%%text%%sKey|@treeview(itemText,TVMenu,%%sel)
        dialog set,Ed2,
        dialog set,ckAlt,
        dialog set,ckCtrl,
        dialog set,ckShift,
        dialog focus,Ed1
      end
    end
  end
  goto Evloop
 
:DeleteBUTTON
  %M = @match(L1,@treeview(item,TVMenu))
  if %M
    %%pm = @treeview(itemText,TVMenu,@treeview(item,TVMenu))
    treeview delete,TVMenu,@treeview(item,TVMenu)
    list delete,L1
    list seek,L2,0
    repeat
      %M = @match(L2,%%pm)
      if %M
        list delete,L2
      end
    until @not(%M)
  else
    %M = @match(L2,@treeview(item,TVMenu))
    if %M
      treeview delete,TVMenu,@treeview(item,TVMenu)
      list delete,L2
    end
  end
  goto Evloop
 
:ExitMENU
:CLOSE
  treeview remove,TVMenu
  exit
 
:ParseMENU
  list create,1
  list create,2
  list clear,L1
  list clear,L2
  list assign,1,9
  %x = 0
  repeat
    %I = @item(1,%x)
    %P = @pos("dialog add,menu,",%I)
    %%mI = @substr(%I,@sum(%P,16),@len(%I))
    repeat
      %P = @pos(",",%%mI)
      if @greater(%P,0)
        %%mI = @strdel(%%mI,%P)
        %%mI = @strins(%%mI,%P,@cr())
      end
    until @zero(%P)
    list assign,2,%%mI
    %%pt = @trim(@item(2,0))
    %%parent = @treeview(add,TVMenu,%%pt,,,1)
    list add,L1,@trim(@item(2,0))|%%parent
    treeview setBold,TVMenu,%%parent,1
    %g = 1
    repeat
      if @not(@null(@item(2,%g)))
        %%child = @treeview(addChild,TVMenu,%%parent,@item(2,%g),,,0)
        list add,L2,@item(2,%g)|%%pt|%%child
      end
      %g = @succ(%g)
    until @greater(%g,@count(2))
    %x = @succ(%x)
  until @equal(%x,@count(1))
  list close,1
  list close,2
  exit

:Error
  option fieldsep,","
  list create,9
  list loadtext,9
"
"1,Invalid Command,An invalid command has been encountered.
"2,Missing parameter(s),The command executed expects more parameters than the number given.
"3,Style already defined,An OPTION STYLE command defining this style has already been defined.
"4,Invalid list operation,The string list or listbox control referenced does not exist.
"5,Invalid variable name,Valid variable names are %1 ... %9 and %A ... %Z and %%(alphanumerics - numerics)
"6,= symbol expected,A command started with a variable but no equals symbol was found.
"7,Invalid @ function,An invalid function has been encountered.
"8,Syntax error in @ function,Something is wrong with a function call.
"9,Missing END or ELSE,An IF or ELSE command has been executed but the corresponding ELSE or END is missing.
"10,Command nested too deeply,REPEAT or GOSUB commands have been nested more than 9 deep.
"11,Missing argument(s) to @ function,The function executed expects more parameters than the number given.
"12,Label not found,The label named in a GOTO or GOSUB command does not exist.
"13,Invalid argument to @ function,One of the parameters to a function is not valid.
"14,Invalid parameter to command,One of the parameters to a command is not valid.
"15,UNTIL without REPEAT,An UNTIL command was encountered but no previous REPEAT command can be found.
"16,Invalid Style,A style parameter of a dialog element does not exist.
"17,Dialog already defined,A dialog cannot recreate itself while it is still showing.
"18,Control already defined,The control referenced in the DIALOG or LIST command or @DLGTEXT function does not exist.
"19,List index out of range,The item number in a list index operation is less than zero or greater than the number of items in the list.
"20,File does not exist,The icon or bitmap file referenced in a dialog element cannot be found.
"21,Cannot create control,Cannot create the control specified in a DIALOG CREATE command.
"22,Operation invalid with no dialog showing,Function or command can only be used when a dialog is being displayed.
"23,Control name not valid,The name specified for a control contains an invalid character.
"24,Mismatched brackets,The parser has reached the end of a line and a closing bracket is expected.
"25,Non-numeric value in arithmetic function,An invalid character appears in a string being treated as a numeric value.
"26,Arithmetic error,
"27,Untrapped error in an external command or function
"28,External library not available,Either the DLL specified in an EXTERNAL command could not be located on the search path or a condition for its use was not met.
"29,Insufficient memory,
"30,Breakpoint reached,
"31,Stopped by user,
 
  list seek,9,@error(E)
  %I = @item(9)
  parse "%%num;%%err;%%msg",%I
 
  dialog create,Error,-1,0,300,150,COLOR #FF0000,NOSYS
  dialog add,Style,StErrNum,,9,B,#FF0000,#00FFFF
  dialog add,Style,StErr,,9,B,#FF0000,#00FF00
  dialog add,Style,StMsg,,9,,#FF0000,#FFFFFF
  dialog add,Text,Text1,10,10,290,15,Error: %%num Line: @error(N),,StErrNum
  dialog add,Text,Text2,30,10,290,20,%%err,,StErr
  dialog add,Text,Text3,50,10,290,60,%%msg,,StMsg
  dialog add,BUTTON,ErrOk,115,115,70,30,Ok
  dialog showModal

  list close,9
  exit
 



Enjoy! Smile Wink

_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."


Last edited by ShinobiSoft on Sat Mar 15, 2003 12:04 am; edited 2 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
ShinobiSoft
Professional Member
Professional Member


Joined: 06 Nov 2002
Posts: 790
Location: Knoxville, Tn

PostPosted: Fri Mar 14, 2003 10:48 pm    Post subject: SSMenu Editor - How To Reply with quote

Code:

*** Using SSMenu Editor ***

To add a menu:
 1) Check the "Menu" checkbox
 2) Enter the menu's text in the edit control below the "Menu"
    checkbox
 3) Click the "Add" button

To add a menu item:
 1) Uncheck the "Menu" checkbox
 2) Enter the menu item's text in the edit control below the
    "Menu" checkbox
 3) If you want a hot-key, enter the hot-key letter in the edit
    control in the "Hot-Key" group element
 4) Select the appropriate control keys. You can select all 3
    control keys if you'd like
 5) Click the "Add" button

  All menu items are appended to the highlighted menu in the treeview
control. SSMenu Editor does not support defining sub-menus at this
time.

  To delete an item or menu, select it in the treeview control and then
press the "Delete" button. If you delete a menu all the menu items are
deleted as well.


_________________
Bill Weckel
ShinobiSoft Software

"The way is known to all, but not all know it."
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 4 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group