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位小数,在面试,紧急,谢谢

解决方案 »

  1.   

    这样可以,但不能处理粘贴。
    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;