第一个界面的代码:
unit OuvasA;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, ExtCtrls, Grids, DBGrids, ToolWin, ActnMan,
  ActnCtrls, jpeg, Buttons;type
  TForm1 = class(TForm)
    stat1: TStatusBar;
    lblTimeShow: TLabel;
    pnl2: TPanel;
    lbl9: TLabel;
    lbl8: TLabel;
    lblA: TLabel;
    lbl11: TLabel;
    lblB: TLabel;
    lbl10: TLabel;
    dbgrdPast: TDBGrid;
    edtInput: TEdit;
    img1: TImage;
    lbl1: TLabel;
    lblName: TLabel;
    pnl1: TPanel;
    lbl7: TLabel;
    dbgrdFresh: TDBGrid;
    lbl: TLabel;
    lblSex: TLabel;
    lbl3: TLabel;
    lblid: TLabel;
    lblToTime: TLabel;
    img2: TImage;
    Image1: TImage;
    img3: TImage;
    btn1: TSpeedButton;
    btn2: TSpeedButton;
    lbl2: TLabel;
    lbl4: TLabel;
    img4: TImage;
    img5: TImage;
    img6: TImage;
    btnAnew: TButton;
    procedure FormShow(Sender: TObject);
    procedure btnAnewClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation
uses UnitCheck;{$R *.dfm}
procedure TForm1.FormShow(Sender: TObject);
var
   sysTime:TSystemTime;
begin
  //窗体加载的时候显示时间
  GetSystemTime(sysTime);
  lblTimeShow.Caption:=IntToStr(sysTime.wYear)+'-'+IntToStr(sysTime.wMonth) +'-'+IntToStr(sysTime.wDay);
  //窗体加载时显示排药药师
  stat1.Panels[1].Text:='java';
  //窗体加载初始化新到患者的字体颜色显示
  lblName.Font.Color:=clWhite;
  lblSex.Font.Color:=clWhite;
  lbl.Font.Color:=clWhite;
  lbl3.Font.color:=clWhite;
  lblid.Font.Color:=clWhite;
  lblToTime.Font.Color:=clWhite;end;procedure TForm1.btnAnewClick(Sender: TObject);
begin
  ForCheck.ShowModal;//重新打印按钮
end;end.
第二个界面的代码:unit UnitCheck;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, jpeg, Buttons, ComCtrls;type
  TForCheck = class(TForm)
    edtID: TEdit;
    dbgrd1: TDBGrid;
    lbl2: TLabel;
    img1: TImage;
    img2: TImage;
    lbl3: TLabel;
    img3: TImage;
    lblName: TLabel;
    lblSex: TLabel;
    lbl: TLabel;
    lblid: TLabel;
    img4: TImage;
    btn1: TSpeedButton;
    stat1: TStatusBar;
    lbl1: TLabel;
    dbgrd2: TDBGrid;
    btnOK: TButton;
    btnAdd: TButton;
    procedure FormShow(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  ForCheck: TForCheck;implementation
uses UnitAdd;{$R *.dfm}procedure TForCheck.FormShow(Sender: TObject);
 var
 sysTime:TSystemTime;
begin
  GetSystemTime(sysTime);
  stat1.Panels[1].Text:='java';//显示药师姓名
  stat1.Panels[3].Text:='null';//显示药师工号
  stat1.Panels[5].Text:='null';//显示药师今日排药
  stat1.Panels[7].Text:=IntToStr(sysTime.wYear)+'年'+IntToStr(sysTime.wMonth)+'月'+IntToStr(sysTime.wDay)
  +'日'+'--'+IntToStr(sysTime.wHour)+'时'+IntToStr(sysTime.wMinute)+'分';//显示当前时间   //窗体加载初始化新到患者的字体颜色显示
  lblName.Font.Color:=clWhite;
  lblSex.Font.Color:=clWhite;
  lbl.Font.Color:=clWhite;
  lblid.Font.color:=clWhite;
end;procedure TForCheck.btnAddClick(Sender: TObject);
begin
  ForAdd.ShowModal;
end;end.东西运行后,第一个窗体是好的,但是当我点击重新打印后想要预览第二个窗体的时候就会弹出改错误.而且重启也没有效,这个错误阻扰我的模块进程好多天了

解决方案 »

  1.   

    直接点击"btnAnew" 过都过不去  还调个什么试乐   郁闷呢  烦死了
      

  2.   

    ForCheck是不是没有创建,你就用了,Application.CreateForm(TForCheck, ForCheck);
      

  3.   

    创建了啊,而且开始都可以运行的,不过后来我来开始设计界面后就删除了一些check事件啊.后来又重新注册后就运行成这样了
      

  4.   

    打断点跟踪一下,Address都是0的话,应该是使用了没有创建的对象~
      

  5.   

    TForCheck.FormShow 这个事件能进去吗??
    你窗口的FormStyle是什么?
      

  6.   

    这个事件当然能进啦   初始化的时间什么的都可以显示的  就是当我点击重新打印按钮就会弹出上图中的错误
       formstyle是默认的啊 我也没有动它 
      

  7.   

    我说的不是TForm1.FormShow,是procedure TForCheck.FormShow(Sender: TObject);这个事件
    你点击重新打印按钮,执行的是
    ForCheck.ShowModal;//重新打印按钮下面的事件设置断点,看看会在什么地方出错:
    procedure TForCheck.FormShow(Sender: TObject);
     var
     sysTime:TSystemTime;
    begin
      GetSystemTime(sysTime);
      stat1.Panels[1].Text:='java';//显示药师姓名
      stat1.Panels[3].Text:='null';//显示药师工号
      stat1.Panels[5].Text:='null';//显示药师今日排药
      stat1.Panels[7].Text:=IntToStr(sysTime.wYear)+'年'+IntToStr(sysTime.wMonth)+'月'+IntToStr(sysTime.wDay)
      +'日'+'--'+IntToStr(sysTime.wHour)+'时'+IntToStr(sysTime.wMinute)+'分';//显示当前时间  //窗体加载初始化新到患者的字体颜色显示
      lblName.Font.Color:=clWhite;
      lblSex.Font.Color:=clWhite;
      lbl.Font.Color:=clWhite;
      lblid.Font.color:=clWhite;
    end;