LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

inserting submenu items via code - not the graphical *.uir file editor (not by the edit >> Menu Bars... method!)

Solved!
Go to solution
How are submenu items constructed via code and not the edit menu bar setup in the *.uir editor?  NemMenuItem(...) doesn't do this, or I am not plugging in parameters correctly, which I doubt the case is.  BTW, there is no explanation in the CVI v.8.0.1 help menu items about NewSubMenu(...) and how to use the subMenuHandler for any other functions.  At least whatever I found had nothing to do with submenu items.  Is this impossible to do via programming? 
0 Kudos
Message 1 of 6
(3,616 Views)

Hi,

 

you can accomplish this using the command

 

sub_menu_id = NewSubMenu ( menu_bar_handle, menu_item_id );

 

Prior to this, you have to create a menu using NewMenuItem (); then you would call NewSubMenu (), which only creates a submenu without any entries; these you can create subsequently using NewMenuItem on the sub_menu_id...

 

Good luck,

 

Wolfgang
   

0 Kudos
Message 2 of 6
(3,605 Views)

Actually you need to call both functions.

 

NewMenuItem just creates a "place holder" at a given location for your menu item. You specify the location using the MenuID and BeforeMenuItemID parameters.

This function will return a menu item ID. 

Then you will use this ID when calling NewSubMenu.

 

If you want to do it in code completely, you should start with NewMenuBar and NewMenu.

If you already have a menu bar from the editor, you can skip this part.

 

Hope this helps. 

Message Edited by ebalci on 06-13-2009 01:57 PM
S. Eren BALCI
IMESTEK
0 Kudos
Message 3 of 6
(3,603 Views)

I don't believe that I explained this correctly.  I can make submenus, but when I try to populate items in the submenu using NemMenuItem, I can't do this successfully.  I've tried doing all of these suggestions, and to no avail, this stuff doesn't work.  Put down some example source code for the folowing example if it's so easy. 

 

menu

-submenu

--submenuitem

 

How is this constructed via source?

0 Kudos
Message 4 of 6
(3,600 Views)
Solution
Accepted by topic author Chrisg101080

Hi Chris,

 

 

You can paste the code below directly to interactive execution window and run.

The outcome is in the attachment.

 

 

#include <userint.h>

 
static int pnl,mbar,menu;
static int mitem, subm, submitem;

pnl = NewPanel (0, "", 250, 250, 250, 250);
mbar = NewMenuBar (pnl);
menu = NewMenu (mbar, "menu", -1);

mitem = NewMenuItem (mbar, menu, "submenu", -1, 0, 0, 0); 
subm = NewSubMenu (mbar, mitem);
submitem = NewMenuItem (mbar, subm, "submenuitem", -1, 0, 0, 0); 

DisplayPanel (pnl);
RunUserInterface ();

 

 

I hope this is what you have been asking.

 

Have a nice weekend 

Message Edited by ebalci on 06-13-2009 08:12 PM
S. Eren BALCI
IMESTEK
Message 5 of 6
(3,593 Views)

You are the man!  Exactly what I needed.  I was using the wrong value for the second argument of the NewMenuItem(...) function.  Instead of using the handler, I was using the constant that is generated in the *.uir header file.  Regardless, I recommend that these types of explanations be put into the help files within the CVI environment.  There is very little explanation of how to develop submenu items.  Nonetheless, I appreciate all of your support via these forums.  NI is very instructive and helpful.  I recommend this forum to all NI users.  Thank you. 

 

Chris

0 Kudos
Message 6 of 6
(3,557 Views)