1 頁 (共 1 頁)

如何動態生成 form

發表於 : 2008年 11月 27日, 17:00
tim
在程式中要動態生成 form, 可以利用以下的程式碼:

代碼: 選擇全部

     
    var 
      f: Tform; 
      c: TformClass; 
    begin 
      try 
        c := TformClass(FindClass('Tform3')); 
        if c <> nil then 
        begin 
          application.Createform(c, f); 
          f.Show; 
        end; 
      except 
      end; 
    end; 
注意, 使用 FindClass 時必須在 Tform3 是有註冊過!!
也就是在 Tform3 的 Unit 中必須有
initialization
RegisterClass(Tform3);