Enable/ disable Menu item

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Enable/ disable Menu item

Post by bluebird »

Dear Viewers

I would like to know if there is a way to enable/ disable a menu item- example below at 3.4.4 release level. I did notice a members
question from several years back but I don't understand if or how it was resolved.

If you want the MenuIems to be allowed only if a condition exists - for example if the 1st item is complete then allow the 2nd item
but not before, then can you disable (grey out) until your code enables the menu items?

At this time I can create logical variable and place if - then - else statements in the Action codeblocks but this looks amateurish to me. The user does not see if the menuitem is allowed ahead of time

DEFINE MAIN MENU
DEFINE POPUP 'File'
MENUITEM 'Quit 1' ACTION Win_1.Release
MENUITEM 'Reset ' ACTION ImageReset()
END POPUP

DEFINE POPUP 'Procedures'
MENUITEM 'Select Images (<=25)' ACTION SelectImages()
MENUITEM 'Display Images' ACTION BuildScreenComp()
MENUITEM 'Build The Image Composite)' ACTION BuildOutputComposite()
MENUITEM 'Save The Composite to Disk' ACTION SaveComposite()
END POPUP

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

Re: Enable/ disable Menu item

Post by edk »

Try:

Code: Select all


DEFINE MAIN MENU
DEFINE POPUP 'File'
MENUITEM 'Quit 1' ACTION Win_1.Release
MENUITEM 'Reset '	ACTION ImageReset() 
END POPUP

DEFINE POPUP 'Procedures'
MENUITEM 'Select Images (<=25)' ACTION SelectImages() NAME pSelIma
MENUITEM 'Display Images' ACTION BuildScreenComp() NAME pDispIma
MENUITEM 'Build The Image Composite)' ACTION BuildOutputComposite() NAME pBuildIma
MENUITEM 'Save The Composite to Disk' ACTION SaveComposite() NAME pSave
END POPUP

END MENU

<formName>.pSelIma.Enabled := .F.

not tested 😉
Marin
Posts: 33
Joined: Tue Dec 20, 2016 1:39 pm
DBs Used: DBF
Location: Bulgaria, Sofia
Contact:

Re: Enable/ disable Menu item

Post by Marin »

Dear bluebird,

Please consider the following PRG-fragment - it is just an idea.
Remember the naming clause at the end of the ITEM statement.

DEFINE MAIN MENU OF Win_1
POPUP '1. Input data'
POPUP '1.1. Dentists'
ITEM '√ 1.1.1. Dentists - input' ACTION GetKabineti() NAME MENU111
SEPARATOR
ITEM '√ 1.1.2. Dentists - edit' ACTION GetDoplKabineti() NAME MENU112
END POPUP
......


// Locking both submenus according to you condition could be made as follows (not tested!):
Win_1.MENU111.Enabled := .F.
Win_1.MENU112.Enabled := .F.

Regards,
Marin
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

Re: Enable/ disable Menu item

Post by bluebird »

Thanks to both members who responded. I really think this enable/ disable technique should explained clearly in the HMG Ref doc
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Enable/ disable Menu item

Post by serge_girard »

Good idea!

Serge
There's nothing you can do that can't be done...
Post Reply