library R;
{$R *.res}
procedure SetDllSkin(Handle: HWnd;AData: Pointer);
begin
Application.Handle := Handle;
Winskindata.SkinDll(AData);
end;
var
DllApp: TApplication;
hhk: HHOOK;
FMouseControl: TControl;
function DoMouse: TControl;
var
CaptureControl: TControl;
P: TPoint;
begin
GetCursorPos(P);
Result := FindDragTarget(P, True);
if (Result <> nil) and (csDesigning in Result.ComponentState) then
Result := nil;
CaptureControl := GetCaptureControl;
if FMouseControl <> Result then
begin
if ((FMouseControl <> nil) and (CaptureControl = nil)) or
((CaptureControl <> nil) and (FMouseControl = CaptureControl)) then
FMouseControl.Perform(CM_MOUSELEAVE, 0, 0);
FMouseControl := Result;
if ((FMouseControl <> nil) and (CaptureControl = nil)) or
((CaptureControl <> nil) and (FMouseControl = CaptureControl)) then
FMouseControl.Perform(CM_MOUSEENTER, 0, 0);
end;
end;
function MouseProc(nCode: Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
if (nCode=HC_ACTION) and (wParam=WM_MOUSEMOVE) then
begin
DoMouse;
end;
Result := CallNextHookEx(hhk,nCode,wParam,lParam);
end;
procedure HookOn;
begin
hhk := SetWindowsHookEx(WH_MOUSE,@MouseProc,HInstance,GetCurrentThreadId);
end;
procedure HookOff;
begin
UnhookWindowsHookEx(hhk);
end;
procedure DllMain(Reason:integer);
begin
if Reason=DLL_PROCESS_ATTACH then
begin
HookOn;
end else
if Reason=DLL_PROCESS_DETACH then
begin
Application:=DLLApp;//恢复
HookOff;
end;
end;
begin
DllApp := Application;
DllProc := @DllMain;
DllMain(DLL_PROCESS_ATTACH);
end.
浙公网安备 33010602011771号