[DUG] Order of mouse events
John Bird
johnkbird at paradise.net.nz
Wed Jan 10 19:02:56 NZDT 2007
One way to do this:
If you don't need the click event, eg you are using a part of the form to
drag that does not need to watch for clicks:
(declaration)
procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
//drag with mouse on the form
//in this case only part that can be used is the round frame
inherited;
if Msg.Result = HTCLIENT then
Msg.Result := HTCAPTION;
end;
Effectively says to Windows that you have clicked on the title bar of the
form, which it understands as a drag area. I use it when I have a form with
no title bar eg an Analogue round clock. If you need the click as well you
might have to modify this and it may be simpler to do it another way...
John
-----Original Message-----
From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
Behalf Of Max Nilson
Sent: Wednesday, 10 January 2007 5:11 p.m.
To: NZ Borland Developers Group - Delphi List
Subject: RE: [DUG] Order of mouse events
Keith asked:
> I want to be able to either click or drag a component without
> using the shift key.
The only way that I have found that is satisfactory doing this sort of thing
to to use a timer to handle the mouse click. If a MouseUp event occurs
before the timer fires that you treat it as a click event, and it the timer
expires then you assume that the user has started a drag operation (where
upon you use a manual drag begin method).
Its all a bit ugly, especially if you want to support double clicks as well,
but as far as I can tell this is the only way of differentiating between a
click event and a drag start event.
Cheers, Max.
_______________________________________________
Delphi mailing list
Delphi at ns3.123.co.nz http://ns3.123.co.nz/mailman/listinfo/delphi
__________ NOD32 1.1461 (20060329) Information __________
This message was checked by NOD32 antivirus system. http://www.eset.com
More information about the Delphi
mailing list