Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-11

Forwarding events/messages

5 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Grajcar

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?

My workaround is to scroll manually, like

TScrollingWinControl(Parent).ScrollBy (0, ScrollAmount);

but this feels stupid as it duplicates the ScrollAmount computation. -------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151104/db897fa0/attachment.html>

Reply by email

Ondrej Pokorny
to Martin Grajcar
Martin Grajcar wrote 18 lines
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.

Show quoted text 5 lines
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.freepascal.org/pipermail/lazarus/attachments/20151104/e4b039f4/attachment-0001.html>

Reply by email

Martin Grajcar
to Ondrej Pokorny
Ondrej Pokorny wrote 25 lines
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.

I found it in the meantime... and the usage seems to be obvious (if the parent instance and message type checks pass, then send it to the parent, otherwise call inherited). The tiny problem is that it does workaround is to scroll manually, like

Show quoted text 8 lines
TScrollingWinControl(Parent).ScrollBy (0, ScrollAmount); but this feels stupid as it duplicates the ScrollAmount computation. AFAIK forwarding of messages works only on Windows,

This could be the reason for my code doing nothing. :(

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.

That's ugly like hell and I can only guess the ScrollAmount, which means that it can scroll much more or less than when the mouse it outside of my TControl.

Anyway, thank you!

Martin.

- Zeljko, correct me if I am wrong, you are the specialist here :) Ondrej

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151104/d6ca4345/attachment.html>

Reply by email

Ondrej Pokorny
to Martin Grajcar
Martin Grajcar wrote 13 lines
On Wed, Nov 4, 2015 at 6:07 PM, Ondrej Pokorny < <mailto:>> wrote: There is TControl.WndProc, but don't call it directly if you don't know what and why you are doing it. I found it in the meantime... and the usage seems to be obvious (if the parent instance and message type checks pass, then send it to the parent, otherwise call inherited). The tiny problem is that it does nothing at all.

This is why I said don't do that :)

Show quoted text 19 lines
> 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, This could be the reason for my code doing nothing. :( 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. That's ugly like hell and I can only guess the ScrollAmount, which means that it can scroll much more or less than when the mouse it outside of my TControl.

Yes that's true and correct. AFAIK on other OS than Win, no change to do it differently. Maybe Zeljko knows some dirty tricks ;)

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

Reply by email