What are csClickEvents and csCaptureMouse exactly?
I'm trying to understand the ControlStyle
property i开发者_如何学运维n Delphi 2007, but I'm having trouble grasping the csClickEvents
and csCaptureMouse
attributes.
According to specifications, csCaptureMouse
makes the control capture mouse events when it is clicked, whereas csClickEvents
enables the control to receive and answer to mouse clicks. It also mentions explicitly that TButton
does not inherit this attribute (I've checked the source code: this is indeed the case).
What exactly do csCaptureMouse
and csClickEvents
do, and what is the difference? Thanks for any answer.
csCaptureMouse means for example that the component will receive MouseUp event (after click on the component) even if the mouse was released out of the component's bounds;
csClickEvents means that the component generates OnClick events.
These options are different.
About why TButton does not include csClickEvents - the answer is:
Because the mechanism through which you receive clicks for a TButton is different - it generates click events from a BN_CLICKED windows message, which is the windows way of handling buttons, rather than via WML_BUTTONDOWN, which is the default for a TControl. It may be that now you've included csClickEvents that you'll get two Clicks for every mouse click, or perhaps one will be discarded, but you may still get strange behaviour. I haven't delved deeply enough to know the pitfalls of turning csClickEvents on but I wouldn't assume it will be plain sailing.
I have found this answer in New Zealand DUG archive
精彩评论