确实是exit1click没有定义吗?(200分)

  • 主题发起人 主题发起人 flyman5
  • 开始时间 开始时间
F

flyman5

Unregistered / Unconfirmed
GUEST, unregistred user!
我按照《Delphi 2.0高级程序设计指南》教程编写一文件管理程序的
子窗口程序部分如下:
unit fileext1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Tabs, Menus, ExtCtrls, FileCtrl, StdCtrls;

type
TFMForm = class(TForm)
DriveTabSet: TTabSet;
DirectoryListBox1: TDirectoryListBox;
FileListBox1: TFileListBox;
Image1: TImage;
Image2: TImage;
Image3: TImage;
MainMenu1: TMainMenu;
File1: TMenuItem;
Function1: TMenuItem;
Directory1: TMenuItem;
Exit11: TMenuItem;
procedure FormClose(Sender: TObject
var Action: TCloseAction);
procedure FormCloseQuery(Sender: TObject
var CanClose: Boolean);
procedure Exit1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure DriveTabSetClick(Sender: TObject);
procedure DirectoryListBox1Change(Sender: TObject);
procedure DriveTabSetMeasureTab(Sender: TObject
Index: Integer;
var TabWidth: Integer);
procedure DriveTabSetDrawTab(Sender: TObject
TabCanvas: TCanvas;
R: TRect
Index: Integer
Selected: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FMForm: TFMForm;

implementation

uses filemana;

{$R *.DFM}

var
ExitClick: Boolean;

procedure TFMForm.FormClose(Sender: TObject
var Action: TCloseAction);
begin
Action := OnFree;
end;

procedure TFMForm.FormCloseQuery(Sender: TObject
var CanClose: Boolean);
begin
If (FileManager.MDIChildCount <= 1) and (Not ExitClick) then
CanClose := False;
end;

procedure TFMForm.Exit1Click(Sender: TObject);
begin
ExitClick := True;
FileMana.Exit1Click(Sender);
end;

procedure TFMForm.FormCreate(Sender: TObject);
var
Drive, AddedIndex: Integer;
DriveLetter: Char;
begin
FileMana := TFMForm.Create(Application);
for Drive := 0 to 25 do
begin
DriveLetter := Chr(Drive + ord('a'));
case GetDrivetype(Drive) of
DRIVE_REMOVABLE:
AddedIndex := DriveTabSet.Tabs.AddObject(DriveLetter, Floppy.Picture.Graphic);
DRIVE_FIXED:
AddedIndex := DriveTabSet.Tabs.AddObject(DriveLetter, Fixed.Picture.Graphic);
DRIVE_REMOTE:
AddedIndex := DriveTabSet.Tabs.AddObject(DriveLetter, Network.Picture.Graphic);
end;
if UpCase(DriveLetter) = UpCase(FileListbox1.Drive) then
DriveTabSet.TAbIndex := AddedIndex;
end;
end;

procedure TFMForm.DriveTabSetClick(Sender: TObject);
begin
With DriveTabSet do
DirectoryListBox1.Drive := Tabs[TabIndex][1];

end;

procedure TFMForm.DirectoryListBox1Change(Sender: TObject);
begin
FileListBox1.Directory := DirectoryListBox1.Directory;
FileListBox1.Update;
end;

procedure TFMForm.DriveTabSetMeasureTab(Sender: TObject
Index: Integer;
var TabWidth: Integer);
var
BitmapWidth: Integer;
begin
BitmapWidth := TBitmap(DriveTabSet.Tabs.Objects[Index]).Width;
Inc(TabWidth, 2 + BitmapWidth);
end;

procedure TFMForm.DriveTabSetDrawTab(Sender: TObject
TabCanvas: TCanvas;
R: TRect
Index: Integer
Selected: Boolean);
var
Bitmap: TBitmap;
begin
Bitmap := TBitmap(DriveTabSet.Tabs.Objects[Index]);
with TabCanvas do
begin
Draw(R.Left, R.Top + 4, Bitmap);
TextOut(R.Left + 2 + Bitmap.Width, R.Top + 2, DriveTabSet.Tabs[Index]);
end;
end;

end.
其中filemana是主程序,FMform是子窗口。运行以上程序显示未声明变量(unclared identifier:'exit1click')。
教程是这样阐述的:
我们需要判断发出关闭消息的是子窗口的系统菜单还是菜单的Exit项。
定义一个全局变量
var
ExitClick: Boolean;
在子窗口的Exit1Click事件处理过程中:
ExitClick := True;
FileManager.Exit1Click(Sender);
子窗口关闭前可以利用这一全局变量检测是否应关闭:
我开始未在filemana的菜单项file中加入exit子菜单项并单击它,后加入它并单击它(filemana
中加入exit1click),但都同样显示以上提示信息。
后来根据一位大侠的建议,在主窗口中将
FileManager.Exit1Click(Sender);
定义为public成员(无法单击filemana的菜单项file中的exit子菜单,
在filemana的type后加入Exit1Click过程),
结果依然显示以上提示信息。
请问各位大侠这是什么原因,该如何解决?
 
这句是做什么的:
FileMana := TFMForm.Create(Application);
FileMana又是从哪来的? 看不明白啊!
 
接受答案了.
 
后退
顶部