mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Path edit on right mouse click
FIX: Drive menu button auto size
This commit is contained in:
parent
5201a60f3b
commit
4ad1863cd0
10 changed files with 3418 additions and 3387 deletions
|
|
@ -7,4 +7,8 @@
|
|||
13.08.2007 ADD: Сохранение и загрузку табов
|
||||
15.08.2007 ADD: Сделал корректную синхронизацию размеров панелей дисков
|
||||
15.08.2007 ADD: Сохранение состояния окна (normal, maximized)
|
||||
16.08.2007 Сделал более корректной распаковку по маске
|
||||
16.08.2007 Сделал более корректной распаковку по маске
|
||||
20.10.2007 ADD: Возможность редактирования текущего каталога, по правому щелчку мыши
|
||||
FIX: AutoSize кнопки вызова меню дисков
|
||||
UPD: При создания ссылки/символьной ссылки в качестве имени ссылки
|
||||
подставляется имя исходного файла/каталога
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
$$$*** This is unit history file ***$$$ ###encoding="UTF-8"###
|
||||
09.06.2007 Добавил возможность более детальной настройки цветов в файловой панели
|
||||
25.09.2007 ADD: Возможность отключения показа иконок
|
||||
25.09.2007 ADD: Возможность отключения показа иконок
|
||||
20.10.2007 ADD: Возможность редактирования текущего каталога, по правому щелчку мыши
|
||||
|
|
@ -7,14 +7,13 @@ inherited frmHardLink: TfrmHardLink
|
|||
HorzScrollBar.Range = 411
|
||||
VertScrollBar.Page = 155
|
||||
VertScrollBar.Range = 145
|
||||
ActiveControl = edtNew
|
||||
ActiveControl = edtDst
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'frmHardLink'
|
||||
ClientHeight = 156
|
||||
ClientWidth = 417
|
||||
KeyPreview = True
|
||||
OnKeyPress = frmHardLinkKeyPress
|
||||
Position = poMainFormCenter
|
||||
object lblNew: TLabel
|
||||
Left = 8
|
||||
|
|
@ -66,6 +65,7 @@ inherited frmHardLink: TfrmHardLink
|
|||
Top = 120
|
||||
Width = 75
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Cancel = True
|
||||
Caption = 'Cancel'
|
||||
Kind = bkCancel
|
||||
ModalResult = 2
|
||||
|
|
|
|||
158
fhardlink.pas
158
fhardlink.pas
|
|
@ -1,85 +1,73 @@
|
|||
unit fHardLink;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LResources,
|
||||
SysUtils, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, fLngForm, Buttons;
|
||||
|
||||
type
|
||||
TfrmHardLink = class(TfrmLng)
|
||||
lblNew: TLabel;
|
||||
lblDst: TLabel;
|
||||
edtNew: TEdit;
|
||||
edtDst: TEdit;
|
||||
btnOK: TBitBtn;
|
||||
btnCancel: TBitBtn;
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
procedure frmHardLinkKeyPress(Sender: TObject; var Key: Char);
|
||||
private
|
||||
{ Private declarations }
|
||||
|
||||
public
|
||||
procedure LoadLng; override;
|
||||
end;
|
||||
|
||||
procedure ShowHardLinkForm(const sNew, sDst:String);
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
uses
|
||||
uLng, uShowMsg, uOSUtils;
|
||||
|
||||
procedure ShowHardLinkForm(const sNew, sDst:String);
|
||||
begin
|
||||
with TfrmHardLink.Create(Application) do
|
||||
begin
|
||||
try
|
||||
edtDst.Text:=sDst;
|
||||
edtNew.Text:=sNew;
|
||||
ShowModal;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmHardLink.LoadLng;
|
||||
begin
|
||||
Caption:=lngGetString(clngHardLink);
|
||||
lblNew.Caption:=lngGetString(clngHardLinkDst);
|
||||
lblDst.Caption:=lngGetString(clngHardLinkNew);
|
||||
end;
|
||||
|
||||
procedure TfrmHardLink.btnOKClick(Sender: TObject);
|
||||
var
|
||||
sSrc,sDst:String;
|
||||
begin
|
||||
inherited;
|
||||
sSrc:=edtNew.Text;
|
||||
sDst:=edtDst.Text;
|
||||
if CreateHardLink(sSrc, sDst) then
|
||||
Close
|
||||
else
|
||||
begin
|
||||
MsgError(lngGetString(clngHardErrCreate));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmHardLink.frmHardLinkKeyPress(Sender: TObject; var Key: Char);
|
||||
begin
|
||||
if Key=#27 then
|
||||
ModalResult:=mrCancel;
|
||||
if Key=#13 then
|
||||
begin
|
||||
ModalResult:=mrOK;
|
||||
Key:=#0;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I fhardlink.lrs}
|
||||
end.
|
||||
unit fHardLink;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LResources,
|
||||
SysUtils, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, fLngForm, Buttons;
|
||||
|
||||
type
|
||||
TfrmHardLink = class(TfrmLng)
|
||||
lblNew: TLabel;
|
||||
lblDst: TLabel;
|
||||
edtNew: TEdit;
|
||||
edtDst: TEdit;
|
||||
btnOK: TBitBtn;
|
||||
btnCancel: TBitBtn;
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
|
||||
public
|
||||
procedure LoadLng; override;
|
||||
end;
|
||||
|
||||
procedure ShowHardLinkForm(const sNew, sDst:String);
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
uses
|
||||
uLng, uShowMsg, uOSUtils;
|
||||
|
||||
procedure ShowHardLinkForm(const sNew, sDst:String);
|
||||
begin
|
||||
with TfrmHardLink.Create(Application) do
|
||||
begin
|
||||
try
|
||||
edtDst.Text:=sDst;
|
||||
edtNew.Text:=sNew;
|
||||
ShowModal;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmHardLink.LoadLng;
|
||||
begin
|
||||
Caption:=lngGetString(clngHardLink);
|
||||
lblNew.Caption:=lngGetString(clngHardLinkDst);
|
||||
lblDst.Caption:=lngGetString(clngHardLinkNew);
|
||||
end;
|
||||
|
||||
procedure TfrmHardLink.btnOKClick(Sender: TObject);
|
||||
var
|
||||
sSrc,sDst:String;
|
||||
begin
|
||||
inherited;
|
||||
sSrc:=edtNew.Text;
|
||||
sDst:=edtDst.Text;
|
||||
if CreateHardLink(sSrc, sDst) then
|
||||
Close
|
||||
else
|
||||
begin
|
||||
MsgError(lngGetString(clngHardErrCreate));
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I fhardlink.lrs}
|
||||
end.
|
||||
|
|
|
|||
30
fmain.lfm
30
fmain.lfm
|
|
@ -1,10 +1,10 @@
|
|||
inherited frmMain: TfrmMain
|
||||
Left = 329
|
||||
Left = 248
|
||||
Height = 336
|
||||
Top = 286
|
||||
Top = 120
|
||||
Width = 540
|
||||
HorzScrollBar.Page = 539
|
||||
VertScrollBar.Page = 309
|
||||
VertScrollBar.Page = 335
|
||||
VertScrollBar.Range = 79
|
||||
ActiveControl = pnlNotebooks
|
||||
Caption = 'Double Commander'
|
||||
|
|
@ -79,35 +79,35 @@ inherited frmMain: TfrmMain
|
|||
end
|
||||
end
|
||||
object pnlNotebooks: TPanel
|
||||
Height = 234
|
||||
Height = 260
|
||||
Top = 49
|
||||
Width = 540
|
||||
Align = alClient
|
||||
ClientHeight = 234
|
||||
ClientHeight = 260
|
||||
ClientWidth = 540
|
||||
FullRepaint = False
|
||||
TabOrder = 1
|
||||
TabStop = True
|
||||
object MainSplitter: TSplitter
|
||||
Left = 171
|
||||
Height = 194
|
||||
Height = 220
|
||||
Top = 1
|
||||
Width = 4
|
||||
ResizeStyle = rsLine
|
||||
end
|
||||
object pnlLeft: TPanel
|
||||
Left = 1
|
||||
Height = 194
|
||||
Height = 220
|
||||
Top = 1
|
||||
Width = 170
|
||||
Align = alLeft
|
||||
BevelOuter = bvNone
|
||||
Caption = 'pnlLeft'
|
||||
ClientHeight = 194
|
||||
ClientHeight = 220
|
||||
ClientWidth = 170
|
||||
TabOrder = 0
|
||||
object nbLeft: TNotebook
|
||||
Height = 170
|
||||
Height = 196
|
||||
Hint = 'Left'
|
||||
Top = 24
|
||||
Width = 170
|
||||
|
|
@ -170,22 +170,23 @@ inherited frmMain: TfrmMain
|
|||
Align = alClient
|
||||
Alignment = taCenter
|
||||
ParentColor = False
|
||||
OnDblClick = lblDriveInfoDblClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pnlRight: TPanel
|
||||
Left = 175
|
||||
Height = 194
|
||||
Height = 220
|
||||
Top = 1
|
||||
Width = 364
|
||||
Align = alClient
|
||||
BevelOuter = bvNone
|
||||
Caption = 'pnlRight'
|
||||
ClientHeight = 194
|
||||
ClientHeight = 220
|
||||
ClientWidth = 364
|
||||
TabOrder = 1
|
||||
object nbRight: TNotebook
|
||||
Height = 170
|
||||
Height = 196
|
||||
Hint = 'Right'
|
||||
Top = 24
|
||||
Width = 364
|
||||
|
|
@ -248,13 +249,14 @@ inherited frmMain: TfrmMain
|
|||
Align = alClient
|
||||
Alignment = taCenter
|
||||
ParentColor = False
|
||||
OnDblClick = lblDriveInfoDblClick
|
||||
end
|
||||
end
|
||||
end
|
||||
object pnlCommand: TPanel
|
||||
Left = 1
|
||||
Height = 38
|
||||
Top = 195
|
||||
Top = 221
|
||||
Width = 538
|
||||
Align = alBottom
|
||||
Anchors = [akLeft, akRight]
|
||||
|
|
@ -301,7 +303,7 @@ inherited frmMain: TfrmMain
|
|||
end
|
||||
object pnlKeys: TPanel
|
||||
Height = 27
|
||||
Top = 283
|
||||
Top = 309
|
||||
Width = 540
|
||||
Align = alBottom
|
||||
Anchors = [akLeft, akRight]
|
||||
|
|
|
|||
|
|
@ -35,12 +35,14 @@ type
|
|||
lblLInfo: TLabel;
|
||||
pnlHeader: TPanel;
|
||||
lblLPath: TLabel;
|
||||
edtPath,
|
||||
edtRename: TEdit;
|
||||
dgPanel: TDrawGrid;
|
||||
pnAltSearch: TPanel;
|
||||
edtSearch: TEdit;
|
||||
|
||||
procedure edSearchChange(Sender: TObject);
|
||||
procedure edtPathKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure edtRenameKeyPress(Sender: TObject; var Key: Char);
|
||||
procedure dgPanelDrawCell(Sender: TObject; ACol, ARow: Integer;
|
||||
Rect: TRect; State: TGridDrawState);
|
||||
|
|
@ -378,6 +380,27 @@ begin
|
|||
// pnlFile.UpdatePanel;
|
||||
end;
|
||||
|
||||
procedure TFrameFilePanel.edtPathKeyPress(Sender: TObject;
|
||||
var Key: Char);
|
||||
begin
|
||||
if Key=#27 then
|
||||
begin
|
||||
edtPath.Visible:=False;
|
||||
SetFocus;
|
||||
end;
|
||||
if Key=#13 then
|
||||
begin
|
||||
Key:=#0; // catch the enter
|
||||
//if DirectoryExists(edtPath.Text) then
|
||||
begin
|
||||
pnlFile.ActiveDir:=edtPath.Text;
|
||||
LoadPanel;
|
||||
edtPath.Visible:=False;
|
||||
RefreshPanel;
|
||||
SetFocus;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TFrameFilePanel.edtRenameKeyPress(Sender: TObject;
|
||||
var Key: Char);
|
||||
|
|
@ -694,6 +717,10 @@ begin
|
|||
lblLPath.Width:=pnlHeader.Width - 4;
|
||||
lblLPath.Color:=clActiveCaption;
|
||||
|
||||
edtPath:=TEdit.Create(lblLPath);
|
||||
edtPath.Parent:=pnlHeader;
|
||||
edtPath.Visible:=False;
|
||||
|
||||
pnlFooter:=TPanel.Create(Self);
|
||||
pnlFooter.Parent:=Self;
|
||||
pnlFooter.Align:=alBottom;
|
||||
|
|
@ -764,7 +791,7 @@ begin
|
|||
{/Alexx2000}
|
||||
edtSearch.OnChange:=@edSearchChange;
|
||||
edtSearch.OnKeyPress:=@edSearchKeyPress;
|
||||
|
||||
edtPath.OnKeyPress:=@edtPathKeyPress;
|
||||
edtRename.OnKeyPress:=@edtRenameKeyPress;
|
||||
|
||||
pnlHeader.OnResize := @pnlHeaderResize;
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
inherited frmSymLink: TfrmSymLink
|
||||
Left = 291
|
||||
Left = 305
|
||||
Height = 136
|
||||
Top = 233
|
||||
Top = 140
|
||||
Width = 362
|
||||
HorzScrollBar.Page = 361
|
||||
HorzScrollBar.Range = 344
|
||||
VertScrollBar.Page = 135
|
||||
VertScrollBar.Range = 128
|
||||
ActiveControl = btnOK
|
||||
ActiveControl = edtDst
|
||||
BorderIcons = [biSystemMenu]
|
||||
BorderStyle = bsDialog
|
||||
Caption = 'frmSymLink'
|
||||
ClientHeight = 136
|
||||
ClientWidth = 362
|
||||
KeyPreview = True
|
||||
OnKeyPress = frmSymLinkKeyPress
|
||||
Position = poScreenCenter
|
||||
object lblNew: TLabel
|
||||
Height = 13
|
||||
|
|
@ -61,6 +60,7 @@ inherited frmSymLink: TfrmSymLink
|
|||
Top = 96
|
||||
Width = 75
|
||||
BorderSpacing.InnerBorder = 2
|
||||
Cancel = True
|
||||
Caption = 'Cancel'
|
||||
Kind = bkCancel
|
||||
ModalResult = 2
|
||||
|
|
|
|||
158
fsymlink.pas
158
fsymlink.pas
|
|
@ -1,85 +1,73 @@
|
|||
unit fSymLink;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LResources,
|
||||
SysUtils, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, fLngForm, Buttons;
|
||||
|
||||
type
|
||||
TfrmSymLink = class(TfrmLng)
|
||||
lblNew: TLabel;
|
||||
lblDst: TLabel;
|
||||
edtNew: TEdit;
|
||||
edtDst: TEdit;
|
||||
btnOK: TBitBtn;
|
||||
btnCancel: TBitBtn;
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
procedure frmSymLinkKeyPress(Sender: TObject; var Key: Char);
|
||||
private
|
||||
{ Private declarations }
|
||||
|
||||
public
|
||||
procedure LoadLng; override;
|
||||
end;
|
||||
|
||||
procedure ShowSymLinkForm(const sNew, sDst:String);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uLng, uShowMsg, uOSUtils;
|
||||
|
||||
procedure ShowSymLinkForm(const sNew, sDst:String);
|
||||
begin
|
||||
with TfrmSymLink.Create(Application) do
|
||||
begin
|
||||
try
|
||||
edtDst.Text:=sDst;
|
||||
edtNew.Text:=sNew;
|
||||
ShowModal;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmSymLink.LoadLng;
|
||||
begin
|
||||
Caption:=lngGetString(clngSymLink);
|
||||
lblNew.Caption:=lngGetString(clngSymLinkDst);
|
||||
lblDst.Caption:=lngGetString(clngSymLinkNew);
|
||||
end;
|
||||
|
||||
procedure TfrmSymLink.btnOKClick(Sender: TObject);
|
||||
var
|
||||
sSrc,sDst:String;
|
||||
begin
|
||||
inherited;
|
||||
sSrc:=edtNew.Text;
|
||||
sDst:=edtDst.Text;
|
||||
if CreateSymLink(sSrc, sDst) then
|
||||
Close
|
||||
else
|
||||
begin
|
||||
MsgError(lngGetString(clngSymErrCreate));
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmSymLink.frmSymLinkKeyPress(Sender: TObject; var Key: Char);
|
||||
begin
|
||||
if Key=#27 then
|
||||
ModalResult:=mrCancel;
|
||||
if Key=#13 then
|
||||
begin
|
||||
ModalResult:=mrOK;
|
||||
Key:=#0;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I fsymlink.lrs}
|
||||
|
||||
end.
|
||||
unit fSymLink;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
LResources,
|
||||
SysUtils, Classes, Graphics, Controls, Forms,
|
||||
Dialogs, StdCtrls, fLngForm, Buttons;
|
||||
|
||||
type
|
||||
TfrmSymLink = class(TfrmLng)
|
||||
lblNew: TLabel;
|
||||
lblDst: TLabel;
|
||||
edtNew: TEdit;
|
||||
edtDst: TEdit;
|
||||
btnOK: TBitBtn;
|
||||
btnCancel: TBitBtn;
|
||||
procedure btnOKClick(Sender: TObject);
|
||||
private
|
||||
{ Private declarations }
|
||||
|
||||
public
|
||||
procedure LoadLng; override;
|
||||
end;
|
||||
|
||||
procedure ShowSymLinkForm(const sNew, sDst:String);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
uLng, uShowMsg, uOSUtils;
|
||||
|
||||
procedure ShowSymLinkForm(const sNew, sDst:String);
|
||||
begin
|
||||
with TfrmSymLink.Create(Application) do
|
||||
begin
|
||||
try
|
||||
edtDst.Text:=sDst;
|
||||
edtNew.Text:=sNew;
|
||||
ShowModal;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TfrmSymLink.LoadLng;
|
||||
begin
|
||||
Caption:=lngGetString(clngSymLink);
|
||||
lblNew.Caption:=lngGetString(clngSymLinkDst);
|
||||
lblDst.Caption:=lngGetString(clngSymLinkNew);
|
||||
end;
|
||||
|
||||
procedure TfrmSymLink.btnOKClick(Sender: TObject);
|
||||
var
|
||||
sSrc,sDst:String;
|
||||
begin
|
||||
inherited;
|
||||
sSrc:=edtNew.Text;
|
||||
sDst:=edtDst.Text;
|
||||
if CreateSymLink(sSrc, sDst) then
|
||||
Close
|
||||
else
|
||||
begin
|
||||
MsgError(lngGetString(clngSymErrCreate));
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
{$I fsymlink.lrs}
|
||||
|
||||
end.
|
||||
|
|
|
|||
520
uShowMsg.pas
520
uShowMsg.pas
|
|
@ -1,260 +1,260 @@
|
|||
{
|
||||
Seksi Commander
|
||||
----------------------------
|
||||
Implementing of Showing messages with lokalization
|
||||
|
||||
Licence : GNU GPL v 2.0
|
||||
Author : radek.cervinka@centrum.cz
|
||||
|
||||
contributors:
|
||||
|
||||
Koblov Alexander (Alexx2000@mail.ru)
|
||||
|
||||
}
|
||||
|
||||
unit uShowMsg;
|
||||
|
||||
{$MODE Delphi}{$H+}
|
||||
|
||||
interface
|
||||
uses
|
||||
Forms, Classes;
|
||||
|
||||
type
|
||||
TMyMsgResult=(mmrOK, mmrNo, mmrYes, mmrCancel, mmrNone,
|
||||
mmrAppend, mmrRewrite, mmrRewriteAll, mmrSkip, mmrSkipAll, mmrAll );
|
||||
|
||||
TMyMsgButton=(msmbOK, msmbNO, msmbYes, msmbCancel, msmbNone,
|
||||
msmbAppend, msmbRewrite, msmbRewriteAll, msmbSkip, msmbSkipAll, msmbAll);
|
||||
|
||||
|
||||
{ TDlgOpThread }
|
||||
|
||||
TDlgOpThread = class
|
||||
private
|
||||
procedure ShowInTheThread;
|
||||
protected
|
||||
FThread : TThread;
|
||||
FMsg : String;
|
||||
FButtons: array of TMyMsgButton;
|
||||
FButDefault,
|
||||
FButEscape : TMyMsgButton;
|
||||
FDlgResult : TMyMsgResult;
|
||||
public
|
||||
constructor Create(Thread : TThread);
|
||||
destructor Destroy;override;
|
||||
function Show(const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton) : TMyMsgResult;
|
||||
end;
|
||||
|
||||
function msgYesNo(const sMsg:String):Boolean;
|
||||
function msgYesNoCancel(const sMsg:String):TMyMsgResult;
|
||||
procedure msgOK(const sMsg:String);
|
||||
|
||||
function msgWarning(const sMsg:String):Boolean;
|
||||
procedure msgError(const sMsg:String);
|
||||
|
||||
function MsgBox(const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton):TMyMsgResult;
|
||||
function MsgBoxForThread(Thread : TThread;const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton):TMyMsgResult;
|
||||
|
||||
function MsgTest:TMyMsgResult;
|
||||
procedure msgLoadLng;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils, StdCtrls, Graphics, fMsg, uLng, Buttons, Controls;
|
||||
|
||||
const
|
||||
cMsgName='Double Commander';
|
||||
|
||||
var
|
||||
cLngButton:Array[TMyMsgButton] of String;
|
||||
|
||||
{ TDlgOpThread }
|
||||
|
||||
procedure TDlgOpThread.ShowInTheThread;
|
||||
begin
|
||||
FDlgResult := MsgBox(FMsg, FButtons, FButDefault, FButEscape);
|
||||
end;
|
||||
|
||||
constructor TDlgOpThread.Create(Thread : TThread);
|
||||
begin
|
||||
FThread := Thread;
|
||||
end;
|
||||
|
||||
destructor TDlgOpThread.Destroy;
|
||||
begin
|
||||
FButtons := nil;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TDlgOpThread.Show(const sMsg: String;
|
||||
const Buttons: array of TMyMsgButton; ButDefault,
|
||||
ButEscape: TMyMsgButton) : TMyMsgResult;
|
||||
var
|
||||
I : Integer;
|
||||
begin
|
||||
FMsg := sMsg;
|
||||
|
||||
SetLength(FButtons, SizeOf(Buttons));
|
||||
for I := Low(Buttons) to High(Buttons) do
|
||||
FButtons[I] := Buttons[I];
|
||||
|
||||
FButDefault := ButDefault;
|
||||
FButEscape := ButEscape;
|
||||
|
||||
FThread.Synchronize(FThread, ShowInTheThread);
|
||||
|
||||
Result := FDlgResult;
|
||||
end;
|
||||
|
||||
{ This is workaround for autosize}
|
||||
function MeasureText(Canvas:TCanvas; const sText:String):Integer;
|
||||
var
|
||||
xEnter:Integer;
|
||||
x:Integer;
|
||||
begin
|
||||
xEnter:=Pos(#10, sText);
|
||||
if xEnter>0 then
|
||||
Result:=Canvas.TextWidth(Copy(sText,1, xEnter))
|
||||
else
|
||||
Result:=Canvas.TextWidth(sText);
|
||||
end;
|
||||
|
||||
procedure SetMsgBoxParams(var frmMsg : TfrmMsg; const sMsg:String;
|
||||
const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton);
|
||||
var
|
||||
iIndex:Integer;
|
||||
begin
|
||||
frmMsg.Position:=poScreenCenter;
|
||||
frmMsg.BorderStyle := bsSingle;
|
||||
frmMsg.BorderIcons := [biSystemMenu, biMinimize];
|
||||
|
||||
if (High(Buttons)+1)>=3 then
|
||||
frmMsg.Width:=(cButtonWith+cButtonSpace)*3+cButtonSpace
|
||||
else
|
||||
frmMsg.Width:=(cButtonWith+cButtonSpace)*(High(Buttons)+1)+cButtonSpace;
|
||||
frmMsg.Height:=(High(Buttons) div 3)*40+80;
|
||||
|
||||
|
||||
frmMsg.Caption:=cMsgName;
|
||||
with frmMsg.lblMsg do
|
||||
begin
|
||||
Caption:=sMsg;
|
||||
Top:=15;
|
||||
AutoSize:=True;
|
||||
// Anchors:=[akTop];
|
||||
Width:=MeasureText(frmMsg.Canvas, sMsg); // workaround
|
||||
if Width>frmMsg.Width then
|
||||
frmMsg.Width:=Width+2*cButtonSpace;
|
||||
Left:=(frmMsg.Width-Width) div 2;
|
||||
end;
|
||||
|
||||
for iIndex:=0 to High(Buttons) do
|
||||
begin
|
||||
With TButton.Create(frmMsg) do
|
||||
begin
|
||||
Caption:=cLngButton[Buttons[iIndex]];
|
||||
Parent:=frmMsg;
|
||||
Width:=cButtonWith;
|
||||
Height := 32;
|
||||
Tag:=iIndex;
|
||||
OnCLick:=frmMsg.ButtonClick;
|
||||
if (High(Buttons)+1)>=3 then
|
||||
Left:=(iIndex mod 3)*(cButtonWith+cButtonSpace)+(frmMsg.Width-(3*cButtonWith+2*cButtonSpace)) div 2
|
||||
else
|
||||
Left:=iIndex*(cButtonWith+cButtonSpace)+(frmMsg.Width-((High(Buttons)+1)*cButtonWith+High(Buttons)*cButtonSpace)) div 2;
|
||||
|
||||
Top:=(iIndex div 3)*(Height+5)+50;
|
||||
if Buttons[iIndex]=ButDefault then
|
||||
Default:=True;
|
||||
if Buttons[iIndex]=ButEscape then
|
||||
frmMsg.Escape:=iIndex;
|
||||
{ if iIndex=0 then
|
||||
SetFocus; }
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function MsgBox(const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton):TMyMsgResult;
|
||||
var
|
||||
frmMsg:TfrmMsg;
|
||||
begin
|
||||
frmMsg:=TfrmMsg.Create(Application);
|
||||
try
|
||||
|
||||
SetMsgBoxParams(frmMsg, sMsg, Buttons, ButDefault, ButEscape);
|
||||
|
||||
frmMsg.ShowModal;
|
||||
if (frmMsg.iSelected)=-1 then
|
||||
Result:=mmrNone
|
||||
else
|
||||
Result:=TMyMsgResult(Buttons[frmMsg.iSelected]);
|
||||
finally
|
||||
frmMsg.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function MsgBoxForThread(Thread: TThread; const sMsg: String;
|
||||
const Buttons: array of TMyMsgButton; ButDefault,
|
||||
ButEscape: TMyMsgButton): TMyMsgResult;
|
||||
var
|
||||
DlgOpThread : TDlgOpThread;
|
||||
begin
|
||||
Result := mmrNone;
|
||||
try
|
||||
DlgOpThread := TDlgOpThread.Create(Thread);
|
||||
Result := DlgOpThread.Show(sMsg, Buttons, ButDefault, ButEscape);
|
||||
finally
|
||||
DlgOpThread.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function MsgTest:TMyMsgResult;
|
||||
begin
|
||||
Result:= MsgBox('test language of msg subsystem'#10'Second line',[msmbOK, msmbNO, msmbYes, msmbCancel, msmbNone,
|
||||
msmbAppend, msmbRewrite, msmbRewriteAll],msmbOK, msmbNO);
|
||||
end;
|
||||
|
||||
function msgYesNo(const sMsg:String):Boolean;
|
||||
begin
|
||||
Result:= MsgBox(sMsg,[msmbYes, msmbNo], msmbYes, msmbNo )= mmrYes;
|
||||
end;
|
||||
|
||||
function msgYesNoCancel(const sMsg:String):TMyMsgResult;
|
||||
begin
|
||||
Result:= MsgBox(sMsg,[msmbYes, msmbNo, msmbCancel], msmbYes, msmbNo);
|
||||
end;
|
||||
|
||||
procedure msgOK(const sMsg:String);
|
||||
begin
|
||||
MsgBox(sMsg,[msmbOK],msmbOK, msmbOK);
|
||||
end;
|
||||
|
||||
procedure msgError(const sMsg:String);
|
||||
begin
|
||||
MsgBox(sMsg,[msmbOK],msmbOK, msmbOK);
|
||||
end;
|
||||
|
||||
function msgWarning(const sMsg:String):Boolean;
|
||||
begin
|
||||
Raise Exception.Create('Not implemented yet!');
|
||||
end;
|
||||
|
||||
procedure msgLoadLng;
|
||||
var
|
||||
i:TMyMsgButton;
|
||||
s:String;
|
||||
xPos:Integer;
|
||||
|
||||
begin
|
||||
s:=lngGetString(clngDlgButtons);
|
||||
for i:= Low(TMyMsgButton) to High(TMyMsgButton) do
|
||||
begin
|
||||
xPos:=Pos(';',s);
|
||||
cLngButton[i]:=Copy(s,1,xPos-1);
|
||||
Delete(s,1,xPos);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
{
|
||||
Seksi Commander
|
||||
----------------------------
|
||||
Implementing of Showing messages with lokalization
|
||||
|
||||
Licence : GNU GPL v 2.0
|
||||
Author : radek.cervinka@centrum.cz
|
||||
|
||||
contributors:
|
||||
|
||||
Koblov Alexander (Alexx2000@mail.ru)
|
||||
|
||||
}
|
||||
|
||||
unit uShowMsg;
|
||||
|
||||
{$MODE Delphi}{$H+}
|
||||
|
||||
interface
|
||||
uses
|
||||
Forms, Classes;
|
||||
|
||||
type
|
||||
TMyMsgResult=(mmrOK, mmrNo, mmrYes, mmrCancel, mmrNone,
|
||||
mmrAppend, mmrRewrite, mmrRewriteAll, mmrSkip, mmrSkipAll, mmrAll );
|
||||
|
||||
TMyMsgButton=(msmbOK, msmbNO, msmbYes, msmbCancel, msmbNone,
|
||||
msmbAppend, msmbRewrite, msmbRewriteAll, msmbSkip, msmbSkipAll, msmbAll);
|
||||
|
||||
|
||||
{ TDlgOpThread }
|
||||
|
||||
TDlgOpThread = class
|
||||
private
|
||||
procedure ShowInTheThread;
|
||||
protected
|
||||
FThread : TThread;
|
||||
FMsg : String;
|
||||
FButtons: array of TMyMsgButton;
|
||||
FButDefault,
|
||||
FButEscape : TMyMsgButton;
|
||||
FDlgResult : TMyMsgResult;
|
||||
public
|
||||
constructor Create(Thread : TThread);
|
||||
destructor Destroy;override;
|
||||
function Show(const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton) : TMyMsgResult;
|
||||
end;
|
||||
|
||||
function msgYesNo(const sMsg:String):Boolean;
|
||||
function msgYesNoCancel(const sMsg:String):TMyMsgResult;
|
||||
procedure msgOK(const sMsg:String);
|
||||
|
||||
function msgWarning(const sMsg:String):Boolean;
|
||||
procedure msgError(const sMsg:String);
|
||||
|
||||
function MsgBox(const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton):TMyMsgResult;
|
||||
function MsgBoxForThread(Thread : TThread;const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton):TMyMsgResult;
|
||||
|
||||
function MsgTest:TMyMsgResult;
|
||||
procedure msgLoadLng;
|
||||
|
||||
|
||||
implementation
|
||||
uses
|
||||
SysUtils, StdCtrls, Graphics, fMsg, uLng, Buttons, Controls;
|
||||
|
||||
const
|
||||
cMsgName='Double Commander';
|
||||
|
||||
var
|
||||
cLngButton:Array[TMyMsgButton] of String;
|
||||
|
||||
{ TDlgOpThread }
|
||||
|
||||
procedure TDlgOpThread.ShowInTheThread;
|
||||
begin
|
||||
FDlgResult := MsgBox(FMsg, FButtons, FButDefault, FButEscape);
|
||||
end;
|
||||
|
||||
constructor TDlgOpThread.Create(Thread : TThread);
|
||||
begin
|
||||
FThread := Thread;
|
||||
end;
|
||||
|
||||
destructor TDlgOpThread.Destroy;
|
||||
begin
|
||||
FButtons := nil;
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TDlgOpThread.Show(const sMsg: String;
|
||||
const Buttons: array of TMyMsgButton; ButDefault,
|
||||
ButEscape: TMyMsgButton) : TMyMsgResult;
|
||||
var
|
||||
I : Integer;
|
||||
begin
|
||||
FMsg := sMsg;
|
||||
|
||||
SetLength(FButtons, SizeOf(Buttons));
|
||||
for I := Low(Buttons) to High(Buttons) do
|
||||
FButtons[I] := Buttons[I];
|
||||
|
||||
FButDefault := ButDefault;
|
||||
FButEscape := ButEscape;
|
||||
|
||||
FThread.Synchronize(FThread, ShowInTheThread);
|
||||
|
||||
Result := FDlgResult;
|
||||
end;
|
||||
|
||||
{ This is workaround for autosize}
|
||||
function MeasureText(Canvas:TCanvas; const sText:String):Integer;
|
||||
var
|
||||
xEnter:Integer;
|
||||
x:Integer;
|
||||
begin
|
||||
xEnter:=Pos(#10, sText);
|
||||
if xEnter>0 then
|
||||
Result:=Canvas.TextWidth(Copy(sText,1, xEnter))
|
||||
else
|
||||
Result:=Canvas.TextWidth(sText);
|
||||
end;
|
||||
|
||||
procedure SetMsgBoxParams(var frmMsg : TfrmMsg; const sMsg:String;
|
||||
const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton);
|
||||
var
|
||||
iIndex:Integer;
|
||||
begin
|
||||
frmMsg.Position:=poScreenCenter;
|
||||
frmMsg.BorderStyle := bsSingle;
|
||||
frmMsg.BorderIcons := [biSystemMenu, biMinimize];
|
||||
|
||||
if (High(Buttons)+1)>=3 then
|
||||
frmMsg.Width:=(cButtonWith+cButtonSpace)*3+cButtonSpace
|
||||
else
|
||||
frmMsg.Width:=(cButtonWith+cButtonSpace)*(High(Buttons)+1)+cButtonSpace;
|
||||
frmMsg.Height:=(High(Buttons) div 3)*40+90;
|
||||
|
||||
|
||||
frmMsg.Caption:=cMsgName;
|
||||
with frmMsg.lblMsg do
|
||||
begin
|
||||
Caption:=sMsg;
|
||||
Top:=15;
|
||||
AutoSize:=True;
|
||||
// Anchors:=[akTop];
|
||||
Width:=MeasureText(frmMsg.Canvas, sMsg); // workaround
|
||||
if Width>frmMsg.Width then
|
||||
frmMsg.Width:=Width+2*cButtonSpace;
|
||||
Left:=(frmMsg.Width-Width) div 2;
|
||||
end;
|
||||
|
||||
for iIndex:=0 to High(Buttons) do
|
||||
begin
|
||||
With TButton.Create(frmMsg) do
|
||||
begin
|
||||
Caption:=cLngButton[Buttons[iIndex]];
|
||||
Parent:=frmMsg;
|
||||
Width:=cButtonWith;
|
||||
Height := 32;
|
||||
Tag:=iIndex;
|
||||
OnCLick:=frmMsg.ButtonClick;
|
||||
if (High(Buttons)+1)>=3 then
|
||||
Left:=(iIndex mod 3)*(cButtonWith+cButtonSpace)+(frmMsg.Width-(3*cButtonWith+2*cButtonSpace)) div 2
|
||||
else
|
||||
Left:=iIndex*(cButtonWith+cButtonSpace)+(frmMsg.Width-((High(Buttons)+1)*cButtonWith+High(Buttons)*cButtonSpace)) div 2;
|
||||
|
||||
Top:=(iIndex div 3)*(Height+5)+50;
|
||||
if Buttons[iIndex]=ButDefault then
|
||||
Default:=True;
|
||||
if Buttons[iIndex]=ButEscape then
|
||||
frmMsg.Escape:=iIndex;
|
||||
{ if iIndex=0 then
|
||||
SetFocus; }
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function MsgBox(const sMsg:String; const Buttons: array of TMyMsgButton; ButDefault, ButEscape:TMyMsgButton):TMyMsgResult;
|
||||
var
|
||||
frmMsg:TfrmMsg;
|
||||
begin
|
||||
frmMsg:=TfrmMsg.Create(Application);
|
||||
try
|
||||
|
||||
SetMsgBoxParams(frmMsg, sMsg, Buttons, ButDefault, ButEscape);
|
||||
|
||||
frmMsg.ShowModal;
|
||||
if (frmMsg.iSelected)=-1 then
|
||||
Result:=mmrNone
|
||||
else
|
||||
Result:=TMyMsgResult(Buttons[frmMsg.iSelected]);
|
||||
finally
|
||||
frmMsg.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function MsgBoxForThread(Thread: TThread; const sMsg: String;
|
||||
const Buttons: array of TMyMsgButton; ButDefault,
|
||||
ButEscape: TMyMsgButton): TMyMsgResult;
|
||||
var
|
||||
DlgOpThread : TDlgOpThread;
|
||||
begin
|
||||
Result := mmrNone;
|
||||
try
|
||||
DlgOpThread := TDlgOpThread.Create(Thread);
|
||||
Result := DlgOpThread.Show(sMsg, Buttons, ButDefault, ButEscape);
|
||||
finally
|
||||
DlgOpThread.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
Function MsgTest:TMyMsgResult;
|
||||
begin
|
||||
Result:= MsgBox('test language of msg subsystem'#10'Second line',[msmbOK, msmbNO, msmbYes, msmbCancel, msmbNone,
|
||||
msmbAppend, msmbRewrite, msmbRewriteAll],msmbOK, msmbNO);
|
||||
end;
|
||||
|
||||
function msgYesNo(const sMsg:String):Boolean;
|
||||
begin
|
||||
Result:= MsgBox(sMsg,[msmbYes, msmbNo], msmbYes, msmbNo )= mmrYes;
|
||||
end;
|
||||
|
||||
function msgYesNoCancel(const sMsg:String):TMyMsgResult;
|
||||
begin
|
||||
Result:= MsgBox(sMsg,[msmbYes, msmbNo, msmbCancel], msmbYes, msmbNo);
|
||||
end;
|
||||
|
||||
procedure msgOK(const sMsg:String);
|
||||
begin
|
||||
MsgBox(sMsg,[msmbOK],msmbOK, msmbOK);
|
||||
end;
|
||||
|
||||
procedure msgError(const sMsg:String);
|
||||
begin
|
||||
MsgBox(sMsg,[msmbOK],msmbOK, msmbOK);
|
||||
end;
|
||||
|
||||
function msgWarning(const sMsg:String):Boolean;
|
||||
begin
|
||||
Raise Exception.Create('Not implemented yet!');
|
||||
end;
|
||||
|
||||
procedure msgLoadLng;
|
||||
var
|
||||
i:TMyMsgButton;
|
||||
s:String;
|
||||
xPos:Integer;
|
||||
|
||||
begin
|
||||
s:=lngGetString(clngDlgButtons);
|
||||
for i:= Low(TMyMsgButton) to High(TMyMsgButton) do
|
||||
begin
|
||||
xPos:=Pos(';',s);
|
||||
cLngButton[i]:=Copy(s,1,xPos-1);
|
||||
Delete(s,1,xPos);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue