mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
71 lines
1.4 KiB
ObjectPascal
71 lines
1.4 KiB
ObjectPascal
unit fMkDir;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
interface
|
|
|
|
uses
|
|
SysUtils, Classes, Controls, Forms, StdCtrls, Buttons;
|
|
|
|
type
|
|
|
|
{ TfrmMkDir }
|
|
|
|
TfrmMkDir = class(TForm)
|
|
cbMkDir: TComboBox;
|
|
btnOK: TBitBtn;
|
|
btnCancel: TBitBtn;
|
|
lblMakeDir: TLabel;
|
|
|
|
procedure FormKeyPress(Sender: TObject; var Key: Char);
|
|
public
|
|
function ShowMkDir(var sPath:string):Boolean; // 21.05.2009 - перенес в public
|
|
end;
|
|
|
|
var frmMkDir: TfrmMkDir; // 21.05.2009 - создаем из файла проекта
|
|
|
|
implementation
|
|
|
|
{$R *.lfm}
|
|
|
|
procedure TfrmMkDir.FormKeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
inherited;
|
|
if Key=#27 then
|
|
begin
|
|
ModalResult:=mrCancel;
|
|
Key := #0;
|
|
end
|
|
else if Key=#13 then
|
|
begin
|
|
ModalResult:=mrOK;
|
|
Key:=#0;
|
|
end;
|
|
end;
|
|
|
|
Function TfrmMkDir.ShowMkDir(var sPath:string):Boolean; var Index: Integer;
|
|
const
|
|
MAX_LINES = 20;
|
|
begin
|
|
ActiveControl := cbMkDir;
|
|
if (sPath <> '..') then
|
|
cbMkDir.Text := sPath
|
|
else
|
|
cbMkDir.Text := '';
|
|
cbMkDir.SelectAll;
|
|
Result := (ShowModal = mrOK);
|
|
sPath := cbMkDir.Text;
|
|
If Result then
|
|
begin
|
|
Index := cbMkDir.Items.IndexOf(cbMkDir.Text);
|
|
if (Index = -1) then
|
|
cbMkDir.Items.Insert(0, cbMkDir.Text)
|
|
else
|
|
cbMkDir.Items.Move(Index, 0);
|
|
|
|
if (cbMkDir.Items.Count > MAX_LINES) then
|
|
cbMkDir.Items.Delete(cbMkDir.Items.Count - 1);
|
|
end;
|
|
end;
|
|
|
|
end.
|