LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Dimmed events

Hello all,
what kind of events can a dimmed control receive ?
I was trying to have a control 'undim' when clicked on, but that doesn't
work. Suggestions, beside putting an on/off button next to it ?
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 1 of 5
(3,146 Views)

As of CVI2009 I'm afraid a dimmed control receives only EVENT_DISCARD events Smiley Sad

 

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 Smiley Wink

    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;
    }



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?
0 Kudos
Message 2 of 5
(3,141 Views)

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:

 

Rect r;
GetCtrlBoundingRect (panel, ctrl, &r.top, &r.left, &r.height, &r.width);
if (RectContainsPoint (r, MakePoint (eventData2, eventData1))) {
...
}

 

NickB

National Instruments

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

Aha! I was not aware of RectContainsPoint function! Smiley Wink

I see this is present in CVI since release 4 Smiley Surprised Every day I can learn something new in this board: thanks Nick Smiley Happy

 

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.



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?
0 Kudos
Message 4 of 5
(3,123 Views)
Thanks, I'll see what I can do with that.
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 5 of 5
(3,109 Views)