WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Menu Sample

 Keywords:  MENUITEM MENUIBAR MENU DIALOG DROPDOWN CONTEXT



#DefineFunction MyDialogCallbackProc(MyDialog_Handle,MyDialog_Message,MyDialog_Name,MyDialog_EventInfo,rsvd)
   MSG_INIT = 0
   MSG_BUTTONPUSHED=2        ; Pushbutton or Picturebutton
   MSG_MENUITEM=15           ; MenuItem selected
   RET_DO_CANCEL=0           ; Cancels dialog
   RET_DO_DEFAULT= -1        ; Continue with default processing for control
   RET_DO_NOT_EXIT= -2       ; Do not exit the dialog

   ON_EQUAL = @TRUE                                         ; Initialize variable ON_EQUAL
   Switch MyDialog_Message                                  ; Switch based on Dialog Message type
      Case MSG_INIT                                         ; Standard Initialization message
         DialogProcOptions(MyDialog_Handle,MSG_BUTTONPUSHED,@TRUE)
         DialogProcOptions(MyDialog_Handle,MSG_MENUITEM,@TRUE)
         Return(RET_DO_DEFAULT)

     Case MSG_BUTTONPUSHED
        Switch ON_EQUAL
           Case MyDialog_Name == "PushButton_RightClickMe"           ; Right Click Me!
              Pause('Notice','You Left-Clicked the button')
              Return(RET_DO_NOT_EXIT)

           Case MyDialog_Name == "PushButton_Cancel"       ; Cancel
              Pause('Notice','You pressed Cancel')
              Return(RET_DO_CANCEL)

        EndSwitch                                          ; MyDialog_Name
        Return(RET_DO_DEFAULT)

     Case MSG_MENUITEM
        Switch ON_EQUAL
           Case MyDialog_Name == "cmi1_PushButton_RightClickMe"      ; PushButton_RightClickMe Context Menu One
              Pause('You Selected:','Context Menu One')
              Return(RET_DO_NOT_EXIT)

           Case MyDialog_Name == "cmi3_PushButton_RightClickMe"      ; cmi1_PushButton_RightClickMe Subcontext Menu One
              Pause('You Selected:','Subcontext Menu One')
              Return(RET_DO_NOT_EXIT)

           Case MyDialog_Name == "cmi2_PushButton_RightClickMe"      ; PushButton_RightClickMe Context menu Two
              Pause('You Selected:','Context menu Two')
              Return(RET_DO_NOT_EXIT)

           Case MyDialog_Name == "mbi1_MyDialog"           ; Dialog_Bar Menu Item One
              ;NOTICE : The user-defined callback is not called in response to the mouse selection of menu
              ;item that have an associated dropdown menus or submenus. The associated dropdown or submenu
              ;is displayed instead. Hot-keys should not be used with menu items that display a dropdown
              ;or submenu.
              Return(RET_DO_NOT_EXIT)

           Case MyDialog_Name == "mbi2_MyDialog"           ; mbi1_MyDialog SubMenu Item One
              Pause('You Selected:','SubMenu Item One')
              Return(RET_DO_NOT_EXIT)

           Case MyDialog_Name == "mbi3_MyDialog"           ; Dialog_Bar Menu Item Two
              Pause('You Selected:','Menu Item Two')
              Return(RET_DO_NOT_EXIT)

        EndSwitch                                          ; MyDialog_Name
        Return(RET_DO_DEFAULT)

   EndSwitch                                                ; MyDialog_Message
   Return(RET_DO_DEFAULT)
#EndFunction                                                ; End of Dialog Callback MyDialogCallbackProc


;MENUITEMs can be displayed on a menu bar or as a menu item associated with a drop-down, context menu or submenu.
;
;Dropdown menus are created by placing the name of a MENUITEM displayed in the menu bar in the parent attribute
;of the menu item's template entry.  A submenu is started by placing the name of a MENUITEM other than a menu bar
;displayed menu item in the parent attribute.
;
;Context menus are usually activated by right-clicking the client area of a control or dialog.  Create context
;menus by specifying the name of a control in the parent attribute.  If you use the DEFAULT keyword as the
;MENUITEM parent, the context menu will by associated with the dialog and display when the user right clicks on
;an 'empty' area of the dialog or on any control that does not already have a system or template supplied context
;menu.



MyDialogFormat=`WWWDLGED,6.2`

MyDialogCaption=`Menu Sample`
MyDialogX=241
MyDialogY=080
MyDialogWidth=242
MyDialogHeight=117
MyDialogNumControls=009
MyDialogProcedure=`MyDialogCallbackProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`073,047,078,012,PUSHBUTTON,"PushButton_RightClickMe",DEFAULT,"Right Click Me!",1,10,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`093,093,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`000,000,000,000,MENUITEM,"cmi1_PushButton_RightClickMe","PushButton_RightClickMe","Context Menu One",DEFAULT,10,DEFAULT`
MyDialog004=`000,000,000,000,MENUITEM,"cmi3_PushButton_RightClickMe","cmi1_PushButton_RightClickMe","Subcontext Menu One",DEFAULT,10,DEFAULT`
MyDialog005=`000,000,000,000,MENUITEM,"cmi2_PushButton_RightClickMe","PushButton_RightClickMe","Context menu Two",DEFAULT,20,DEFAULT`
MyDialog006=`000,000,000,000,MENUBAR,"Dialog_Bar"`
MyDialog007=`000,000,000,000,MENUITEM,"mbi1_MyDialog","Dialog_Bar","Menu Item One",DEFAULT,10,DEFAULT`
MyDialog008=`000,000,000,000,MENUITEM,"mbi2_MyDialog","mbi1_MyDialog","SubMenu Item One",DEFAULT,10,DEFAULT`
MyDialog009=`000,000,000,000,MENUITEM,"mbi3_MyDialog","Dialog_Bar","Menu Item Two",DEFAULT,20,DEFAULT`

ButtonPushed=Dialog("MyDialog")

Article ID:   W17749
Filename:   Menu Sample.txt
File Created: 2009:11:16:13:08:04
Last Updated: 2009:11:16:13:08:04