function GetInstanceFromhWnd(const hWnd: Cardinal): TWinControl;
type
PObjectInstance = ^TObjectInstance;
TObjectInstance = packed record
Code: Byte; { 短跳转 $E8 }
Offset: Integer; { CalcJmpOffset(Instance, @Block^.Code); }
Next: PObjectInstance; { MainWndProc 地址 }
Self: Pointer; { 控件对象地址 }
end;
var
wc: PObjectInstance;
begin
Result := nil;
wc := Pointer(GetWindowLong(hWnd, GWL_WNDPROC));
if wc <> nil then
begin
Result := wc.Self;
end;
end;
type
PObjectInstance = ^TObjectInstance;
TObjectInstance = packed record
Code: Byte; { 短跳转 $E8 }
Offset: Integer; { CalcJmpOffset(Instance, @Block^.Code); }
Next: PObjectInstance; { MainWndProc 地址 }
Self: Pointer; { 控件对象地址 }
end;
var
wc: PObjectInstance;
begin
Result := nil;
wc := Pointer(GetWindowLong(hWnd, GWL_WNDPROC));
if wc <> nil then
begin
Result := wc.Self;
end;
end;