修正TiAnlogDisplay显示的问题
来源:互联网 发布:微领袖学堂源码 编辑:程序博客网 时间:2024/05/01 13:06
原来在DELPHI7下的程序移到XE2下,修修改改,总算行了。一直没注意这个TiAnlogDisplay控件,界面上用了好多这个控件,运行,显示为空,也不报错。看设计界面,也是空的,本来应当显示初始值的。用的是6.0.4 for xe2(网友自己改的),相同的源码在D7下没问题,这就奇怪了。再放个TiAnlogOuput控件(父类是TiCustomEdit),显示也没问题。这2个控件都继承自TiComponent,(中间的一些控件和显示无关),是控件自己的问题了。看源码,也看不出有什么不同的地方。它们的显示都是通过PaintTo这个方法,设断点,出问题了:
procedure TiAnalogDisplay.iPaintTo(Canvas: TCanvas);var AText : String; ATextRect : TRect; ATextFlags : TiTextFlags;begin with Canvas, ATextRect do begin if not ErrorActive then begin if FPrecision >= 0 then AText := Trim(Format('%.' + IntToStr(FPrecision) + 'f', [FValue])) + FUnitsText else AText := Trim(Format('%g', [FValue])) + FUnitsText; Font.Assign(FFont); DrawBackGround(Canvas, BackGroundColor); end else begin AText := ErrorText; Font.Assign(ErrorFont); DrawBackGround(Canvas, ErrorBackGroundColor); end; case BorderStyle of ibsNone : begin ATextRect.Top := 2; ATextRect.Bottom := Height - 2; end; ibsRaised : begin ATextRect.Top := 2; ATextRect.Bottom := Height - 2; end; ibsLowered : begin ATextRect.Top := 2; ATextRect.Bottom := Height - 4; end; end; case FAlignment of iahCenter : begin ATextFlags := [itfHCenter, itfVCenter, itfSingleLine]; ATextRect.Left := 2; ATextRect.Right := Width - 2; end; iahLeft : begin ATextFlags := [itfHLeft, itfVCenter, itfSingleLine]; ATextRect.Left := 2 + FAlignmentMargin; ATextRect.Right := Width - 2; end; else begin ATextFlags := [itfHRight, itfVCenter, itfSingleLine]; ATextRect.Left := 2; ATextRect.Right := Width - 2 - FAlignmentMargin; end; end; Brush.Style := bsClear; iDrawText(Canvas, AText, ATextRect, ATextFlags, True, BackGroundColor); end;end;
这儿的Right和Bottom值变成一个巨大的数!(如44062789),Hight和Width本身的值没问题,但是代码的运算(简单运算,不就是减个常数),Bottom和Right就变成一个巨大数了,怀疑表达式中的Hight和Width在运算的时候被替换了,真奇怪啊
修改成这样:
procedure TiAnalogDisplay.iPaintTo(Canvas: TCanvas);var AText : String; ATextRect : TRect; ATextFlags : TiTextFlags;begin with Canvas, ATextRect do begin if not ErrorActive then begin if FPrecision >= 0 then AText := Trim(Format('%.' + IntToStr(FPrecision) + 'f', [FValue])) + FUnitsText else AText := Trim(Format('%g', [FValue])) + FUnitsText; Font.Assign(FFont); DrawBackGround(Canvas, BackGroundColor); end else begin AText := ErrorText; Font.Assign(ErrorFont); DrawBackGround(Canvas, ErrorBackGroundColor); end; case BorderStyle of ibsNone : begin ATextRect.Top := 2; ATextRect.Bottom := Self.Height - 2; end; ibsRaised : begin ATextRect.Top := 2; ATextRect.Bottom := Self.Height - 2; end; ibsLowered : begin ATextRect.Top := 2; ATextRect.Bottom := Self.Height - 4; end; end; case FAlignment of iahCenter : begin ATextFlags := [itfHCenter, itfVCenter, itfSingleLine]; ATextRect.Left := 2; ATextRect.Right := Self.Width - 2; end; iahLeft : begin ATextFlags := [itfHLeft, itfVCenter, itfSingleLine]; ATextRect.Left := 2 + FAlignmentMargin; ATextRect.Right := Self.Width - 2; end; else begin ATextFlags := [itfHRight, itfVCenter, itfSingleLine]; ATextRect.Left := 2; ATextRect.Right := Self.Width - 2 - FAlignmentMargin; end; end; Brush.Style := bsClear; iDrawText(Canvas, AText, ATextRect, ATextFlags, True, BackGroundColor); end;end;
OK,好了
- 修正TiAnlogDisplay显示的问题
- 修正 MyEclipse 显示 0 时区的问题
- 合唱队问题的修正
- 修正模糊处理显示效果问题
- 修正Raize的时间日期控件不能正确显示星期几的问题
- 修正Raize的时间日期控件不能正确显示星期几的问题
- 完成根据坐标查询经纬度,修正显示树错误的问题
- 修正《呼啸战神3》(狂神天威)只能看到背景,单位不显示的问题。
- Arduino - 修正LCD1602 IIC转接卡只显示第一个字符的问题
- Ubuntu 显示分辨率不正确的修正
- ros对摄像头显示的修正补充
- 问题修正
- 修正Bugfree 1.0 + mysql4.1中文显示乱码问题
- 修正DataGridView的列乱序的问题
- u-boot2010.03 移植篇(三)-----修正配置文件.解决内存大小显示问题,真的没什么可看的
- u-boot2010.03 移植篇(三)-----修正配置文件.解决内存大小显示问题,真的没什么可看的
- u-boot2010.03 移植篇(三)-----修正配置文件.解决内存大小显示问题,真的没什么可看的
- ubuntu 安装的小问题修正
- myeclipse更改打开jsp的默认方式
- 如何继续使用replace pioneer
- mysql中int、bigint、smallint 和 tinyint的区别与长度的含义
- Webservice学习
- Codeforces Beta Round #11, problem: (D) A Simple Task 状态压缩DP+记忆化搜素DP
- 修正TiAnlogDisplay显示的问题
- java多态举例
- Android高手应该精通哪些内容
- Codeforces Round #168 (Div. 1), problem: (B) Zero Tree, DFS
- Ibatis 通过logging打印sql语句的xml配置
- 判断两个链表是否相交及获得相交的第一个节点
- java 下载地址
- android.os.NetworkOnMainThreadException
- CSS选择器