04-01-2011 03:10 AM
04-01-2011 04:36 AM
As of CVI2009 I'm afraid a dimmed control receives only EVENT_DISCARD events
You could install a panel callback and handle EVENT_LEFT_CLICK event, handling control state depending on callbackdata parameters which hold mouse coordinates: not so elegant since you must store control coordinates in static variable in order to save processor time, but it works. It all depends on how many controls do you have to handle this way.
static int left1 = 0, left2 = 0, top1 = 0, top2 = 0;
if (!left1) {
GetCtrlAttribute (panel, PANEL_setI, ATTR_LEFT, &left1);
GetCtrlAttribute (panel, PANEL_setI, ATTR_WIDTH, &left2); left2 += left1;
}
if (!top1) {
GetCtrlAttribute (panel, PANEL_setI, ATTR_TOP, &top1);
GetCtrlAttribute (panel, PANEL_setI, ATTR_HEIGHT, &top2); top2 += top1;
}
if (event == EVENT_LEFT_CLICK) {
if (eventData1 >= top1 && eventData1 <= top2 && eventData1 >= left1 && eventData2 <= left2) {
// dim / undim the control
}
}
Now let's wait for Luis' or Nick's or somebody else's post that shows some for-me-unknown CVI function that natively does that exact thing faster and easier
04-01-2011 09:22 AM
As far as I'm aware, what Roberto has posted is the only method available. However, I would suggest perhaps using GetCtrlBoundingRect in association with RectContainsPoint to check whether the mouse click lies within the dimmed control:
NickB
National Instruments
04-01-2011 06:01 PM - edited 04-01-2011 06:04 PM
Aha! I was not aware of RectContainsPoint function!
I see this is present in CVI since release 4 Every day I can learn something new in this board: thanks Nick
Be aware, though, that in GetCtrlBoundingRect is included room for control label too, which could in some case enlarge a lot the active area for the function.
04-04-2011 03:10 AM