现在的位置: 首页 > 综合 > 正文

Delphi中判断控件的详细类型

2014年01月11日 ⁄ 综合 ⁄ 共 261字 ⁄ 字号 评论关闭

var
  t:TFrmMain;
begin
  if(self is TForm) then
  begin
    if(self.ClassType=tform) then
    begin
            ShowMessage('tform');
    end
    else if(self.classtype=TFrmMain) then
    begin
      ShowMessage('tform1');
    end;
  end;

end;

delphi中的is运算符可以判断对象是否继承自某一个类,classtype可以判断具体是哪个类。

抱歉!评论已关闭.