LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

menu on right-click for numeric control

Thanks Wolfgang,

 

Roberto,

 

This code already has the EVENT_LEFT_CLICK to be used to configure the settings of up to 16 items, what I am trying to implement is to copy from item to another the configuration using EVENT_RIGHT_CLICK to do this.

Please look at the attachment for a clearer view, thanks.

LabVIEW Intermediate I level!
0 Kudos
Message 11 of 21
(2,095 Views)

It seems to me that you should get rid of NewMenuItem call, define menuHandle integer variable and apply the correct menu ID in RunPopupMenu taking it from the menubar designed in the UIR editor (also the break in EVENT_RIGHT_CLICK is unnecessary).

I say that considering that you have actually designed your menu bar in the UIR editor, otherwise you will need to programmatically design it from scratch using some different calls: a task which is not trivial. In the first place I strongly suggest you to run the UIR editor way!

 

Next you need to trap the return code from RunPopupMenu and check wether it returns an error or an actual choice (now it should return a negative User Interface error code).



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?
0 Kudos
Message 12 of 21
(2,089 Views)

This is by the way the menu I created...

LabVIEW Intermediate I level!
0 Kudos
Message 13 of 21
(2,086 Views)

Er... Bebeto... Smiley Surprised Where is the menubar in your UIR? You are using a menu ring control!!! Smiley SurprisedSmiley Surprised

 

I modified it and created a small project for you to see what I was intending with 'menubar'.

To examine menu design open the UIR in the editor and choose "Edit >> Menu bars..." menu item



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 14 of 21
(2,076 Views)

Hello Roberto,

 

Thanks for the help, I was using the menu ring control as my intention is that when I RIGHT CLICK on the legacy Software the "copy from LS" window comes up and just click on the list to select the LS desired. And since this was the only control that I found with the appearance needed I went with it.

 

Is it possible to use the menu ring control for this purpose or not? thanks again in advance.

LabVIEW Intermediate I level!
0 Kudos
Message 15 of 21
(2,034 Views)

No, you can't use that control for your purpose: keep on the menubar instead. You can customize it in several ways, hiding or dimming items, adding separators... You can also dim menu items depending on some program state, as described in this tip.

 



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 16 of 21
(2,023 Views)

Hello Roberto,

 

I was able to do it, thanks, now I want to actually copy the value from the menu that appears when doing the RIGHT_CLICK.

 

should I do a SetCtrlVal or GetCtrlVal ?

 

Thanks in advance

LabVIEW Intermediate I level!
0 Kudos
Message 17 of 21
(1,958 Views)

If you want to get the value of the numeric control during menu callback yes, you can use GetCtrlVal, the same as you would do in any other situation. Since RunPopupMenu is called within the control callback, 'panel' and 'control' parameters in the callback identify the control itself.



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 18 of 21
(1,949 Views)

Hi Roberto

I've loade the menu and get a valid value in 'PopUpMenuHandle'

PopUpMenuHandle=LoadMenuBar(0,"MyUIR.uir",POPUPMENU);

 

I've checked the .h file associated to 'MyUIR.uir' and this what I find there :

#define  POPUPMENU                               1
#define  POPUPMENU_TEST1                  2       /* callback function: PopUpMenuCB */
#define  POPUPMENU_TEST2                  3       /* callback function: PopUpMenuCB */

 

When I later try to run the menu by 

RunPopupMenu(PopUpMenuHandle,POPUPMENU,0,30,60,0,0,0,0);

 

I get a run time error -40 The id passed was not a valid menu id.

If I pass the panelhandle where I invoke RunPopupMenu() the result is the same 

 

0 Kudos
Message 19 of 21
(1,553 Views)

Hello fluidtronic,

you must correctly understand the structure of menus in CVI, which is organized in a three-level manner:

 

The menubar

  +- The menus ("File", "Edit", ... "Help")

      +- Items in menus (e.g. in FIle menu: "New, "Open", "Print"...)

 

As the name says, LoadMenuBar loads a menu bar and gets the associated handle, while RunPopupMenu issues a menu.

In your case, POPUPMENU is the menubar name, and you correctly pass it to LoadMenuBar without getting errors. You cannot pass the same name as the menu in RunPopupMenu!

You must reorganize your menu adding an intermediate level (the "menu") which holds your TEST1 and TEST2 as child items.



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?
0 Kudos
Message 20 of 21
(1,545 Views)