LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Right-click on tab, how do I know which tab ?

Hello all,

I want to show a contextual menu upon right click on a tab out of a tab control.

Showing the menu is done via RunPopupMenu() at the position eventData1, eventData2, this much works fine.

The problem is that I need to know which tab has been right-clicked on, even if it is not the active tab.

How can I accomplish this ? Is there some way to convert X/Y coords into a tab index ? Or something simpler maybe ?

Thanks

0 Kudos
Message 1 of 4
(193 Views)

Oh, I found the answer shortly after posting: just use GetTabPageFromPoint()

 

But this brings me to another related question: how do you use a context menu with RunPopupMenu() WITHOUT a menubar on your panel ? It seems that the menu you want to display must be part of a menubar which must be loaded (and displayed) in a panel.

The only way around that I could find was to load the menubar in an empty and hidden panel.

 

Is there a better way ?

0 Kudos
Message 2 of 4
(157 Views)

@gdargaud  ha scritto:

... the menu you want to display must be part of a menubar which must be loaded (and displayed) in a panel...

Actually you do not need to display the menubar, you even do not need to associate it to a panel.

You can pass 0 as panel handle to LoadMenubar () and the menu bar will only reside in memory. The menu bar handle is then to be passed to RunPopupMenu () together with the ID of the menu you want to display.



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 3 of 4
(143 Views)

Thanks, yeah I saw that in the uirview.prj example. I didn't know you could have an unattached menubar.

 

It mostly works now, except that often the right click stops working after the popup menu closes. I have to left-click anywhere for it to start working again. That weird. I even tried to see what's going on with a amin callback and no events are generated. It's easy for the user to work around, but still annoying.

0 Kudos
Message 4 of 4
(131 Views)