[DUG] Component creation
Karl at Work
karlreynolds at xtra.co.nz
Tue Sep 5 12:45:15 NZST 2006
If you really need to detect any mouse click outside your component you're
going to have to put in an application-wide mouse event hook to do that, ie.
YourHook := SetWindowsHookEx(WH_MOUSE, @YourHookProc, 0,
GetCurrentThreadID);
You will have to globally keep track of which component, if any, is expanded
so that YourHookProc can contract it again on a click elsewhere - it sounds
like only one can be expanded at once, so you shouldn't need to track all
component instances in this case. So YourHookProc will be something like
(untested):
function YourHookProc(Code: Integer; WParam, LParam: Longint): Longint;
stdcall;
begin
if ExpandedThing <> nil then
case WParam of
WM_NCLBUTTONDOWN, WM_NCLBUTTONDBLCLK, WM_LBUTTONDOWN,
WM_LBUTTONDBLCLK:
ExpandedThing.Contract;
end;
Result := CallNextHookEx(YourHook, Code, WParam, LParam);
end;
Call UnhookWindowsHookEx when you're done.
Cheers,
Carl
More information about the Delphi
mailing list