相用以下语句获得用户录入的时间。
if InputQuery('设置时间','时间为10、12、15、20、30、60',TempStr) then
begin
...
end;
可是对话框上却只能看到前面五个数,看到不最后的那个“、60”.
最后没办法,只好在60后面再加上"、10" 这样才能看到、60,而新加的10自然还是看不到。
请问这种忽略最后一小节的数字是什么原因呢?、
多谢,一定给分!
if InputQuery('设置时间','时间为10、12、15、20、30、60',TempStr) then
begin
...
end;
可是对话框上却只能看到前面五个数,看到不最后的那个“、60”.
最后没办法,只好在60后面再加上"、10" 这样才能看到、60,而新加的10自然还是看不到。
请问这种忽略最后一小节的数字是什么原因呢?、
多谢,一定给分!
可行的解决方法:在后面加空格,好像空格数等于用的汉字数
我用的是delphi 6。0 , 打过两个补丁,win200.没有你提出的类似问题。
你看看InputQuery的源码就知道了,InputQuery创建的Lable的最大长度和文本框一样,并且是wordwarp,长度超出后会自动折行的。
下面是部分源码
Form := TForm.Create(Application);
with Form do
try
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
再看看GetAveCharSize函数,
for I := 0 to 25 do Buffer[I] := Chr(I + Ord('A'));
for I := 0 to 25 do Buffer[I + 26] := Chr(I + Ord('a'));
GetTextExtentPoint(Canvas.Handle, Buffer, 52, TSize(Result));
只计算了大小写字母的平均大小,
GetTextExtentPoint is provided for compatibility with 16-bit versions of Windows. Win32-based applications should call the GetTextExtentPoint32 function, which provides more accurate results.
可能是在你的环境下计算字符大小出了问题。
(我用的是delphi6中文企业版,没有打补丁,也找不到补丁!)
您是让我把哪个东东拷过来啊?这个LABEL是INPUTQUERY自动产生的,我如何能改得动呢?
你好,请问空格应加在哪儿?是不是加在数字序列的最后?
var Value: string): Boolean;
var
Form: TForm;
Prompt: TLabel;
Edit: TEdit;
DialogUnits: TPoint;
ButtonTop, ButtonWidth, ButtonHeight: Integer;
begin
Result := False;
Form := TForm.Create(Application);
with Form do
try
Canvas.Font := Font;
DialogUnits := GetAveCharSize(Canvas);
BorderStyle := bsDialog;
Caption := ACaption;
ClientWidth := MulDiv(180, DialogUnits.X, 4);
ClientHeight := MulDiv(63, DialogUnits.Y, 8);
Position := poScreenCenter;
Prompt := TLabel.Create(Form);
with Prompt do
begin
Parent := Form;
AutoSize := True;
Left := MulDiv(8, DialogUnits.X, 4);
Top := MulDiv(8, DialogUnits.Y, 8);
Caption := APrompt;
end;
Edit := TEdit.Create(Form);
with Edit do
begin
Parent := Form;
Left := Prompt.Left;
Top := MulDiv(19, DialogUnits.Y, 8);
Width := MulDiv(164, DialogUnits.X, 4);
MaxLength := 255;
Text := Value;
SelectAll;
end;
ButtonTop := MulDiv(41, DialogUnits.Y, 8);
ButtonWidth := MulDiv(50, DialogUnits.X, 4);
ButtonHeight := MulDiv(14, DialogUnits.Y, 8);
with TButton.Create(Form) do
begin
Parent := Form;
Caption := SMsgDlgOK;
ModalResult := mrOk;
Default := True;
SetBounds(MulDiv(38, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
with TButton.Create(Form) do
begin
Parent := Form;
Caption := SMsgDlgCancel;
ModalResult := mrCancel;
Cancel := True;
SetBounds(MulDiv(92, DialogUnits.X, 4), ButtonTop, ButtonWidth,
ButtonHeight);
end;
if ShowModal = mrOk then
begin
Value := Edit.Text;
Result := True;
end;
finally
Form.Free;
end;
end;