求助

fangpengyu 2009-05-05 03:29:27
procedure TfrmMain.mnu3_001Click(Sender: TObject);
var
count:double;
begin

if (frmMain.MDIChildCount >= 1) then exit;
if not User_Checked then
exit;

if (not IsCreatedForm('frmW_001')) then //若是尚未开启此画面
begin
Application.CreateForm(TfrmW_001,frmW_001); //建立将开启的画面

end
else //此画面先前已开启
frmW_001.Show; //SHOW出画面
end;

function TfrmMain.IsCreatedForm(psFormName: string): boolean; //检查画面是否已开启
var
i: integer;
begin
result := false;
for i := MDIChildCount-1 downto 0 do
if MDIChildren[i].Name = psFormName then
begin
result := true;
exit;
end;
end;

怎样控制frmW_001窗体内输入框输入小数,并且保留3位小数,在面试,紧急,谢谢
...全文
63 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
taxi 2009-05-06
  • 打赏
  • 举报
回复
这样可以,但不能处理粘贴。
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
var
i: Integer;
begin
if not (Key in ['0'..'9', #8, '.']) then
Key := #0;

i := Pos('.', Edit1.Text);
if (Key = '.') and (i > 0) then
Key := #0;

if (Key = '.') and (Length(Copy(Edit1.Text, Edit1.SelStart + 1, Length(Edit1.Text))) > 3) then
Key := #0;

if (i > 0) and (Key <> #8) and (Length(Copy(Edit1.Text, i + 1, 3)) = 3) then
Key := #0;
end;

16,749

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧