0
我正在創建一個使用Tnt組件(Compenents with unicode)的Delphi 2007應用程序。 我有一種形式:對thouse組件使用TEdit和TUpDown與聯合
edit : TTntEdit;
updown : TTntUpDown
設置:
edit.OnKeyPressed := edKeyPress;
edit.OnKExit := edExit;
updown.Max := 900;
updown.Min := 300;
updown.Assosiate := edit;
updown.onClick := updownClick;
procedure TForm.edKeyPress(Sender: TObject;
var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SetValue(edit, updown, some_global_variable);
end;
end;
procedure TForm.edExit(Sender: TObject);
begin
SetValue(edit, updown, some_global_variable);
end;
procedure TForm.SetValue(ED: tTntEdit;UD: tUpDown;var CardValue: real);
var
rVal : real;
begin
if MainForm.CheckRealStr(ED.Text,rVal,'.') or
MainForm.CheckRealStr(ED.Text,rVal,',') then
begin
if rVal <= (UD.Min/10) then rVal := (UD.Min/10);
if rVal >= (UD.Max/10) then rVal := (UD.Max/10);
CardValue := rVal;
UD.Position := Round(CardValue*10);
ED.Text := FormatFloat('0.0', UD.Position/10);
end
else
ED.Text := FormatFloat('0.0', UD.Position/10);
end;
procedure TForm.updownClick(Sender: TObject;
Button: TUDBtnType);
begin
edit.Text := FormatFloat('0.0', updown.Position/10);
end;
正如你所看到的,增減的可能有300和900之間的位置,這就是意味着edit.Text是從' 30.0'至'90,0'。 如果文字設置爲89.8,我們使用向上箭頭來增加它的位置,那麼編輯中的文字會改變如下:'89.9' - >'90.0' - >'900'並截取。當edit.text從'90 .0'變爲'900'時,甚至不會調用updownClick事件!
因此,這裏是我的問題:
- 爲什麼值 '900' 出現;
- 爲什麼updownClick事件沒有被調用;
非常感謝,幫助!當然,我不需要2位數字的tnt,我只是因爲項目中有許多其他(tnt)組件 - 編輯,組合框,標籤等等,才使用它們。 –