1,183
社区成员
发帖
与我相关
我的任务
分享
function FindControl(Handle: HWnd): TWinControl;
var
OwningProcess: DWORD;
ControlAtomString :string;
ControlAtom :TAtom;
RM_GetObjectInstance : dword;
begin
ControlAtomString := Format('ControlOfs%.8X%.8X', [HInstance, GetCurrentThreadID]);
ControlAtom := GlobalAddAtom(PChar(ControlAtomString));
RM_GetObjectInstance := RegisterWindowMessage(PChar(ControlAtomString));
Result := nil;
if (Handle <> 0) and (GetWindowThreadProcessID(Handle, OwningProcess) <> 0) and
(OwningProcess = GetCurrentProcessId) then
begin
Result := Pointer(SendMessage(Handle, RM_GetObjectInstance, 0, 0));
end;
end;
调用
SG := Pointer(FindControl(P^.DestWnd));
var SG: TDBGrid;