Fons wrote:
> This works fine:
>
> procedure TFormTest.WndProc(var Message: TMessage);
> begin
> inherited;
>
> if Message.LParam = longint(Label1) then begin
> case Message.Msg of
> CM_MOUSELEAVE : Label2.Caption := 'CM_MOUSELEAVE';
> CM_MOUSEENTER : Label2.Caption := 'CM_MOUSEENTER';
> end;
> end;
> end;
You have it backward. The LParam field is _meaningless_ until you know
which message it's the long parameter _to_. The first field to check
should always be Msg, never WParam, LParam, or LResult.
> Until I put Label1 in a TPanel. If I catch WndProc of Label1, instead of
> the Form, I can make it work but there must be a better solution.
Why should there be? If you're interested in what's happening to the
label, why shouldn't you handle messages sent to the label?
--
Rob


|