小编Rob*_*edy的帖子

为什么DrawText只打印字符串的前四个字符?

我有Canvas DrawText的问题,我从我想要显示的文本中得到了前4个字符.

例如,我有文本'离线'它将显示'offl'.

这段代码有什么不对.

代码

procedure TStatusCombo.Paint ;
var DrawRect : TRect ;
    StatusColor : TColor ;
    iTextWidth : Integer ;
    r : TRect ;
begin
DrawRect := ClientRect ;

//colors
Canvas.Brush.Style := bsClear ; //transparent background
Canvas.Brush.Color := Tcolor($4D4D4D) ;
Canvas.Pen.Color :=  Tcolor($4D4D4D)   ;

Canvas.RoundRect(DrawRect.Left , DrawRect.Top ,
            DrawRect.Right , DrawRect.Bottom , 15, 15);

//Drawing
//SetRect(DrawRect, DrawRect.Left+3, DrawRect.Top+3, DrawRect.Right-3, DrawRect.Bottom-3);

case ChatStatus of
  sNormal: StatusColor  :=   TColor($00FF78) ;
  sOnline: StatusColor  :=   TColor($00FF78) ;
  sBusy: StatusColor  :=   TColor($00FF78) ;
  sAway: …
Run Code Online (Sandbox Code Playgroud)

delphi

0
推荐指数
1
解决办法
247
查看次数

为什么我的算法反转字符值在存储在Delphi XE2 ShortString中时不起作用?

我有以下代码:

user_s.username := EnDecrypt(Edit_username.Text);
Run Code Online (Sandbox Code Playgroud)

功能如下:

function EnDeCrypt(const Value : String) : String;
 var
 CharIndex : integer;
begin
 Result := Value;
 for CharIndex := 1 to Length(Value) do
Result[CharIndex] := chr(not(ord(Value[CharIndex])));
end;
Run Code Online (Sandbox Code Playgroud)

变量的类型是:

TUser = record
 access: char;
 username: string[25];
 password: string[25];
end;
Run Code Online (Sandbox Code Playgroud)

在Delphi 2007中它可以工作,在Delphi XE2中它失败了.奇怪的是,如果它是123456789,它会很好地加密/解密密码.这个问题必须与unicode和shortstring的使用有关.我希望有一些方法可以让它在Delphi XE2中运行..

delphi unicode

0
推荐指数
1
解决办法
347
查看次数

如何防止滚轮选择TStringGrid的最后一行?

我有一个包含多行的TStringGrid,其中我实现了某种"只读"行.更准确地说,我不允许用户点击倒数第二行.如果用户点击最后一行,则没有任何反应; 焦点不会移动到该行的单元格.

我有代码(在KeyDown中),一切顺利.但是,如果用户单击顶行然后使用鼠标滚轮向下滚动,最终焦点将移动到倒数第二行.知道如何防止这种情况吗?

delphi scrollwheel tstringgrid

0
推荐指数
1
解决办法
3286
查看次数

如何调试堆栈溢出?

我想知道是否有人有类似的经历.我试图追查问题的根源,但我想出的是零.我在Delphi 5中有一个项目,它有Report Builder报告.我需要一个reportbuilder的升级版本,所以我尝试在Delphi 7中运行该项目.当我的项目运行时,我点击一个按钮来查看报告,它看起来很好.但是,如果我使用paramstr运行报告(showmainform设置为false)并显示报告过程运行,则会出现堆栈溢出错误.

原始代码是:

 if lowercase(ParamStr(1)) = 'termsexceeded' then begin
    reportsdata.termsexceeded.close;
    reportsdata.termsexceeded.open;
    reports.ppTermsExceeded.print;
    reportsdata.termsexceeded.close;
    application.terminate;
  end; 
Run Code Online (Sandbox Code Playgroud)

它给了我.print函数的堆栈溢出错误.

在Delphi 7中运行的代码是:

 if lowercase(ParamStr(1)) = 'termsexceeded' then begin
    reportsdata.termsexceeded.close;
    reportsdata.termsexceeded.open;
    reports.left := -10000;
    reports.show;
    reports.ppTermsExceeded.print;
    reportsdata.termsexceeded.close;
    application.terminate;
  end; 
Run Code Online (Sandbox Code Playgroud)

是否有人建议我如何调试这个以查看问题出在我的Delphi 7或Reportbuilder上?

报告表单的.show事件中没有事件.

任何有关如何深入了解这一点的建议都将受到赞赏.

问候

stack-overflow delphi reportbuilder delphi-7 delphi-5

0
推荐指数
1
解决办法
325
查看次数

将 int 转换为十六进制格式 0xyy c#

我需要编写一个函数,它接收一个类型int(十进制)的参数,并返回string包含十六进制 int 值,但格式为 0xyy
不仅如此,我还希望答案采用 4 字节的固定格式,例如:

int b = 358;
string ans = function(b); 
Run Code Online (Sandbox Code Playgroud)

在这种情况下 ans = "0x00 0x00 0x01 0x66"

int a = 3567846; 
string ans = function(a);
Run Code Online (Sandbox Code Playgroud)

在这种情况下 ans = "0x00 0x36 0x70 0xE6"

c# hex

0
推荐指数
1
解决办法
3158
查看次数

如何在Delphi中安装Chromium包?

我从http://code.google.com/p/delphichromiumembedded/下载了必要的TortoiseSVN,但我不知道如何在Delphi XE2中使用它.如何安装TChromium组件?

delphi chromium delphi-xe2 tchromium

0
推荐指数
1
解决办法
7208
查看次数

使用两个With语句

首先,我在onselect期间使用了combobox1 fill combobox2.我开始了很长的路,见下文.

    procedure TFGetZoneDept.ComboBox1Select(Sender: TObject);
begin
  Combobox2.Clear;
  with Combobox1 do
  begin
      if text = '3' then
      begin
        with combobox2 do
        begin
          Add('Zone 3 depts');
          Add('Zone 3 depts');
          Add('Zone 3 depts');
          Add('Zone 3 depts');
          Add('Zone 3 depts');
          Add('Zone 3 depts');
        end;   {with combobox2}
      end;  {If }
      if text = '4' then
      begin
        with ComboBox2 do
        begin
          add('Zone 4 depts');
          add('Zone 4 depts');
          add('Zone 4 depts');
          add('Zone 4 depts');
          add('Zone 4 depts)';
        end;{combobox2 with}
      end;{IF}
      if text ='1' then
      begin
        with …
Run Code Online (Sandbox Code Playgroud)

delphi with-statement

0
推荐指数
1
解决办法
172
查看次数

如何在字符串消息中包含XML中的数据?

我有这样的XML:

<SPPROFILES>
         <----DATA------>
         <PROFILES>
                  <PROFILE>
                           <ID>--------------</ID>
                           <NAME>------------</NAME>
                           <USERNAME>-----------</USERNAME>
                  </PROFILE>
          </PROFILES>
</SPPROFILES>
Run Code Online (Sandbox Code Playgroud)

我想从XML获取用户名并显示它.

这是代码的一部分:

SFailedHMConnection = 'Could not connect to default database with username "-------".';
Run Code Online (Sandbox Code Playgroud)

用户名后面的"------"应该显示XML中的用户名,那么如何从XML中获取值并将其包含在消息中呢?

xml delphi

0
推荐指数
1
解决办法
536
查看次数

使用嵌套循环,循环变量以什么顺序递增?

我有一个关于如何在Delphi中填充矩阵的问题?在哪个方式和哪个行和列第一个econd和哪个数字后跟哪个数字在Delphi中的顺序是什么?你能帮忙澄清一下吗?详情如下:

我有5x5 Matrix,数字1到5,代码如下:

for i := 1 to 5 do
   for j := 1 to 5 do
       x[i, j] := i + j;
Run Code Online (Sandbox Code Playgroud)

x [2,2]和x [1,1]等位置会是什么?填充矩阵的顺序是什么?用哪种方法?什么行和列填充第一,第二,第三等?谢谢您的回答.

delphi for-loop position matrix cycle

0
推荐指数
2
解决办法
2356
查看次数

如何从字符串中删除空格?

我想从字符串值中删除空格.例如,sString := 'Hello my name is Bob应该成为sString := 'HellomynameisBob.

我尝试使用while循环:

iPos := pos(' ', sString);
while iPos > 0 do
Delete(sString,iPos,1);
Run Code Online (Sandbox Code Playgroud)

但程序只是冻结了.

delphi string

0
推荐指数
1
解决办法
5841
查看次数