LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

When I load a new instance of a panel with a menu bar defined on it, the new menu bar and the old menu bar have the same ID.

I have a panel which I wish to reuse a bunch of times.  It has a menu bar on it.  When I seperately load, display, and operate more than one instance of this panel the menu bars are linked.  How should I make a panel with a menu in it which can be reused but the menus are all separated?
 
Thanks,
DS
 
 
 
0 Kudos
Message 1 of 4
(3,065 Views)
Well, actually the menus have the same IDs, but their functions receive panel handle as the last parameter so that you can differentiate various instances of the menus from this value.


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 2 of 4
(3,058 Views)
Thanks! I see the panel information is there but I do not know how to use it properly. 
The code below makes only one item checked on a menu (you pick one item and it is checked and any others are cleared).
Do you have any suggestions how I might do that to only the menu that was picked and not the other menu on the other panel?
 
void CVICALLBACK select_deselect_exclusive (int menuBar, int menuItem, void *callbackData,int panel)
{
int is_checked;
  GetMenuBarAttribute (menuBar, menuItem, ATTR_CHECKED, &is_checked);
  if(!is_checked)
    {
    int menu_id = 1;
    find_menu(menuBar,menuItem,&menu_id);
    while(menu_id !=0)
      {
        SetMenuBarAttribute (menuBar, menu_id, ATTR_CHECKED, 0);
        GetMenuBarAttribute (menuBar, menu_id, ATTR_NEXT_ITEM_ID, &menu_id);
      }
    SetMenuBarAttribute (menuBar, menuItem, ATTR_CHECKED, 1);
    }
}
 
 
0 Kudos
Message 3 of 4
(3,050 Views)
ok i figured this out.
thanks for your help!
 
to make multiple instances of the same menu work you need to NOT associate the menu in the *.uir file and load it explicitly when you load the panel.
 
you can load lots of menus this way and they do not check / uncheck each other with the previous code i had
 
  if ((graph_report = LoadPanelEx (report, "ui_graph.uir",GRAPHPANEL,__CVIUserHInst)) < 0) return -1;
  if ((graph_report_menu = LoadMenuBarEx (graph_report, "ui_graph.uir", GRAPH, __CVIUserHInst)) < 0) return -1;
  SetPanelMenuBar (graph_report, graph_report_menu);
 
 
0 Kudos
Message 4 of 4
(3,046 Views)