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
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi