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.
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.
09-04-2015 12:40 PM
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
Solved! Go to Solution.
09-08-2015 03:57 AM - edited 09-08-2015 04:06 AM
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:
Can you provide any steps that I'm missing, JB?
Thanks!
- Johannes
09-08-2015 08:56 AM - edited 09-08-2015 08:58 AM
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
09-09-2015 04:23 AM
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
09-09-2015 05:40 AM
In the meantime, I've submitted a bug report with ID #545203 to track this problem down.
- Johannes
09-09-2015 01:00 PM
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
09-11-2015 12:02 PM
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