📄 unit_global_variant.~pas
字号:
if (Copy(sDotAfter,1,1) <> '0') or
(Copy(sDotAfter,2,1) <> '0') then
begin
if (Copy(sDotAfter,1,1) = '0') and
(Copy(sDotAfter,2,1) <> '0') then
begin
sUpperAfter:='零'+ UpperNum(Copy(sDotAfter,2,1))+'分';
end
else if (Copy(sDotAfter,1,1) <> '0') and
(Copy(sDotAfter,2,1) = '0') then
begin
sUpperAfter:=UpperNum(Copy(sDotAfter,1,1))+'角';
end else
sUpperAfter:=UpperNum(Copy(sDotAfter,1,1))+'角'+
UpperNum(Copy(sDotAfter,2,1))+'分';
end else sUpperAfter := '整';
end;
end else
sUpperAfter:='整';
//合并处理结果并返回
if not bFnum then
Result:=sUpperBefore+'元'+sUpperAfter
else
Result:='负'+sUpperBefore+'元'+sUpperAfter;
end;
procedure InitPageControl(pcTemp: TPageControl);
var
i: integer;
begin
if pcTemp.Tag=1 then Exit; //???????
for i:=0 to pcTemp.PageCount-1 do
pcTemp.Pages[i].TabVisible := False;
pcTemp.ActivePageIndex := 0;
pcTemp.Tag := 1;
end;
procedure ChangeState(owner:TWinConTrol;enabled:Boolean; cl:TColor); //fjp
var
i:integer;
begin
owner.Enabled := enabled;
if enabled then
cl := cl_enabled
else
cl := cl_disabled;//$00EBEBEB;
for i := 0 to owner.ControlCount -1 do
begin
if owner.Controls[i] is TWinConTrol then //如果是TWinConTrol子类 控件
begin
TWinConTrol(owner.Controls[i]).Brush.Color := cl;
TWinConTrol(owner.Controls[i]).Refresh;
end;
if Owner.Controls[i] is TDBGridEh then TDBGridEh(Owner.Controls[i]).Color := cl;
if Owner.Controls[i] is TDBCtrlGrid then TDBCtrlGrid(Owner.Controls[i]).Color := cl;
if Owner.Controls[i] is TPanel then TPanel(Owner.Controls[i]).Color := cl;
if Owner.Controls[i] is TCustomMemo then TPanel(Owner.Controls[i]).Color := cl;
if Owner.Controls[i] is TDBRadioGroup then TPanel(Owner.Controls[i]).Color := cl;
end;
end;
function GetChineseParamStr(sName: string):string;
var
i,iLen1,iLen2: integer;
wsName, s: widestring;
begin
Result := '';
if sName='' then exit;
iLen1 := Length(sName);
wsName := widestring(sName);
iLen2 := Length(wsName);
Result := sName;
if iLen1=iLen2 then exit; //没有中文
s := '';
for i:=1 to iLen1-iLen2 do
begin
s := s + ' ';
end;
Result := sName + s; //有中文
end;
//2007.2.2 by nls 增加改变dbgrid的选中时的颜色
procedure TEventHandlers.dbGridEhDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
begin
if (State = [gdSelected, gdFocused]) or (State = [gdSelected])
or (State = [gdSelected, gdFixed]) then
begin
with (Sender as TDBGridEh) do
begin
Canvas.Brush.Color := cl_dbSelColor;
Canvas.Font.Color := clBlack;
end;
end else begin
//dbEhPerson.Canvas.Brush.Color := clWhite;
(Sender as TDBGridEh).Canvas.Font.Color := clBlack;
end;
(Sender as TDBGridEh).DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
//2007.2.2 by nls 增加改变dbgrid的选中时的颜色
procedure TEventHandlers.dbGridEhDrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if (State = [gdSelected, gdFocused]) or (State = [gdSelected])
or (State = [gdSelected,gdFixed]) then
begin
with (Sender as TDBGrid) do
begin
Canvas.Brush.Color := cl_dbSelColor;
Canvas.Font.Color := clBlack;
end;
end else begin
//dbEhPerson.Canvas.Brush.Color := clWhite;
(Sender as TDBGrid).Canvas.Font.Color := clBlack;
end;
(Sender as TDBGrid).DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
procedure TEventHandlers.DBGridEhTitleClick(Sender: TObject; ACol: Integer; Column: TColumnEh);
var
cds: TClientDataSet;
begin
if (Sender as TDBGridEh).DataSource = nil then Exit;
cds := (Sender as TDBGridEh).DataSource.DataSet as TClientDataSet;
if not cds.Active then exit; //数据集未打开.
if Column.Field.FieldKind in [fkCalculated, fkLookup, fkInternalCalc, fkAggregate] then exit; //计算字段,排序出错,故排除.
OrderGrid(cds, Column.FieldName);
end;
procedure dbGridEhDrawSelectedCellColor(dbg: TDBGridEh; State: TGridDrawState);
begin
dbg.Canvas.Font.Color := clBlack;
if (State = [gdSelected, gdFocused])
or (State = [gdSelected])
or (State = [gdSelected, gdFixed]) then
dbg.Canvas.Brush.Color := cl_dbSelColor;
end;
procedure SetInterfaceStyle(pForm: TForm);
type
iTag = set of 98..99;
jTag = set of 97..97;
var
i, j: integer;
iTagA: iTag;
jTagA: jTag;
begin
iTagA := [98, 99]; //本函数的disable标志, 99为skindata的disable标志
jTagA := [97];
for i := 0 to pForm.ComponentCount - 1 do
begin
if pForm.Components[i].ClassName = 'TMdDictEdit' then
begin
with TMdDictEdit(pForm.Components[i]) do
begin
if not (TMdDictEdit(pForm.Components[i]).Tag in iTagA) then
begin
DictGrid.FixedColor := $00EDA684;
DictGrid.Color := $00FFFBEC;
end;
end;
end;
if pForm.Components[i].ClassName = 'TMdDictDBEdit' then
begin
with TMdDictDBEdit(pForm.Components[i]) do
begin
if not (TMdDictDBEdit(pForm.Components[i]).Tag in iTagA) then
begin
DictGrid.FixedColor := $00EDA684;
DictGrid.Color := $00FFFBEC;
end;
end;
end;
if pForm.Components[i].ClassName = 'TLabel' then
begin
with TLabel(pForm.Components[i]) do
begin
if not (TLabel(pForm.Components[i]).Tag in iTagA) then
begin
Font.Color := $0085543A;
Transparent := true;
end;
end;
end;
if pForm.Components[i].ClassName = 'TEdit' then
begin
with TEdit(pForm.Components[i]) do
begin
if not (TEdit(pForm.Components[i]).Tag in iTagA) then
begin
//Font.Color := $0085543A;
//Transparent := true;
Text := '';
end;
end;
end;
if pForm.Components[i].ClassName = 'TPanel' then
begin
with TPanel(pForm.Components[i]) do
begin
if not (TPanel(pForm.Components[i]).Tag in iTagA) then
Color := $00E0F4F5; // F8FBFF 00E0F4F5
end;
end;
if pForm.Components[i].ClassName = 'TGroupBox' then
begin
with TGroupBox(pForm.Components[i]) do
begin
if not (TGroupBox(pForm.Components[i]).Tag in iTagA) then
begin
Font.Color := $0085543A;
ParentColor := true;
end;
end;
end;
if pForm.Components[i].ClassName = 'TDBGridEh' then
begin
with TDBGridEh(pForm.Components[i]) do
begin
if not (TDBGridEh(pForm.Components[i]).Tag in iTagA) then
begin
FixedColor := $00F0C0C0; //$00F0C0C0;//$00DECBBC;//$00F5EFEB; //$00F0C0C0;
Color := clWhite;
//VertScrollBar.Visible := true;
VertScrollBar.Tracking := true;
end;
for j := 0 to Columns.Count - 1 do
begin
if not (Columns[j].Tag in jTagA) then
Columns[j].Title.TitleButton := true;
end;
if not ([dghAutoSortMarking] = OptionsEh) then
OptionsEh := OptionsEh + [dghAutoSortMarking];
if @OnDrawColumnCell=nil then
OnDrawColumnCell := EvHandler.dbGridEhDrawColumnCell;
if @OnTitleBtnClick=nil then
OnTitleBtnClick := EvHandler.DBGridEhTitleClick;
end;
end;
if pForm.Components[i].ClassName = 'TDBGrid' then
begin
with TDBGrid(pForm.Components[i]) do
begin
if not (TDBGrid(pForm.Components[i]).Tag in iTagA) then
begin
FixedColor := $00F0C0C0;//$00F0C0C0; //$00F0C0C0;
Color := clWhite;
if @OnDrawColumnCell=nil then
OnDrawColumnCell := EvHandler.dbGridEhDrawColumnCell;
end;
end;
end;
end;
end;
procedure SetDictGridStyle(pDE: TMdDictEdit);
begin
pDE.DictGrid.FixedColor := $00F0C0C0; //$00EDA684;
pDE.DictGrid.Color := $00FFFBEC;
end;
procedure SetDictGridStyle(pDE: TMdDictDbEdit);
begin
pDE.DictGrid.FixedColor := $00F0C0C0; //$00EDA684;
pDE.DictGrid.Color := $00FFFBEC;
end;
procedure OrderGrid(dataSet:TClientDataset;orderField:string);
var
i:integer;
begin
if dataSet.IndexFieldNames<>'' then
begin
i := TClientDataSet(DataSet).IndexDefs.IndexOf('i'+orderField);
if i=-1 then
begin
with Dataset.IndexDefs.AddIndexDef do
begin
Name:='i'+orderField;
Fields:=orderField;
DescFields:=orderField;
end;
end;
dataSet.IndexFieldNames:='';
dataSet.IndexName:='i'+orderField;
end else begin
dataSet.IndexName:='';
dataSet.IndexFieldNames:=orderfield;
end;
dataset.First;
end;
procedure AlignFormCenter(frm: TForm);
begin
frm.Top := (Screen.Height - frm.Height) div 2;
frm.Left := (Screen.Width - frm.Width) div 2;
end;
procedure bsStartComm(sType: string); //sType = outer, inner
var
tIni: TIniFile;
begin
tIni := TIniFile.Create(ExtractFilePath(Application.ExeName) + 'set.ini');
try
if sType = 'outer' then
begin
tComOuter.CommName := tIni.ReadString('outer', 'com', 'COM2');
tComOuter.BaudRate := StrToInt(tIni.ReadString('outer', 'baud', '19200'));
bsDelay_out := StrToInt(tIni.ReadString('outer','delay','200'));
bsAddr_out := StrToInt(tIni.ReadString('outer','addr','16'));
bsActlen_out := StrToInt(tIni.ReadString('outer','actlen','10'));
bsIn_out:= StrToInt(tIni.ReadString('outer','in','7'));
bsOut_out := StrToInt(tIni.ReadString('outer','out','14'));
bsStop_out := StrToInt(tIni.ReadString('outer','stop','4'));
tComOuter.StartComm;
end;
if sType = 'inner' then
begin
tComInner.CommName := tIni.ReadString('inner', 'com', 'COM3');
tComInner.BaudRate := StrToInt(tIni.ReadString('inner', 'baud', '19200'));
bsDelay_in := StrToInt(tIni.ReadString('inner','delay','200'));
bsAddr_in := StrToInt(tIni.ReadString('inner','addr','16'));
bsActlen_in := StrToInt(tIni.ReadString('inner','actlen','10'));
bsIn_in := StrToInt(tIni.ReadString('inner','in','7'));
bsOut_in := StrToInt(tIni.ReadString('inner','out','14'));
bsStop_in := StrToInt(tIni.ReadString('inner','stop','4'));
tComInner.StartComm;
end;
finally
tIni.Free;
end;
end;
procedure bsCloseComm(sType: string); //sType = outer, inner
begin
if sType = 'outer' then
tComOuter.StopComm;
if sType = 'inner' then
tComInner.StopComm;
end;
procedure bsSendToLED(sData: string; sType: string;comm1:TComm); //sData: 显示数据
begin
if sType = 'outer' then
SendToLED(sData, bsActlen_out, bsAddr_out, bsDelay_out, bsIn_out, bsOut_out, bsStop_out,comm1);
if sType = 'inner' then
SendToLED(sData, bsActlen_in, bsAddr_in, bsDelay_in, bsIn_in, bsOut_in, bsStop_in,comm1);
end;
//actlen,条屏字数 addr屏地址,delayTime间隔时间,
//sty_in引入方式,sty_out引出方式,sty_stop停留方式);
procedure SendToLED(str: string;actlen,addr: Byte;delayTime: integer;
sty_in,sty_out,sty_stop:integer;comm1: TComm);
var
s:string;
i, j, k, sum, n, p, m, f, sbufLength,LEDStyle:integer;
sbufLED: array[0..127] of byte;
LEDShowCommand: array[0..25] of byte;
flag: Boolean;
begin
if str = '' then
Exit
else
s := str; // 字符串不能过长
LEDStyle := 2 * actlen;// 一屏显示字节数
FillChar(sbufLED, 128, 0);
FillChar(LEDShowCommand, 26, 0);
// 显示内容帧
sbufLED[0] := $FA; // 帧头
sbufLED[1] := $FA; // 帧头
sbufLED[2] := addr; // LED屏地址
sbufLED[3] := $32; // 帧类型为显示内容
sbufLED[4] := 0;//0; // 起始幕号低位
sbufLED[5] := 0;
// 显示命令帧
LEDShowCommand[0] := sbufLED[0];
LEDShowCommand[1] := sbufLED[1];
LEDShowCommand[2] := sbufLED[2];
LEDShowCommand[3] := 1; // 帧类型为显示命令
for p := 4 to 23 do
LEDShowCommand[p] := 0;
if length(s) > LEDStyle then //显示内容大于一屏
begin
sbufLED[7] := sty_in; //07;//32 * $07 + 7; // 引入方式
sbufLED[8] := sty_out; //07;//32 * $07 + 14; // 引出方式 form1.bscbboutspeed.itemindex
sbufLED[9] := sty_stop;// 04;//$04; // 停留方式
i := 1; // 字符串下标
n := 0; // 每幕字节计数器
j := 10; // 数组下标
k := 0; // 字符个数计数器
m := -1; // 幕数0~249
f := 0; // 遇$FA添加$FF的个数计数器
flag := True; // 汉字高位标志
while i <= Length(s) do
begin
if ord(s[i]) > 128 then //是汉字
begin
if flag then //汉字高位
begin
Inc(n);
if n = LEDStyle then//汉字高位遇到屏末字节,则输出前面字符串加一空格
begin
Inc(m);
sbufLED[4] := m;
Inc(k); //加空格
sbufLED[j] := 97;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -