文件拷貝
這四個菜單項共用一個Click事件處理過程
共用的事件處理過程FileChange的程序清單如下
procedure TFMForm
var
ChangeForm: TChangeForm;
IsFile: Boolean;
begin
ChangeForm := TchangeForm
IsFile := True;
with ChangeForm do
begin
if Sender = Move
else if Sender = Copy
else if Sender = Rename
else if Sender = ChangeDirectory
begin
Caption:=
IsFile:=False;
end
else Exit;
if IsFile then
begin
CurrentDir
FromFileName
ToFileName
end
else
begin
CurrentDir
FromFileName
ToFileName
end;
if (ShowModal <> idCancel) and (ToFileName
ConfirmChange(Caption
end;
end;
其中用到的自定義私有過程ConfirmChange用於執行相應的動作
procedure TFMForm
begin
if MessageDlg(Format(
mtConfirmation
begin
if ACaption =
MoveFile(FromFile
else if ACaption =
CopyFile(FromFile
else if ACaption =
RenameFile(FromFile
else if ACaption =
changeDirectory(ToFile)
FileList
end;
end;
當程序執行Properties 菜單項的Click 事件處理過程時
當用戶修改並確認後程序重新設置文件屬性
Properties菜單項的Click事件處理過程如下
procedure TFMForm
var
Attributes
FileAttrForm: TFileAttrForm;
begin
FileAttrForm := TFileAttrForm
ShowFileAttr(FileAttrForm
end;
其中過程ShowFileAttr的實現如下
procedure TFMForm
AFileName
var
Attributes
begin
with FileAttrForm do
begin
FileName
FilePath
ChangeDate
Attributes := FileGetAttr(AFileName)
ReadOnly
Archive
System
Hidden
if ShowModal <> idCancel then
begin
NewAttributes := Attributes;
if ReadOnly
else NewAttributes := NewAttributes and not faReadOnly;
if Archive
else NewAttributes := NewAttributes and not faArchive;
if System
else NewAttributes := NewAttributes and not faSysFile;
if Hidden
else NewAttributes := NewAttributes and not faHidden;
if NewAttributes <> Attributes then
FileSetAttr(AFileName
end;
end;
end;
以上過程中用到的函數FileDataTime在fmxutils單元中定義
function FileDateTime(const FileName: String)
begin
Result := FileDateToDateTime(FileAge(FileName))
end;
在子窗口的Function菜單中
● Search :查找一個給定名字的文件
● Disk View :顯示當前驅動器的大小和剩余空間
● View type :確定顯示文件的類型
當用戶單擊Search菜單項時
在實現這一功能的最初設計中
[
From:http://tw.wingwit.com/Article/program/Delphi/201311/25233.html