问题如题,请高手帮忙啊 !

解决方案 »

  1.   

    unit Unit1;//这是类定义单元interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TFormPop = class(TForm)
        Button1,Button2:TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
       Constructor Create(Owner:TComponent);Override;
        { Public declarations }
      end;implementationprocedure TFormPop.Button1Click(Sender: TObject);
    begin
      showmessage('hi1');
    end;procedure TFormPop.Button2Click(Sender: TObject);
    begin
       showmessage('hi2');
    end;constructor TFormPop.Create(Owner:TComponent);
    begin
      inherited Create(nil);
      caption:='主程序标题';
      Button1.Top:=20;
      Button1.Height:=35;
      Button1.Width:=50;
      Button1.Left:=15;
      Button2.top:=40;
      Button2.Height:=35;
      Button2.Width:=50;
      Button2.Left:=100;
      Button1.Caption:='OK';
      Button2.Caption:='Cancel';end;
    end.
    unit Unit2;//引用类的单元interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls,unit1;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var
    form2:TFormPop;
    begin
      form2:=TFormPop.Create(nil);
      form2.ShowModal;
    end;end.
      

  2.   

    不要在接口引用unit1,改为在implementation下面引用:
    implementation
    uses unit1;
      

  3.   

    呵呵,你的TFormPop 没有Form的资源文件哈{$R *.dfm}加上去就可以了implementation 后面
      

  4.   

    错错错!我没看清!!!你的unit1根本就不是一个窗体单元!!!
      

  5.   

    因为Delphi的VCL设计是采用分离PASCAL源代码和DELPHI窗体资源的设计,也就是.PAS和.dfm文件
      

  6.   

    哦 是的 
    unit1就是单独的.pas文件,
    那自定义的.dfm文件怎么写?
      

  7.   

    不是自定义, 看看你的代码,你的Button从哪来的? 没有看到你的任何创建过程。所以我看你的TFormPop是通过IDE创建来的,而你又去掉了TFormPop的.dfm,所以就出现你这个错误
      

  8.   

    我是单独新建了1个unit型文件,所以没有.dfm
    那么创建带有窗体控件的类该怎么样定义呢?
      

  9.   

    原来是整个.pas和.dfm就是1个大类,小弟初学受教了!