I am writing a little component which i derive from speed button. All i need to do is actually override the paint method because i would like to change the appearance.
Now i’ve reached to the point where i would like to give different background color when button is clicked. However, i can’t find a way to catch left mouse button click message in my component.
What i’ve used so far:
procedure KeyboardButton.WndProc(var Message: TMessage);
begin
if Message.LParam = VK_LBUTTON then
begin
//Some code
end
else
inherited;
end;
Which doesn’t work as when i click on the button Message.LParam is not 1.
Also i tried…
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
Well, i know that CM_MOUSELEAVE is not a message that represents mouse click. But maybe there’s a message like CM_MOUSECLICK??? I couldn’t find it though. At all, can anyone please tell me what is CM_XXXX as i can’t find anything from msdn? Seems like Delphi specific messages.
Thanks in advance!
You’re not correctly testing for a mouse event. Try this:
BTW,
TMessage.LParamandTMessage.WParamare parameters passed with a specific message type (likeWM_LBUTTONDOWN), and have different meanings depending on whatTMessage.Msgactually is. There should never be a case where you get a generic message likeTMessageand check only theWParamorLParam.