A WM_VSCROLL message handler works perfectly for me.
However, this will only be sent for scrollbar directed scrolling. To also handle mousewheel scrolling you will have to implement a WM_MOUSEWHEEL message handler (and WM_HMOUSEWHEEL if appropriate to your needs). Could it be mouse scrolling that you are missing ? I would also note that you will almost certainly want to distinguish between H and V scrolling, rather than have a "universal" "some sort of scrolling has occurred" notification. You may also wish to be able to respond both before and after scrolling has occurred. In my list view class I have: TScrollNotification = ( snBeforeHScroll, snBeforeHWheel, snBeforeVScroll, snBeforeWheel, snHScroll, snHWheel, snVScroll, snWheel ); procedure TXListview.WMVScroll(var aMessage: TWMVScroll); begin DoScroll(snBeforeVScroll); inherited; DoScroll(snVScroll); end; procedure TXListview.WMHScroll(var aMessage: TWMHScroll); begin DoScroll(snBeforeHScroll); inherited; DoScroll(snHScroll); end; and similar for mousewheel messages of course, where DoScroll: procedure TXListview.DoScroll(const aNotification: TScrollNotification); begin if (aNotification in [snBeforeHScroll, snBeforeVScroll, snBeforeHWheel, snBeforeWheel]) then CancelEdit; if Assigned(fOnScroll) then fOnScroll(self, aNotification); end; i.e. my listview also provides a facility for sub-item editing and when scrolling occurs, the first thing I do before doing the actual scrolling is dismiss any sub-item editor that may be active, before then firing the OnScroll event to allow my application code to respond as it may require. hth From: delphi-boun...@delphi.org.nz [mailto:delphi-boun...@delphi.org.nz] On Behalf Of David O'Brien Sent: Friday, 25 February 2011 15:09 To: NZ Borland Developers Group - Delphi List Subject: [DUG] Listview problem I am working on an application (D2009) where I need to know when a TListView is Scrolled. I have used Application.OnMessage to look for WM_VScroll messages, but they do not happen, also have tried creating the below which I thought should work: TLVScrollEvent = procedure(Sender: TObject) of object; TICListView = class(TListView) private FOnScroll: TLVScrollEvent; protected Procedure WMVScroll( Var Msg: TMessage ); message WM_VSCROLL; Procedure WMHScroll( Var Msg: TMessage ); message WM_HSCROLL; property OnScroll: TLVScrollEvent read FOnScroll write FOnscroll ; end; procedure Register ; implementation procedure Register; begin RegisterComponents('Dave', [TICListView]); end; procedure TICListView.WMHScroll(var Msg: TMessage); begin OnScroll ; inherited; end; procedure TICListView.WMVScroll(var Msg: TMessage); begin OnScroll ; inherited; end; which also doesn't fire. I have written a list of all messages fired when the scrollbar is moved, but there doesn't seem to be anything useful. Anyone have a solution? Regards, Dave.
_______________________________________________ NZ Borland Developers Group - Delphi mailing list Post: delphi@delphi.org.nz Admin: http://delphi.org.nz/mailman/listinfo/delphi Unsubscribe: send an email to delphi-requ...@delphi.org.nz with Subject: unsubscribe