动态建立了N个窗体,在程序里如何找到这些窗体并对其进行操作?
如何知道当前建立了多少个动态窗体?
是用遍历还是什么方法?

解决方案 »

  1.   

    如何知道当前建立了多少个动态窗体?
    是用遍历还是什么方法?
    ----------------------
    用FindComponent,As操作符,遍历
      

  2.   

    建议你先学C或PASCAL,学得差不多了再来学DELPHI.
      

  3.   

    TO:ahjoe(强哥)
    不要太打击想上进的小弟嘛。
      

  4.   

    可以用windowsAPI的函数EnumWindows遍历所有窗口然后再在EnumWindows中使用EnumChildWindows遍历所有的子窗口得到所有窗口(父窗口和子窗口)的句柄,注意上述两个函数的返回值都是枚举型的  使用Enumwindows你可以不指定起始窗口,而让程序遍历windows内存中所有的窗口,也可以指定起始窗口遍历,灵活运用
      

  5.   

    findcomponent 有局限性,只能遍历属于你指定的窗体的从tcomponent继承来的控件  ,对于父窗体的遍历则做不到
      

  6.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      i : integer;
      j : integer;//¼Ç¼form Êý
    begin
      j:=0; //记录窗体数 Parent为主窗体
      for i:=0 to Form1.ComponentCount-1 do  //
      begin
        if (Form1.Components[i] is Tform) then
          inc(j);
      end;
      showmessage(inttostr(j));end;
      

  7.   

    朋友,你说的是MDI里的窗体吗?
      

  8.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      i : integer;
      j : integer;//¼Ç¼form Êý
    begin
      j:=0; //记录窗体数 Parent为主窗体
      for i:=0 to Form1.ComponentCount-1 do  //
      begin
        if (Form1.Components[i] is Tform) then
          inc(j);
      end;
      showmessage(inttostr(j));end;只能遍历属于form1的子窗体
      

  9.   

    不是MDI,就是普通的窗体。
    如果用数组保存对象指针应该怎样写?
      

  10.   

    var
      i: integer;
    begin
      for i = 0 to Screen.FormCount - 1 do
        showmessage(Screen.Forms[I].Name);
    end;