From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Dimming of menu items of menubar generated by Right-Click event in LabWindows/CVI

Good morning,

I created a context (right-click) menu which is a menubar wih four options. In case the user rigth clicks in a row of a table control, all four options have to be able to be selected. Otherwise, in case the user rights click beyond (outside) a row of the table control, only two options have to be able to be selected (2 options have to be dimmed).

Piece of code i am using for creation of context menu:

ContextMenuBar = NewMenuBar (0);
ContextMenuID = NewMenu (ContextMenuBar, "ContextMenu", -1);

NewMenuItem (ContextMenuBar, ContextMenuID, "Connect", -1, 0, Connect_RightClickCallback, 0); //three more options are created here in the same way

I need to know how i can dimm/undimm or remove/insert those 2 options programmatically depending on the position the right click was done (i can detect the position of the mouse when EVENT_RIGHT_CLICK_UP is triggered to determine if it is over or outside a row of table control).

Regards!

Alejandro Pinto

 

0 Kudos
Message 1 of 3
(3,030 Views)

Dimming of menu entries can be done with 

SetMenuBarAttribute (contectMenuBar, ContextMenuID, ATTR_DIMMED, 1);

Unless you apply dimming immediately after creating the menu entry you will need to save entries handles (ContextMenuID) separately.

 

If your menu is constant (i.e. does not need to have entries created at runtime) you can design it in the UIR editor saving execution time and load it once at program start with

menuH = LoadMenuBar (0, UIR, menuBar);

(if 0 is passed to Destination panel handle parameter the menu is loaded in memory but is not associated to any panel, that is is ready to be used as a popup menu)

 

If on the contrary you need to build up the menu at runtime, why don't you simpy avoid creating unusable entries?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 3
(3,009 Views)

Thank you very much!

Now it is working.

Regards, 

 

Alejandro Pinto

0 Kudos
Message 3 of 3
(2,937 Views)