From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

GetActivePanel seems to behave differently for ConfirmPopup / MessagePopup and FileSelectPopupEx

Solved!
Go to solution

Hello,

 

I have a GUI with a XY graph and in order to switch the mouse cursor style (default versus cross hair) and indicate the graph coordinates I am using a timer control where the callback checks the graph coordinates.

Since it may happen that a popup panel is displayed, I am also checking that the active panel is the current panel so to avoid having a cross hair mouse cursor over the popup panel.

 

So the code is like follows:

 

int CVICALLBACK MouseCursorTimer ( int panel, int control, int event, void *callbackData, int eventData1, int eventData2 )

{

    if ( ( event == EVENT_TIMER_TICK ) && ( UtilityGetActivePanel () == panel ) )

    {

        // get graph coordinates using GetRelativeMouseState () and GetGraphCoordsFromPoint ()

....

 

As expected, the cursor switches style according to mouse position. If I display a panel using InstallPopup () (which appears on top of my graph), the cursor will switch back to the default style if moved over the popup panel. So far so good and I was happy - until I discovered that other popup panels may behave differently...

If I call ConfirmPopup or MessagePopup the mouse cursor style does not change, i.e., it is displayed as a cross hair although the mouse is moved over the popup panel.

Interestingly, FilePopupEx () behaves correctly. Somehow it seems that the panel handle returned from GetActivePanel () depends on the popup panel function called... Is this by design or can it be fixed?

 

Thank you

0 Kudos
Message 1 of 8
(3,922 Views)

I do not have much hope that it would behave different than MessagePopup, but how about using GenericMessagePopup ?

 

I often find myself writing my own message popup functions. Maybe this is another reason for doing so..

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 8
(3,900 Views)

Thanks Eren!

 

I will try setting up a simplified sample project showing the issue...

0 Kudos
Message 3 of 8
(3,857 Views)

OK,

 

I managed to produce a very simple demo showing the problem. It turned out that my initial assumption was wrong, it is not a question of different popup panels but a question of where the mouse cursor position is located when the DisplayPopup is called:

 

If the mouse cursor is not over the graph, the mouse cursor is - as it should be - in its default style when moved over the popup.

If, however, the mouse cursor is over a menu that overlaps the graph region, the mouse cursor will change, erroneously, to cross hair style when moved over the popup

 

Note that the cursor style is correct when the mouse is slightly moved from the menu over the graph: as long as the mouse is over the menu, is is standard style, changes to cross hair when over graph, and back to standard style when over menu again.

 

Attached are the source file: run it, press the OK button to display the popup with the correctly behaving mouse cursor style. Use the menu to show the same popup panel but now with the wrongly behaving mouse cursor style.

 

Thanks!

0 Kudos
Message 4 of 8
(3,793 Views)
Solution
Accepted by topic author Wolfgang

Hi Wolfgang,

I slightly modified your program adding an evidence of when you set the crosshair cursor. It appears that the program still sets the cursor when you are navigating in the menu, even though the system does not honour this setting (it is probably correct that the cursor remains the default one while inside the menu, right?). Question is why the system shows the crosshair cursor inside the popup window, but it is indeed honouring your own choice!

 

As you already evidenced, the problem verifies depending on the state of the cursor when the window is issued, and does not depend on the type of window: I added two options to the menu to display a panel with InstallPopup and to display it as floating window with DisplayPopup; the latter option is useful to see what happens in various situations when the window partially overlaps the graph and you can click on it when coming from the plot area and from the rest of the main window.

 

It seems to me that the system honours the cursor style when inside a panel (possibly because in that area there are controls that could be operated on, who knows?) while is shows the default cursor elsewhere.

 

Since when the popup is shown the timer code is never executed and the cursor change is performed by the OS, I suppose the only workaround you have is to exclude the cursor timer when operating on the menu.

 

(you'll see I have changed to 32-bit configuration: I wanted to verify if that changes the behavior but it operates the same way)



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 5 of 8
(3,760 Views)

Dear Roberto,

 

Thank you so much for investigating this issue! 

It is an interesting conclusion that the cursor change is performed by the OS...

 

I thought of using a menu dimmer callback to stop the cursor timer, but how would I efficiently restart it? Somehow I hesitate to add a line to every of the hundred menu callbacks for restarting the cursor timer, but I am not aware of a suitable event... Smiley Sad

0 Kudos
Message 6 of 8
(3,749 Views)

OK, with the new understanding of the OS responsibility (no timer ticks during the display of popup panels) I think the best/simplest solution is to add an additional call to set the mouse cursor style for every menu entry that is calling a panel.

 

Thanks again Roberto for sharing your insights!

0 Kudos
Message 7 of 8
(3,721 Views)

...and as mentioned in the first post this 'fix' of manually setting the mouse cursor style is not required for FilePopupEx () since this function seems to take care of the mouse cursor by itself

0 Kudos
Message 8 of 8
(3,717 Views)