相用以下语句获得用户录入的时间。
if InputQuery('设置时间','时间为10、12、15、20、30、60',TempStr) then 
begin
...
end;
可是对话框上却只能看到前面五个数,看到不最后的那个“、60”.
最后没办法,只好在60后面再加上"、10"  这样才能看到、60,而新加的10自然还是看不到。
请问这种忽略最后一小节的数字是什么原因呢?、
多谢,一定给分!

解决方案 »

  1.   

    可能是delphi处理汉字跟数字混合的问题,如果用英文加数字没有问题
    可行的解决方法:在后面加空格,好像空格数等于用的汉字数
      

  2.   

    这是Label对中文的支持问题,你在Form上丢几个Label,写上中文,然后运行,很多时候中文都显示不完整的
      

  3.   

    你可以把那个函数考过来,然后把TLabel改成TStaticText,那就可以显示中文和普通字符混合的字符串了
      

  4.   

    你用得delphi 那个版本?打补丁了吗?
    我用的是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. 
    可能是在你的环境下计算字符大小出了问题。
      

  5.   

    怪事,今天又可以正常显示了。我后面加的尾巴都尴尬地显示出来了,真是莫名其妙呢!这又是为何?
    (我用的是delphi6中文企业版,没有打补丁,也找不到补丁!)
      

  6.   

    to :imustworkhard(一切为了生存)
    您是让我把哪个东东拷过来啊?这个LABEL是INPUTQUERY自动产生的,我如何能改得动呢?
      

  7.   

    to jackie168(花好月圓):
    你好,请问空格应加在哪儿?是不是加在数字序列的最后?
      

  8.   

    自己去改VCL,或者在后面加空格,多加点。
      

  9.   

    function InputQuery(const ACaption, APrompt: string;
      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;
      

  10.   

    inputquery函数中的 OK和CANCEL按钮怎么变成中文啊?