07-01-2010 04:33 PM
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.
07-01-2010 04:54 PM
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).
07-01-2010 04:57 PM
This is by the way the menu I created...
07-01-2010 05:29 PM - edited 07-01-2010 05:32 PM
Er... Bebeto... Where is the menubar in your UIR? You are using a menu ring control!!!
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
07-06-2010 10:35 AM
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.
07-06-2010 03:43 PM
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.
07-15-2010 07:13 PM
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
07-15-2010 11:22 PM
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.
10-02-2013 02:36 PM
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
10-02-2013 11:58 PM
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.