unit UntObj;
interface
uses qforms,db;
type
  MyInterface = class
    procedure FrmShowModal(FrmOwner:TForm;FrmChil:TForm;rs:TDataset);
  end;
implementation
procedure  MyInterface.FrmShowModal(FrmOwner:TForm;FrmChil:TForm;rs:TDataset);
begin
  if not assigned(FrmChil) then
    FrmChil:=TForm.Create(FrmOwner);
  FrmChil.ShowModal;
  frmChil:=nil;
  FrmChil.Free;
end;
end.在另一个文件中unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;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
  MyIf:myinterface;
begin
  Myif:=myinterface.Create;
  Myif.FrmShowModal(self,FrmCompInfo,datamodule1.QueryCompInfo);
   //Incompatible types: 'TForm' and 'TFrmCompInfo'
   //Incompatible types: 'TForm' and 'TFrmMain'
  myif:=nil;
  myif.Free;
end;end.难道Tform还不能兼容TFrmMain吗?求教,希望得到指点

解决方案 »

  1.   

    'TFrmCompInfo'和'TFrmMain'是如何定义的?
      

  2.   

    TFrmCompInfo和TFrmMain都是
    TFrmCompInfo = class(TForm)
      button1 : tbutton;
      .....
    end;
    TFrmfrmmain = class(TForm)
      button1 : tbutton;
      .....
    end;
      

  3.   

    qform是包含TForm定义的unit啊。
      

  4.   

    TForm不是虚类(里面有abstract方法),需要强制转换一下:
    Myif.FrmShowModal(self,TForm(FrmCompInfo),TForm(datamodule1.QueryCompInfo));
       
      

  5.   

    哦,这个问题好象解决了,我把qForm换成forms就可以了,但是出来的不是
    TFrmcompInfo,而是一个光光的TForm,我设计的TFrmcompInfo上的控件都不见了。怎么回事啊?
      

  6.   

    qForm是用于LINUIX下的单元文件,FORMS是WINDOWS下的,WINDOWS下的控件很多是不能在LINUIX下用的,所会丢控件