如何通过句柄访问控件对象实例?(100分)

  • 主题发起人 主题发起人 zuoyexingchen
  • 开始时间 开始时间
Z

zuoyexingchen

Unregistered / Unconfirmed
GUEST, unregistred user!
[?]如题。
 
你只有在你的Form里搜索一下了.
function tform1.FindControlbyHandle(aHandle:HWND):TWinControl;
var
i:integer;
begin
Result := nil;
for i := 0 to self.ComponentCount - 1 do
if self.Components is TWinControl then
if TWinControl(self.Components).Handle = aHandle then
begin
Result := TWinControl(self.Components);
break;
end;
end;
 
还有其它的方法吗?
 
FindControl() 可以
var
h: DWORD;

h := FindWindow('TForm1', 'Form1');
Label1.Caption := IntToStr(FindControl(h).Width);
 
谢谢大家的指导。
 
后退
顶部