📄 ufunsys.~pas
字号:
if Currcon.Visible = false then exit;
CurrGrid.Text:=CurrCon.text;
CurrCon.Hide;
end;
procedure MyConExit(var CurrCon:TComboBox;var CurrGrid:TMsFlexGrid);overload;
begin
if Currcon.Visible = false then exit;
CurrGrid.Text:=CurrCon.text;
CurrCon.Hide;
end;
procedure MyConExit(var CurrCon:TDateTimePicker;var CurrGrid:TMsFlexGrid);overload;
begin
if Currcon.Visible = false then exit;
CurrGrid.Text:=FormatDateTime('YYYY-MM-DD',CurrCon.DateTime);
CurrCon.Hide;
end;
{*******************************************************************************
// 绑定控件的KEYDOW 事件
// ===============网格中最重要的函数=================
*******************************************************************************}
procedure FZReturnCol(var Key:Word;
WinControl11:TObject;
bRowEnabled,bLetAddRow:boolean;
MsFlexGrid1:TMsFlexGrid;
Const EditColList:array of TGridColCon);
var
I,J,iCol,X:integer;
iFixRow,iMaxEditRow:integer;
bNextRow:boolean;
WinControl1:TWinControl;
begin
iFixRow:=1;
iMaxEditRow:=MsFlexGrid1.Rows-2;
bNextRow:=False;
wincontrol1:=(wincontrol11 as TWinControl);
case KEY of
VK_RETURN:
begin
KEY:=0;
MsFlexGrid1.setFocus;
iCol:=MsFlexGrid1.Col;
i:=iCol+1;
while (not EditColList[i].bEdit)and(i<>iCol) do begin
if i>=MsFlexGrid1.Cols-1 then begin
i:=-1;
bNextRow:=True;
end;
i:=i+1;
end;
wincontrol1.Visible:=False;
if (bRowEnabled)and(bNextRow) then begin
if (MsFlexGrid1.Row>=iMaxEditRow)and bLetAddRow then begin
MsFlexGrid1.Rows:=MsFlexGrid1.Rows+1;
for iCol:=0 to MsFlexGrid1.Cols-1 do begin
MsFlexGrid1.TextMatrix[MsFlexGrid1.Row+1,iCol]:='';
end;
end;
MsFlexGrid1.Row:=MsFlexGrid1.Row+1;
MsFlexGrid1.SetFocus;
MsFlexGrid1.Col:=i;
end
else
if i <= MsFlexGrid1.Cols-1 then
MsFlexGrid1.Col:=i;
end;
VK_UP:
begin
if (Not bRowEnabled) then Exit;
if wincontrol1 is TCustomComboBox then
if (wincontrol1 as TCustomComboBox).ItemIndex >=1 then Exit;
KEY:=0;
MsFlexGrid1.setFocus;
i := MsFlexGrid1.Row;
x := 0;
while (x <= MsFlexGrid1.Cols-2)
and((MsFlexGrid1.TextMatrix[i,x] = '')or
(MsFlexGrid1.TextMatrix[i,x]='0')or(MsFlexGrid1.TextMatrix[i,x]='0.00')
or(MsFlexGrid1.TextMatrix[i,x]='0.0')or(MsFlexGrid1.TextMatrix[i,x]='0.0000'))
do
x := x + 1;
if (MsFlexGrid1.TextMatrix[i,x] = '') and (x>=MsFlexGrid1.Cols-1)
and(MsFlexGrid1.Rows >3) then
MsFlexGrid1.RemoveItem(MsFlexGrid1.Row);
wincontrol1.Visible:=False;
if (i>=iFixRow+1)and bRowEnabled then MsFlexGrid1.Row:=i-1;
end;
VK_DOWN:
begin
if (not bRowEnabled) then Exit;
if wincontrol1 is TCustomComboBox then
if (wincontrol1 as TCustomComboBox).ItemIndex+1 <(wincontrol1 as TCustomComboBox).items.count then
Exit;
KEY:=0;
MsFlexGrid1.setFocus;
i:=MsFlexGrid1.Row;
wincontrol1.Visible:=False;
if (bRowEnabled)and(MsFlexGrid1.Row>=iMaxEditRow)and bLetAddRow then begin
MsFlexGrid1.Rows:=MsFlexGrid1.Rows+1;
for iCol:=0 to MsFlexGrid1.Cols-1 do
begin
MsFlexGrid1.TextMatrix[MsFlexGrid1.Row+1,iCol]:='';
end;
iMaxEditRow:=iMaxEditRow+1;
j:=0;
while (not EditColList[j].bEdit)and(j<>MsFlexGrid1.Col) do begin
if j>=MsFlexGrid1.Cols-1 then
begin
j:=-1;
end;
j:=j+1;
end;
MsFlexGrid1.setFocus;
MsFlexGrid1.Col:=j;
end;
if i<=iMaxEditRow-1 then begin
MsFlexGrid1.setFocus;
MsFlexGrid1.Row:=i+1;
end;
end;
VK_Left:
begin
if WinControl1 is TDateTimePicker then
Exit;
if MsFlexGrid1.Col <= MsFlexGrid1.FixedCols then
exit;
if Wincontrol1 is TCustomEdit then
begin
KEY:=0;
if (Wincontrol1 as TCustomEdit).SelStart=0 then
begin
MsFlexGrid1.setFocus;
iCol:=MsFlexGrid1.Col;
i:=iCol-1;
while (not EditColList[i].bEdit)and(i<>iCol) do
begin
if i<=0 then
begin
i:=MsFlexGrid1.Cols;
end;
i:=i-1;
end;
(Wincontrol1 as TCustomEdit).Visible:=False;
MsFlexGrid1.Col:=i;
end
else (Wincontrol1 as TCustomEdit).SelStart
:=(Wincontrol1 as TCustomEdit).SelStart-1;
exit;
end;//
if wincontrol1 is TCustomComboBox then
begin
KEY:=0;
if (wincontrol1 as TCustomComboBox).SelStart=0 then
begin
MsFlexGrid1.setFocus;
iCol:=MsFlexGrid1.Col;
i:=iCol-1;
while (not EditColList[i].bEdit)and(i<>iCol) do
begin
if i<=0 then
begin
i:=MsFlexGrid1.Cols-1;
end;
i:=i-1;
end;
(wincontrol1 as TCustomComboBox).Visible:=False;
if i<>iCol then
MsFlexGrid1.Col:=i;
end
else (wincontrol1 as TCustomComboBox).SelStart
:=(wincontrol1 as TCustomComboBox).SelStart-1;
exit;
end;
end;
VK_Right:
begin
if WinControl1 is TDateTimePicker then
Exit;
if wincontrol1 is TCustomComboBox then
begin
// KEY:=0;
if (Wincontrol1 as TCustomComboBox).SelStart
=(Wincontrol1 as TCustomComboBox).GetTextLen then
begin
MsFlexGrid1.setFocus;
iCol:=MsFlexGrid1.Col;
i:=iCol+1;
while (not EditColList[i].bEdit)and(i<>iCol) do
begin
if i>=MsFlexGrid1.Cols-1 then
begin
i:=-1;
end;
i:=i+1;
end;
(Wincontrol1 as TCustomComboBox).Visible:=False;
MsFlexGrid1.Col:=i;
end
else
if (Wincontrol1 as TCustomComboBox).SelLength
=(Wincontrol1 as TCustomComboBox).GetTextLen then
(Wincontrol1 as TCustomComboBox).SelStart
:=(Wincontrol1 as TCustomComboBox).GetTextLen
else (Wincontrol1 as TCustomComboBox).SelStart
:=(Wincontrol1 as TCustomComboBox).SelStart+1;
exit;
end;
// KEY:=0;
if (Wincontrol1 as TCustomEdit).SelStart
=(Wincontrol1 as TCustomEdit).GetTextLen then
begin
KEY:=0;
MsFlexGrid1.setFocus;
iCol:=MsFlexGrid1.Col;
i:=iCol+1;
while (not EditColList[i].bEdit)and(i<>iCol) do
begin
if i>=MsFlexGrid1.Cols-1 then
begin
i:=-1;
end;
i:=i+1;
end;
(Wincontrol1 as TCustomEdit).Visible:=False;
MsFlexGrid1.Col:=i;
end
else
if (Wincontrol1 as TCustomEdit).SelLength
=(Wincontrol1 as TCustomEdit).GetTextLen then
(Wincontrol1 as TCustomEdit).SelStart
:=(Wincontrol1 as TCustomEdit).GetTextLen
else
(Wincontrol1 as TCustomEdit).SelStart
:=(Wincontrol1 as TCustomEdit).SelStart+1;
end;
end;
end;
{******************************************************************************
此函数是将TEdit控件限制成浮点数输入框
Digits 指小数的位数
******************************************************************************}
function MyEnterNumberA(var EditName: TEdit; Key: Char;Digits:Integer):Char;
begin
Result := key;
if Key in ['0'..'9','.','-',#8,#13,#161] then
with EditName do begin
if Key=#161 then begin
Key := '.';
Result := '.';
end;
if (Key='.')and(Digits<=0) then begin
Result:=#0;
exit;
end;
if pos('.',Text)=1 then begin
Text:='0'+Text;
SelStart:=Length(Text);
exit;
end;
if (length(text)>=Digits+2)and(not (Key in [#8,#13]))
and(pos('.',Text)<>0)and(SelStart>=pos('.',Text)) then
begin
if (pos('.',Text))<=(length(text)-Digits) then begin
Result:=#0;
exit;
end;
end;
if Key='-' then
if (Pos('-',Text)>0) or (SelStart<>0) then
Result := #0;
if Key = '.' then begin
if Pos('.',Text) <> 0 then //有小数点
Result := #0;
end;
end
else Result := #0;
end;
{******************** var EditName: TComboBox *********************************}
function MyEnterNumberC(var EditName: TComboBox; Key: Char;Digits:Integer):Char;
begin
Result := key;
if Key in ['0'..'9','.','-',#8,#13,#161] then
with EditName do begin
if Key=#161 then begin
Key := '.';
Result := '.';
end;
if (Key='.')and(Digits<=0) then begin
Result:=#0;
exit;
end;
if pos('.',Text)=1 then begin
Text:='0'+Text;
SelStart:=Length(Text);
exit;
end;
if (length(text)>=Digits+2)and(not (Key in [#8,#13]))
and(pos('.',Text)<>0)and(SelStart>=pos('.',Text)) then
begin
if (pos('.',Text))<=(length(text)-Digits) then begin
Result:=#0;
exit;
end;
end;
if Key='-' then
if (Pos('-',Text)>0) or (SelStart<>0) then
Result := #0;
if Key = '.' then begin
if Pos('.',Text) <> 0 then //有小数点
Result := #0;
end;
end
else Result := #0;
end;
{*******************************************************************************
用来输入限定长度的整数
*******************************************************************************}
function MyEnterNumberB(var Edit1:TEdit;Key:Char;iLength:Integer):Char;
begin
if Key in [#27,#37,#38,#39,#40,#8,#35,#36,#46] then
begin
Result:=Key;
Exit;
end;
if (Key = '0') and (Edit1.Text='') then
begin
Result:=#0;
Exit;
end;
if Length(Edit1.text) >= iLength then
begin
Result:=#0;
Exit;
end;
if Key in ['0'..'9'] then
begin
Result:=Key;
Exit;
end;
Result:=#0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -