解決策 / 回避方法
|
私は、この問題は Controls.pas を修正することによってのみ対応可能だと考えています。以下に示すのはひとつの解決方法です - FindControl と IsDelphiHandle を、ハンドルのプロセス ID がデスクトップウィンドウや別のプロセスのウィンドウではないことを確認するように修正しています。
Delphi 6
function FindControl(Handle: HWnd): TWinControl;
var
PID: DWORD;
begin
Result := nil;
if (Handle <> 0) then
begin
if (GetWindowThreadProcessId(Handle, @PID) <> 0) and
(PID = GetCurrentProcessId) then
begin
if GlobalFindAtom(PChar(ControlAtomString)) = ControlAtom then
Result := Pointer(GetProp(Handle, MakeIntAtom(ControlAtom)))
else
Result := ObjectFromHWnd(Handle);
end;
end;
end;
...
function IsDelphiHandle(Handle: HWND): Boolean;
var
PID: DWORD;
begin
Result := False;
if Handle <> 0 then
begin
if (GetWindowThreadProcessId(Handle, @PID) <> 0) and
(PID = GetCurrentProcessId) then
begin
if GlobalFindAtom(PChar(WindowAtomString)) = WindowAtom then
Result := GetProp(Handle, MakeIntAtom(WindowAtom)) <> 0
else
Result := ObjectFromHWnd(Handle) <> nil;
end;
end;
end;
Delphi 2 〜 5
function FindControl(Handle: HWnd): TWinControl;
var
PID: DWORD;
begin
Result := nil;
if Handle <> 0 then
begin
if (GetWindowThreadProcessId(Handle, @PID) <> 0) and
(PID = GetCurrentProcessId) then
Result := Pointer(GetProp(Handle, MakeIntAtom(ControlAtom)));
end;
end;
...
function IsDelphiHandle(Handle: HWND): Boolean;
var
PID: DWORD;
begin
Result := (Handle <> 0) and
(GetWindowThreadProcessId(Handle, @PID) <> 0) and
(PID = GetCurrentProcessId) and
(GetProp(Handle, MakeIntAtom(WindowAtom)) <> 0);
end;
|
|