Enable/ disable Menu item

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 154
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 41 times
Been thanked: 7 times

Enable/ disable Menu item

Post by bluebird » Fri Feb 16, 2018 4:24 pm

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: 304
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 81 times
Been thanked: 233 times

Post by edk » Fri Feb 16, 2018 5:51 pm

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: 30
Joined: Tue Dec 20, 2016 1:39 pm
DBs Used: DBF
Location: Bulgaria, Sofia
Has thanked: 32 times
Been thanked: 4 times
Contact:

Post by Marin » Fri Feb 16, 2018 5:59 pm

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: 154
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF
Has thanked: 41 times
Been thanked: 7 times

Post by bluebird » Sat Feb 17, 2018 2:57 pm

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: 2045
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 404 times
Been thanked: 89 times
Contact:

Post by serge_girard » Sat Feb 17, 2018 10:47 pm

Good idea!

Serge

Post Reply