Hey Sid, You are correct sir, I should have thought of that as well. I guess I was just happy to see it work using TDBGrid.
Thanks again, Mike -----Original Message----- From: Delphi-Talk [mailto:delphi-talk-boun...@lists.elists.org] On Behalf Of Sid Gudes Sent: Monday, August 10, 2015 10:19 AM To: Delphi-Talk Discussion List Subject: RE: How to force Delphi to respond to mouse wheel event for any control under the mouse? Glad to hear it worked! BTW, I just realized that TCustomGrid is a common ancestor of TStringGrid and TDBGrid (and TDrawGrid). Might want to try changing "if wc is TDBGrid" to "if wc is TCustomGrid", since if that works it will cover all those grids in one statement. At 06:34 AM 8/10/2015, stwizard wrote: >Thanks Sid, works as expected now. I appreciate you taking to time to help. > >Mike > >-----Original Message----- >From: Delphi-Talk [mailto:delphi-talk-boun...@lists.elists.org] On >Behalf Of Sid Gudes >Sent: Saturday, August 08, 2015 11:35 AM >To: Delphi-Talk Discussion List >Subject: Re: How to force Delphi to respond to mouse wheel event for >any control under the mouse? > >I tried the sample code with a TListBox and it worked fine. Then I >tried it with a TStringGrid and it did not work (I don't use TDBGrid, >but IIRC it is built on TStringGrid). It looks like TStringGrid >intercepts the message in an odd way (probably something to do with hot tracking?). > >I played around a bit and got the following to work. In your code >below, change > > SendMessage(wc.Handle, WM_MOUSEWHEEL, Msg.wParam, Msg.lParam); > >to > > if wc is TStringGrid { need to try with TDBGrid } then > SendMessage(wc.Handle, WM_VSCROLL, Msg.wParam, Msg.lParam) > else > SendMessage(wc.Handle, WM_MOUSEWHEEL, Msg.wParam, > Msg.lParam); > > >At 07:08 AM 8/7/2015, stwizard wrote: > >Greetings All, > > > > > > > >Delphi XE5 > > > > > > > >There are certain controls on a Delphi app that respond to a mouse > >wheel event like TMemo, TDBGrid, TListView, etc when and only when > >they have focus. > > > > > > > >There are applications like Microsoft Outlook where the controls will > >respond anytime the mouse is over the control when using the mouse wheel. > >It does not have to be clicked on to receive focus first. > > > > > > > >I found this article on line that I thought would do the trick: > > > >http://delphi.about.com/od/delphitips2010/qt/delphi-redirect-mouse-wh > >ee > >l-con > >trol-under-the-mouse.htm > > > > > > > >I tried it and it does not work (at all). When I debug the following > >code, FindVCLWindow correctly finds the control the mouse is over, > >but it appears that the SendMessage() does nothing or has no affect. > > > > > > > >procedure TfrmMain.ApplicationEventsMessage(var Msg: tagMSG; var Handled: > >Boolean); > > > >var > > > > mousePos: TPoint; > > > > wc: TWinControl; > > > >begin > > > > inherited; > > > > > > > > //* Mouse wheel scrolling for the control under the mouse > > > > if Msg.message = WM_MOUSEWHEEL then > > > > begin > > > > mousePos.X := Word(Msg.lParam); > > > > mousePos.Y := HiWord(Msg.lParam); > > > > wc := FindVCLWindow(mousePos); > > > > > > > > if wc = nil then > > > > Handled := True > > > > else if wc.Handle <> Msg.hwnd then > > > > begin > > > > SendMessage(wc.Handle, WM_MOUSEWHEEL, Msg.wParam, > > Msg.lParam); > > > > Handled := True; > > > > end; > > > > end; > > > >end; > > > > > > > >For instance, if I have 2 TDBGrid's on a form, I run it and neither > >grid has focus yet and I scroll the mouse wheel, nothing happens, > >even if I have the mouse over one of the grids and try to scroll. > >Then if I select one of the grids and use the mouse wheel it scrolls > >that grid (as it would even without this code), then if I move the > >mouse over the other grid, the first grid (which still has the focus) > >will scroll, not the >one the mouse is over. > > > > > > > >I simply want either grid to scroll without being selected (to > >receive > >focus) when the mouse is hovering over it. > > > > > > > >Does anyone have something that will work? > > > > > > > >Thanks, > > > >Mike > > > > > > > >__________________________________________________ > >Delphi-Talk mailing list -> Delphi-Talk@lists.elists.org > >http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk > >__________________________________________________ >Delphi-Talk mailing list -> Delphi-Talk@lists.elists.org >http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk > >__________________________________________________ >Delphi-Talk mailing list -> Delphi-Talk@lists.elists.org >http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk __________________________________________________ Delphi-Talk mailing list -> Delphi-Talk@lists.elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk __________________________________________________ Delphi-Talk mailing list -> Delphi-Talk@lists.elists.org http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-talk