注册 登录
编程论坛 Delphi论坛

[求助]Delphi中窗体调用的问题

jimzzq 发布于 2006-05-05 10:13, 861 次点击
小弟刚刚开始接触Delphi,现在在进行练习中,我做一个简单的WinForm的对话框设计中碰到问题。
程序有两个简单的窗体WinForm,WinForm1。其中WinForm1被命名为AboutBox,且FormBorderStyle属性为FixedDialog,ControlBox,MinimizeBox和MaxmizeBox属性都是False。主窗体WinForm通过点击一个菜单项来调用显示WinForm1,可是在运行时主窗体的程序中老是出现不能识别AboutBox的错误,这是为什么啊??是否是主窗体在调用WinForm1的时候要在程序段中加以编写或者用uses之类的??请各位帮帮忙,我之前的练习也有过类似的毛病。
一下是两个窗体中的额部分程序段,请各位帮我看看吧。谢谢!!

报错点是:《《《《《《《----------
出错提示:undeclared identified:'AboutBox'

主窗体 WinForm:
unit WinForm;

interface

uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;

type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
MainMenu1: System.Windows.Forms.MainMenu;
mnu_about : System.Windows.Forms.MenuItem;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure mnu_About_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
............
............
procedure TWinForm.mnu_About_Click(sender: System.Object; e: System.EventArgs);
var
box : AboutBox; 《《《《《《《----------
begin
box := AboutBox.Create;
box.ShowDialog;
end;


子窗体 WinForm1:
unit WinForm1;

interface

uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data;

type
AboutBox = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
Label1: System.Windows.Forms.Label;
Button1: System.Windows.Forms.Button;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
2 回复
#2
kelehaha52006-05-05 10:31
你这贴的是什么码?~~~!!!
#3
小茶2006-05-05 17:59
检查一下你所添加的调用语句以及添加的位置是否正确,如果均正确,则点击运行后会有提示添加的语句,确定后再次运行就可以了。

语句为:aboutbox.show;
添加处:被调用窗体的菜单项点击处
1