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: 

Possible bug found in hyperlinkctrl.c when using mouse cursor "VAL_POINTING_FINGER_CURSOR" in your own UI.

Solved!
Go to solution

Hi folks, I think I found a bug in the hyperlinkctrl.c custom control, after updating/enhancing an old CVI project.

 

I found it when I switched to using the mouse cursor "VAL_POINTING_FINGER_CURSOR" in my user interface, while adding a new hyperlink control.

 

The error was the non-fatal error: "The mouse cursor passed is not valid".

 

This error breaks from within RunUserInterface (never saw anything like that before, and I've been using CVI since ver. 3.1).

 

This happens as soon as I mouse-hovered anywhere on the panel which contained the new hyperlink control.

 

I also got a temporary hack to solve the problem, for now, which I will pass along in this posting...

 

The hyperlink control source code is located in <install-dir>\toolslib\custctrl\hyperlinkctrl.c

 

The bug/problem is located in the callback function HyperLinkPanelCallback ( ), specifically at lines 460 to 465.

 

This hyperlink control wants to use the VAL_POINTING_FINGER_CURSOR as its default cursor, when you hover over the custom hyperlink.

 

However, if you already happen to be using "VAL_POINTING_FINGER_CURSOR" in your UI, the branch that checks for whether you are using what it thinks is "its own" thread-safe mouse cursor ID, so that it can reset it using its "token concatenation" -created macro "GetTsvCursor", does not have an "else" branch to protect for the ituation when you actually are using the pointing finger cursor... hence the error that the mouse cursor is not valid. Here's the code snippet from those lines.

 

// Mouse is not over a hyperlink
if (cursor == VAL_POINTING_FINGER_CURSOR)
{
    // Reset cursor to previous cached cursor
    cursor = GetTsvCursor();
    errChk(SetMouseCursor(cursor));

     ...etc...

}

 

So my hack was to swap the "VAL_CHECK_CURSOR" cursor type in place of the "VAL_POINTING_FINGER_CURSOR" cursor in three places in that function, then rebuilt the x86 and x64 object files.

 

Hey Luis, did I finally earn a free LabWindows/CVI T-shirt with not only reporting this bug, but also giving the precise location in the source, plus a work-around?

 

:^)

 

JB

--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 1 of 7
(4,457 Views)

Hello JB,

 

I just tried to reproduce the potential bug that you reported, but wasn't able to experience the error.

Here are the steps that I've performed using CVI 2013 and CVI 2015:

  1. Created a new LabWindows/CVI User Interface application from template.
  2. Dropped a new Text Label control the panel.
  3. Programmatically created a new hyperlink control by providing the text label control to NewHyperLinkCtrl custom control function.
  4. Set the panel's Mouse Cursor attribute to "pointing finger cursor" from the Property Browser.
  5. Built and debugged the application.
  6. Hovered over the panel area and over the hyperlink custom control.

Can you provide any steps that I'm missing, JB?

 

Thanks!

- Johannes

0 Kudos
Message 2 of 7
(4,412 Views)

Hmmm... I never realized that you could set the panel mouse cursor via the panel property browser, but there it is...!

 

I am an old-timer, and I hardly use that property browser, I have always used SetMouseCursor ( ).

 

Also, my application is a DLL with a user interface, and therefore I use LoadPanelEx instead of LoadPanel.

 

I will revist my project later this week to check on your advice, so I do not have to use my workaround.

 

Thank you so much for looking into this, please stay tuned,

 

JB

--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 3 of 7
(4,401 Views)

Hello JB,

 

I've finally managed to reproduce the bug.

It looks as if the cached cursor in the Hyperlink custom control is not initialized properly. Currently, I would suggest the following workaround:

Modify the HyperLink source code to initialize the cursor with the current mouse cursor: In the Initialize() function of the hyperlinkctrl.c source file, just before the cached cursor is set, initialize the TSV value like this:

 

int cursor;

GetMouseCursor (&cursor);
SetTsvCursor (cursor);

 

Let me know if this workaround works for you.

 

Best regards!

- Johannes

0 Kudos
Message 4 of 7
(4,381 Views)
Solution
Accepted by topic author JumperBones

In the meantime, I've submitted a bug report with ID #545203 to track this problem down.

 

- Johannes

0 Kudos
Message 5 of 7
(4,373 Views)

Thank you so much...!

 

Unfortumately, I will not be able to make these modifications and then verify your proposed bug fix for a few days.

 

 am under the gun to complete this CVI project, so that is where my attention must stay for at least this week or more.

 

And your proposed bug fix looks to be much more elegant than mine, so I suppose that LuisG can offer a free NI T-shirt to you instead of me...!

 

Bye for now, JB

--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 6 of 7
(4,360 Views)

Hi Johannes, I just flagged your solution as the "accepted solution" for this bug report.

 

Here are the exact changes I made to that "Initialize" function, in case anyone else wants to implement them before the official CVI bug-fix is released:

 

Also, my "Build Options > Compiler Warnings >> Warning level" are set to "Extended", which recommends initializing "locked" before using it.

 

So I also initialized all local three variables in this function to zero:

 

static int Initialize(void)
{
int error = 0;
int locked = 0;
int cursor = 0;

 

...stuff deleted...

 

 

errChk(CmtNewLock(0, 0, &libLock));
InitializeTsvCursor();
GetMouseCursor (&cursor);
SetTsvCursor (cursor);

initialized = 1;

 

...stuff deleted...


return error;
}

 

Thanks again Johannes...!

 

JB

--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 7 of 7
(4,324 Views)