01-08-2010 03:05 PM
The reason I ask is that I seem to be getting unexpected results in a control callback. I have a Table control, which is then duplicated (many times) in the same position as the original. I switch between them by setting the ATTR_VISIBLE attribute on just one at a time, but whichever one is presented on the GUI I always get the same control ID passed in the common callback - the ID is of the last one duplicated, even if it is not visible. I have a workaround, of course, since I know which one I have made visible: it's just that to have the correct callback ID would have been more convenient.
Just guessing, but it seems that CVI searches for any control whose XY coordinates match the position of the mouse, and ignores whether that control is visible or not. Surely not the best way to do it...
Mike
Solved! Go to Solution.
01-09-2010 04:27 AM
According to my experience, when the callback responds to EVENT_COMMIT and EVENT_GOT_FOCUS events it receives the correct control ID even in case of overlapping controls; I never used EVENT_xxx_CLICK events in such a manner (which I suppose you are using since you are speaking of mouse coordinates) so I cannot tell anything for sure but in my opinion the system can respond returning the control ID of the topmost control (which is the last one created and seconds your observations). While I don't know if this is true and agree with you that an invisible control should not respond to any event, I can suggest you to add one simple SetCtrlAttribute instruction immediately after making visible one of the tables to make it the topmost control (I seem to remember that the related attribute is ATTR_ZPLANE_POSITION with a value of 0 to let it topmost but I cannot check at the moment; look in the online help for detailed documentation).
01-11-2010 03:11 PM
As usual, you are of course quite correct, Roberto. Looking at my code in more detail I found a bug. Very embarassing. (In my defence the bug only arose under some unusual circumstances.)
Thanks again
Mike