📄 rm_fmted.pas
字号:
{*****************************************}
{ }
{ Report Machine v2.0 }
{ Format editor }
{ }
{*****************************************}
unit RM_fmted;
interface
{$I RM.inc}
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ExtCtrls;
type
TRMFmtForm = class(TForm)
btnOK: TButton;
btnCancel: TButton;
GroupBox2: TGroupBox;
Label3: TLabel;
Label1: TLabel;
Label2: TLabel;
lstCat: TListBox;
lstType: TListBox;
edtForamt: TEdit;
edtDec: TEdit;
edtSpl: TEdit;
procedure edtSplEnter(Sender: TObject);
procedure lstCatClick(Sender: TObject);
procedure lstTypeClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure lstTypeDblClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure ShowPanels;
procedure Localize;
public
{ Public declarations }
Format: Integer;
FormatStr: String;
end;
implementation
{$R *.DFM}
uses RM_Class, RM_Utils, RM_const, RM_Const1;
const
CategCount = 5;
procedure TRMFmtForm.Localize;
begin
Font.Name := RMLoadStr(SRMDefaultFontName);
Font.Size := StrToInt(RMLoadStr(SRMDefaultFontSize));
Font.Charset := StrToInt(RMLoadStr(SCharset));
Caption := RMLoadStr(rmRes + 420);
Label1.Caption := RMLoadStr(rmRes + 422);
Label2.Caption := RMLoadStr(rmRes + 423);
Label3.Caption := RMLoadStr(rmRes + 424);
btnOK.Caption := RMLoadStr(SOk);
btnCancel.Caption := RMLoadStr(SCancel);
end;
{$WARNINGS OFF}
procedure TRMFmtForm.FormShow(Sender: TObject);
var
i: Integer;
begin
lstCat.Items.Clear;
for i := 0 to CategCount - 1 do
lstCat.Items.Add(RMLoadStr(SCateg1 + i));
lstCat.ItemIndex := (Format and $0F000000) div $01000000;
lstCatClick(nil);
lstType.ItemIndex := (Format and $00FF0000) div $00010000;
ShowPanels;
end;
procedure TRMFmtForm.FormClose(Sender: TObject; var Action: TCloseAction);
var
c: Char;
begin
if ModalResult = mrOk then
begin
Format := lstCat.ItemIndex * $01000000 + lstType.ItemIndex * $00010000 +
StrToIntDef(edtDec.Text, 0) * $00000100;
c := ',';
if edtSpl.Text <> '' then
c := edtSpl.Text[1];
Format := Format + Ord(c);
if edtForamt.Enabled then
FormatStr := edtForamt.Text;
end;
end;
procedure TRMFmtForm.ShowPanels;
begin
RMEnableControls([Label1, Label2, edtDec, edtSpl], lstCat.ItemIndex = 1);
if edtDec.Enabled then
begin
edtDec.Text := IntToStr((Format and $0000FF00) div $00000100);
edtSpl.Text := Chr(Format and $000000FF);
end
else
begin
edtDec.Text := '';
edtSpl.Text := '';
end;
RMEnableControls([Label3, edtForamt], lstType.ItemIndex = lstType.Items.Count -1 );
if edtForamt.Enabled then
edtForamt.Text := FormatStr
else
edtForamt.Text := '';
end;
procedure TRMFmtForm.lstCatClick(Sender: TObject);
var
i: Integer;
begin
lstType.Items.Clear;
case lstCat.ItemIndex of
0: // 字符型
begin
lstType.Items.Add(RMLoadStr(SFormat11));
end;
1: // 数字型
begin
for i := 0 to RMFormatNumCount do
lstType.Items.Add(RMLoadStr(SFormat21 + i));
end;
2: // 日期型
begin
for i := 0 to RMFormatDateCount do
lstType.Items.Add(RMLoadStr(SFormat31 + i));
end;
3: // 时间型
begin
for i := 0 to RMFormatTimeCount do
lstType.Items.Add(RMLoadStr(SFormat41 + i));
end;
4: // 逻辑型
begin
for i := 0 to RMFormatBooleanCount do
lstType.Items.Add(RMLoadStr(SFormat51 + i));
end;
end;
lstType.ItemIndex := 0;
lstTypeClick(nil);
end;
procedure TRMFmtForm.lstTypeClick(Sender: TObject);
begin
ShowPanels;
end;
procedure TRMFmtForm.edtSplEnter(Sender: TObject);
begin
edtSpl.SelectAll;
end;
{$WARNINGS ON}
procedure TRMFmtForm.lstTypeDblClick(Sender: TObject);
begin
if lstType.ItemIndex >= 0 then
btnOK.Click;
end;
procedure TRMFmtForm.FormCreate(Sender: TObject);
begin
Localize;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -