Board index » delphi » How do I find WM_LBUTTONDOWN target?

How do I find WM_LBUTTONDOWN target?

I'm trying to implement 'Whats This' help where you click a help button,
your cursor changes to a help cursor and then you click on anything in your
application to call up help for it.  I want to intercept the next mouse down
message and handle it before the intended target receives it.

When the help button is down I hook into TApplication.OnMessage and look for
the WM_LBUTTONDOWN message.  Once I have it I need to know what application
object it would be sent to if I weren't intercepting it.  It might not be a
TControl (in the case of a TMenuItem) so TWinControl.ControlAtPos won't
work.   I know there's a simple way to get this but it wasn't apparent to me
from the vcl source code.

Thanks,
Darren Clarke

 

Re:How do I find WM_LBUTTONDOWN target?


Quote
In article <87v6fm$c...@bornews.borland.com>, Darren Clarke wrote:
> I'm trying to implement 'Whats This' help where you click a help button,
> your cursor changes to a help cursor and then you click on anything in your
> application to call up help for it.  I want to intercept the next mouse down
> message and handle it before the intended target receives it.
> When the help button is down I hook into TApplication.OnMessage and look for
> the WM_LBUTTONDOWN message.  Once I have it I need to know what application
> object it would be sent to if I weren't intercepting it.  It might not be a
> TControl (in the case of a TMenuItem) so TWinControl.ControlAtPos won't
> work.   I know there's a simple way to get this but it wasn't apparent to me
> from the vcl source code.

You can use the FindDragTarget VCL function to find the control under the
cursor. But you could also harness the build-in support for WM_HELP: if you do
this in your help buttons OnClick handler

  Perform( WM_SYSCOMMAND, SC_CONTEXTHELP, 0 );

Windows goes into the context help mode (the same you get when you click on
the biHelp border icon in a dialog-style form). If the user now clicks on
something the form is send a WM_HELP message, which the VCL handles for you.
If there is a helpfile assigned to the Application.HelpFile property (or to
the forms Helpfile property) and if the control clicked on has a HelpContext
property <> 0 then the VCL automatically calls up the helpfile with the page
associated with this help context ID. If the form has the biHelp bordericon
(whether it is visible or not, depends on Borderstyle) the help will pop up in
a popup window, otherwise you get the normal help window.  

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

Other Threads