📄 sopendialog.pas
字号:
end
else begin
for i := 0 to Owner.Files.Count - 1 do begin
if FileNameEdit.Text = '' then FileNameEdit.Text := '"' + ExtractFileName(Owner.Files[i]) + '"' else FileNameEdit.Text := FileNameEdit.Text + ' "' + ExtractFileName(Owner.Files[i]) + '"';
end;
if FileNameEdit.Text <> '' then Owner.FileName := {DriveComboBox.Path + }Owner.Files[0];
end;
end
else if Assigned(FileListView.Selected) and FileListView.Folders[FileListView.Selected.Index].IsFile(FileListView.Folders[FileListView.Selected.Index].PathName, OpenZipFiles) then begin
Owner.FileName := FileListView.Folders[FileListView.Selected.Index].PathName;
FileNameEdit.Text := ExtractFileName(FileListView.Folders[FileListView.Selected.Index].PathName);
end;
TsSkinOpenDialog(Owner).DoSelectionChange;
end;
procedure TsOpenDialogForm.KindBtnClick(Sender: TObject);
begin
case FileListView.ViewStyle of
vsList: Icons1.OnClick(Icons1);
vsReport: Icons2.OnClick(Icons2);
vsIcon: List1.OnClick(List1);
end;
end;
procedure TsOpenDialogForm.UpBtnClick(Sender: TObject);
begin
FileListView.Back;
// FolderChanged;
end;
procedure TsOpenDialogForm.FormDestroy(Sender: TObject);
begin
FreeAndNil(HistList);
end;
procedure TsOpenDialogForm.BackBtnClick(Sender: TObject);
var
S: string;
begin
if HistList.Count < 2 then Exit;
Returning := True;
S := HistList[HistList.Count - 2];
if DriveComboBox.Path <> S then begin
DeleteHistMenu(HistMenu.Items[HistList.Count - 1]);
HistMenu.Items[HistList.Count - 1].Visible := False;
DriveComboBox.Path := S;
if Assigned(FileListView) then FileListView.TreeUpdate(DriveComboBox.Folders[DriveComboBox.ItemIndex].AbsoluteID);
BackBtn.Enabled := HistList.Count > 1;
end;
Returning := False;
end;
procedure TsOpenDialogForm.FormCreate(Sender: TObject);
begin
InitLngCaptions;
DriveComboBox.ObjectTypes := DriveComboBox.ObjectTypes + [otHidden];
if HistList <> nil then HistList.Clear;
// BackBtn.Enabled := False;
Returning := False;
// FileTypeBox.BoundLabel.Caption := LoadDlg32Msg(386); // 'file type'
FileListView.Anchors := FileListView.Anchors + [akRight, akBottom];
sButton1.Anchors := [akRight, akBottom];
sButton2.Anchors := [akRight, akBottom];
BtnHelp.Anchors := [akRight, akBottom];
FileNameEdit.Anchors := [akLeft, akRight, akBottom];
FileTypeBox.Anchors := [akLeft, akRight, akBottom];
CheckBoxReadOnly.Anchors := [akLeft, akBottom];
end;
procedure TsOpenDialogForm.AddNewHist(S: string);
var
mi: TMenuItem;
begin
if HistList.Count > 0 then HistMenu.Items[HistList.Count - 1].Visible := True;
HistList.Add(S);
mi := TMenuItem.Create(Self);
mi.Caption := S;
mi.OnClick := OnHistClick;
mi.Visible := False;
sSkinProvider1.SkinData.SkinManager.SkinableMenus.HookPopupMenu(HistMenu, True);
HistMenu.Items.Add(mi);
end;
procedure TsOpenDialogForm.DeleteHistMenu(MenuItem: TMenuItem);
begin
HistList.Delete(MenuItem.MenuIndex);
HistMenu.Items.Delete(MenuItem.MenuIndex);
end;
procedure TsOpenDialogForm.OnHistClick(Sender: TObject);
var
S: string;
begin
Returning := True;
S := DelChars(TMenuItem(Sender).Caption, '&');
if DriveComboBox.Path <> S then begin
DriveComboBox.Path := S;
if Assigned(FileListView) then FileListView.TreeUpdate(DriveComboBox.Folders[DriveComboBox.ItemIndex].AbsoluteID);
// DeleteHistMenu(TMenuItem(Sender));
// BackBtn.Enabled := HistList.Count > 0;
end;
Returning := False;
end;
procedure TsOpenDialogForm.FileTypeBoxChange(Sender: TObject);
begin
if not FileListView.Updating then begin
FileListView.Mask := FileTypeBox.Mask;
if Assigned(Owner) and Assigned(Owner.OnTypeChange) then Owner.OnTypeChange(Self);
end;
end;
procedure TsOpenDialogForm.FormShow(Sender: TObject);
begin
if Assigned(Owner) and Assigned(Owner.OnShow) then Owner.OnShow(Self);
if FileListViewWidth <> 0 then begin
FileListView.Width := FileListViewWidth;
sButton1.Left := FileListView.Left + FileListView.Width - sButton1.Width;
sButton2.Left := sButton1.Left;
BtnHelp.Left := sButton1.Left;
FileNameEdit.Width := sButton1.Left - FileNameEdit.Left - 8;
FileTypeBox.Width := FileNameEdit.Width;
end;
FolderChanged;
// sButton1.Anchors := [akRight, akBottom];
// sButton2.Anchors := [akRight, akBottom];
// BtnHelp.Anchors := [akRight, akBottom];
// FileNameEdit.Anchors := [akRight, akBottom, akLeft];
// FileTypeBox.Anchors := [akRight, akBottom, akLeft];
end;
procedure TsOpenDialogForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if Assigned(Owner) and Assigned(Owner.OnClose) then Owner.OnClose(Self);
end;
procedure TsOpenDialogForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if Assigned(Owner) and Assigned(Owner.OnCanClose) then Owner.OnCanClose(Self, CanClose);
end;
procedure TsOpenDialogForm.CreateDirBtnClick(Sender: TObject);
begin
FileListView.MakeNewFolder;
end;
procedure TsOpenDialogForm.BtnHelpClick(Sender: TObject);
begin
Application.HelpContext(Owner.Helpcontext);
end;
constructor TsOpenDialogForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FileListViewWidth := 0;
end;
procedure TsOpenDialogForm.Smallicons1Click(Sender: TObject);
begin
FileListView.ViewStyle := vsSmallIcon;
List1.Checked := False;
Icons1.Checked := False;
Icons2.Checked := False;
SmallIcons1.Checked := True;
end;
procedure TsOpenDialogForm.FileListViewDblClick(Sender: TObject);
begin
if Assigned(FileListView.Selected) then begin
if FileListView.Folders[FileListView.Selected.Index].IsFolder(FileListView.Folders[FileListView.Selected.Index].PathName, OpenZipFiles)
then FileListView.SetPathFromID(FileListView.Folders[FileListView.Selected.Index].AbsoluteID)
else sButton1.Click
end
end;
procedure TsOpenDialogForm.DriveComboBoxChange(Sender: TObject);
begin
FolderChanged;
end;
procedure TsOpenDialogForm.FolderChanged;
begin
AddPathToHistory(DriveComboBox.Path);
UpBtn.Enabled := DriveComboBox.ItemIndex <> 0;
BackBtn.Enabled := (HistList <> nil) and (HistList.Count > 1);
Returning := False;
if Assigned(Owner) and Assigned(Owner.OnFolderChange) then Owner.OnFolderChange(Self);
end;
procedure TsOpenDialogForm.AddPathToHistory(Path: string);
begin
if not Returning and DirectoryExists(Path) then begin
if HistList = nil then HistList := TStringList.Create else if (HistList.Count > 0) and (HistList[HistList.Count - 1] = Path) then Exit;
AddNewHist(Path);
end;
end;
{function TsOpenDialogForm.NeedOpenZipFile(FileListView: TsDlgShellListView): Boolean;
begin
Result := not OpenZipFiles and (LowerCase(ExtractFileExt(FileListView.Folders[FileListView.Selected.Index].PathName)) = '.zip')
end;}
procedure TsOpenDialogForm.InitLngCaptions;
begin
DriveComboBox.BoundLabel.Caption := LoadStr(s_Folder);
FileNameEdit.BoundLabel.Caption := LoadStr(s_FileName);
FileTypeBox.BoundLabel.Caption := LoadStr(s_FileType);
CheckBoxReadOnly.Caption := LoadStr(s_ReadOnly);
sButton2.Caption := LoadStr(s_MsgDlgCancel);
BtnHelp.Caption := LoadStr(s_MsgDlgHelp);
List1.Caption := LoadStr(s_ViewStyleList);
Icons1.Caption := LoadStr(s_ViewStyleReport);
Icons2.Caption := LoadStr(s_ViewStyleIcons);
SmallIcons1.Caption := LoadStr(s_ViewStyleSmallIcons);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -