call a MENUITEM "from Function" ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: call a MENUITEM "from Function" ?

Post 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
User avatar
AUGE_OHR
Posts: 2060
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: call a MENUITEM "from Function" ?

Post 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
have fun
Jimmy
Post Reply