LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Associating a callback with an LED label

Hi all,
I have a GUI interface which have a bunch of LEDs on it. When an LED is clicked, a callback function is called.
I want the user to be able to click the LED label as well to call the same callback.
So far I haven't been able to associate a callback with a control label.
Is there a way of doing this?
 
All help is highly appreciated.
Thanks!
 
 
 
0 Kudos
Message 1 of 5
(3,548 Views)
Easy...
 
Edit the LED contrl, delete the label.
 
Create a TEXTMSG control, change the text to the label text, adjust attributes like size, bold, etc to look just like your label. 
 
Put the TEXTMSG control where your label was, and give it the callback function name to call on EventCommit.
 
Now, the one tricky part:  You must explicitly use the LED control handle in the callback function, not the passed parameter 'control'.
 
Enjoy...
0 Kudos
Message 2 of 5
(3,548 Views)
Sorry, not quite so easy...

A Text Message control cannot generate events, or even receive focus.

You might find some useful ideas in the attached project.

Good luck,
Colin.

0 Kudos
Message 3 of 5
(3,533 Views)
Wrong Colin.  Text messages do issue events.  I use EVENT_RIGHT_CLICK with them all the time.  Can't say I've used EVENT_COMMIT with them, and you are probably right about that event.  But certainly they issue EVENT_LEFT_CLICK events. 
 
Still a simple solution.
0 Kudos
Message 4 of 5
(3,508 Views)
My apologies.

You're absolutely right, and I was wrong. The left-click on the text message is a much better approach; I only checked for EVENT_COMMIT. Smiley Sad

I'll check my facts
more carefully in future!

Regards,
Colin.


0 Kudos
Message 5 of 5
(3,489 Views)