New function; GetMenuItemText()

Share your advanced PureBasic knowledge/code with the community.
dom
New User
New User
Posts: 3
Joined: Tue Dec 21, 2004 5:26 pm
Location: Brazil - Parana

New function; GetMenuItemText()

Post by dom »

Code updated For 5.20+

hi...
sorry my english...


they try is code...

Code: Select all

; ;/////////////////////////////////////////////////////////
; Procedure.s GetMenuItemText(menu,item)
;   b$=Space(127)
;   a=GetMenuString_(menu,item,@b$,127,#MF_BYCOMMAND)
;   ProcedureReturn Mid(b$,1,a)
; EndProcedure
;.:: dom2580456@yahoo.com.br               Wenceslau Braz - Parana - Brazil...

;/////////////////////////////////////////////////////////




;
; ------------------------------------------------------------
;
;   PureBasic - Menu example file
;
;    (c) 2003 - Fantaisie Software
;
; ------------------------------------------------------------
;

;
; We just have to open a window and see when an event happen on the menu
;

If OpenWindow(0, 100, 150, 195, 260, "PureBasic - Menu", #PB_Window_SystemMenu)
  
  ;
  ; Create the menu. The indent is very important here for a good lisibility
  ;
  hwmenu=CreateMenu(0, WindowID(0))
  If hwmenu
    MenuTitle("File")
    MenuItem( 1, "&Load...")
    MenuItem( 2, "Save")
    MenuItem( 3, "Save As...")
    MenuBar()
    OpenSubMenu("Recents")
    MenuItem( 5, "C:\Autoexec.bat")
    MenuItem( 6, "D:\Test.txt")
    OpenSubMenu("Even more !")
    MenuItem( 12, "Test")
    CloseSubMenu()
    MenuItem( 13, "C:\Ok.bat")
    CloseSubMenu()
    MenuBar()
    MenuItem( 7, "&Quit")
    
    MenuTitle("Edition")
    MenuItem( 8, "Cut")
    MenuItem( 9, "Copy")
    MenuItem(10, "Paste")
    
    MenuTitle("?")
    MenuItem(11, "About")
    MenuItem(12, "dom2580456@yahoo.com.br")
    
    
  EndIf
  
  DisableMenuItem(0,3,1)
  DisableMenuItem(0,13, 1)
  
  ;
  ; This is the 'event loop'. All the user actions are processed here.
  ; It's very easy to understand: when an action occurs, the EventID
  ; isn't 0 and we just have to see what have happened...
  ;
  
  Repeat
    
    Select WaitWindowEvent()
        
      Case #PB_Event_Menu
        item=EventMenu()
        Select item  ; To see which menu has been selected
            
          Case 11 ; About
            MessageRequester("About", "Cool Menu example", 0)
          Case 12
            MessageRequester("Info", "God bless Purebasic", 0) 
          Default
            
            MessageRequester("Info", "MenuItem: "+Str(item)+Chr(13)+Chr(13)+"Name item: "+GetMenuItemText(hwmenu,item), 0)
            
        EndSelect
        
      Case #WM_CLOSE ; #PB_Event_CloseWindow
        Quit = 1
        
    EndSelect
    
  Until Quit = 1
  
EndIf



Heis Spiter
User
User
Posts: 41
Joined: Fri Aug 22, 2003 7:10 pm
Location: 76 (FRANCE)
Contact:

Post by Heis Spiter »

You can also do that

Code: Select all

Procedure SetMenuItemText(HMenu.l, Item.l, String.s)

  ModifyMenu_(HMenu, Item, #MF_STRING, Item, String)
  
EndProcedure
;)
Post Reply