Page 2 of 2

Re: call a MENUITEM "from Function" ?

Posted: Wed Jun 09, 2021 7:52 am
by edk
AUGE_OHR wrote: Sun Jun 06, 2021 1:21 am hi,

i do have a CONTEXT MENU and 3 MENUITEM with ACTION
is it possible to activate MENUITEM from a Function :idea:

Code: Select all

   // i want to activate 2nd MENUITEM
   DoMethod("Form_1", "MYMENU", 2, "ACTION" )
Hi, try:

Code: Select all

Eval ( _GetControlAction ( <cMenuItemName> , <cParentWindowName> ) )
I guess this should work for all controls that have an event "Action" / "On Click" and a property "Name".

Sample:

Code: Select all

#include "hmg.ch"

Function Main

DEFINE WINDOW fmain AT 157 , 162 WIDTH 550 HEIGHT 350 TITLE "Hello World!!!!!" MAIN NOMAXIMIZE NOMINIMIZE

    DEFINE MAIN MENU
        DEFINE POPUP "File"
            MENUITEM "Open" ACTION MsgInfo("Open") IMAGE "info.bmp"
            MENUITEM "Save" ACTION MsgInfo("Save") IMAGE "free.bmp"
            SEPARATOR
            MENUITEM "Exit" ACTION ThisWIndow.Release IMAGE "exit.bmp"
        END POPUP
        DEFINE POPUP "Help"
            MENUITEM "About" ACTION MsgInfo("HMG IDE - Menu Designer", "MenuItem 'About'") NAME AboutMenu
        END POPUP
    END MENU

   @ 20,20 BUTTON CallAction CAPTION 'Call Action of MenuItem "About"' WIDTH 200 HEIGHT 30 ACTION Eval ( _GetControlAction ( 'AboutMenu' , 'fmain' ) )


END WINDOW

Center Window fmain
Activate Window fmain

Re: call a MENUITEM "from Function" ?

Posted: Fri Jun 18, 2021 9:51 pm
by AUGE_OHR
hi,
edk wrote: Wed Jun 09, 2021 7:52 am

Code: Select all

Eval ( _GetControlAction ( <cMenuItemName> , <cParentWindowName> ) )
I guess this should work for all controls that have an event "Action" / "On Click" and a property "Name".
sorry had no test your Demo until now. WOW