[Lazarus] Forwarding events/messages

Ondrej Pokorny lazarus at kluug.net
Wed Nov 4 18:07:11 CET 2015


On 04.11.2015 17:54, Martin Grajcar wrote:
> I'd like to forward a TLMVScroll message to the parent component as a 
> workaround for controls preventing parents from receiving mouse wheel 
> events (I couldn't find out how to let the parents receive them).
>
> The problem is that the handler is
>
> PROCEDURE TWhatever.WMVScroll(VAR Message : TLMVScroll);
>
> and I need to put it in
>
> FUNCTION SendMessage(HandleWnd: HWND; Msg: Cardinal; WParam: WParam; 
> LParam: LParam): LResult;
>
> Or am I missing a more suitable procedure? Why is there no
>
> SendMessage(Message : TLMVScroll);
>
> which would do exactly this?

There is TControl.WndProc, but don't call it directly if you don't know 
what and why you are doing it.

> My workaround is to scroll manually, like
>
> TScrollingWinControl(Parent).ScrollBy (0, ScrollAmount);
>
> but this feels stupid as it duplicates the ScrollAmount computation.

AFAIK forwarding of messages works only on Windows, so if you need it 
cross-platform, you will have to use 
"TScrollingWinControl(Parent).ScrollBy (0, ScrollAmount);" in any case. 
So this should be the correct way to do it. - Zeljko, correct me if I am 
wrong, you are the specialist here :)

Ondrej
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20151104/e4b039f4/attachment-0003.html>


More information about the Lazarus mailing list