修正TiKnob的指示箭头显示问题

iocom官方只支持到D7,但是可以运用于新版本,只测试过显示运用,没测试过OPC特性(这个在新版本运用中估计有问题)。

但是在新版本运用中还有有一些小BUG,比如:

修正TiAnlogDisplay显示的问题-CSDN博客

TiKnob也发现BUG。

在10.4中拖入一个TiKnob,发现"Indicator"没有显示出来,

修改

Delphi 复制代码
procedure TiKnob.DrawIndicator(Canvas: TCanvas; const CenterPoint: TPoint);
var
  InnerPoint           : TPoint;
  OuterPoint           : TPoint;
  IndicatorCenterPoint : Tpoint;
  IndicatorRect        : TRect;
  IndicatorDegrees     : Double;
  PointerEndPoint      : TPoint;
  PointerBasePoint     : TPoint;
  Point1               : TPoint;
  Point2               : Tpoint;
begin
  IndicatorDegrees := RotationStartDegrees - PositionDegrees;

  //with Canvas, IndicatorRect do
  with Canvas do
    begin
      Brush.Style := bsSolid;
      IndicatorCenterPoint := GetXYRadPoint(IndicatorDegrees, FKnobRadius - FIndicatorMargin - FIndicatorSize, CenterPoint);

      IndicatorRect := Rect(IndicatorCenterPoint.x - FIndicatorSize,
                            IndicatorCenterPoint.y - FIndicatorSize,
                            IndicatorCenterPoint.x + FIndicatorSize,
                            IndicatorCenterPoint.y + FIndicatorSize);

      if FMouseDown or FKeyDown then begin Pen.Color := FIndicatorActiveColor;   Brush.Color := FIndicatorActiveColor    end
      else                           begin Pen.Color := FIndicatorInactiveColor; Brush.Color := FIndicatorInactiveColor; end;

      case FIndicatorStyle of
        ikisDotLowered : begin
                           Ellipse(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom);
                           Pen.Color := clGray;  Arc(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom, IndicatorRect.Right, IndicatorRect.Top, IndicatorRect.Left, IndicatorRect.Bottom);
                           Pen.Color := clWhite; Arc(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom, IndicatorRect.Left , IndicatorRect.Bottom, IndicatorRect.Right, IndicatorRect.Top);
                         end;
        ikisDotRaised  : begin
                           Ellipse(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom);
                           Pen.Color := clWhite; Arc(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom, IndicatorRect.Right, IndicatorRect.Top, IndicatorRect.Left, IndicatorRect.Bottom);
                           Pen.Color := clGray;  Arc(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom, IndicatorRect.Left, IndicatorRect.Bottom, IndicatorRect.Right, IndicatorRect.Top);
                         end;
        ikisDot        : begin
                           Ellipse(IndicatorRect.Left, IndicatorRect.Top, IndicatorRect.Right, IndicatorRect.Bottom);
                         end;
        ikisLineCenter : begin
                           OuterPoint:=GetXYRadPoint(IndicatorDegrees,FKnobRadius-FIndicatorMargin,CenterPoint);
                           PolyLine([OuterPoint, CenterPoint]);
                         end;
        ikisLineCustom : begin
                           OuterPoint:=GetXYRadPoint(IndicatorDegrees,FKnobRadius-FIndicatorMargin,               CenterPoint);
                           InnerPoint:=GetXYRadPoint(IndicatorDegrees,FKnobRadius-FIndicatorMargin-FIndicatorSize,CenterPoint);
                           PolyLine([OuterPoint, InnerPoint]);
                         end;
        ikisTriangle   : begin
                           PointerEndPoint :=GetXYRadPoint(IndicatorDegrees,FKnobRadius-FIndicatorMargin,               CenterPoint);
                           PointerBasePoint:=GetXYRadPoint(IndicatorDegrees,FKnobRadius-FIndicatorMargin-FIndicatorSize,CenterPoint);
                           Point1 := GetXYRadPoint(IndicatorDegrees + 90, FIndicatorSize/2, PointerBasePoint);
                           Point2 := GetXYRadPoint(IndicatorDegrees - 90, FIndicatorSize/2, PointerBasePoint);
                           Polygon([Point1, Point2, PointerEndPoint]);
                         end;
      end;
    end;
end;

是由于Canvas和IndicatorRect都有Left和Top属性引起的。

重新编译(不用重新安装),正常 。

估计其它控件也有类似的问题,一般照此修改就可以。

相关推荐
lincats20 小时前
一步一步学习使用LiveBindings(16)使用代码创建LiveBindings绑定
delphi·livebindings·delphi 12.3·firedac·firemonkey
lincats4 天前
一步一步学习使用LiveBindings(14)TListView进阶使用(2),打造天气预报程序
delphi·livebindings·delphi 12.3·firedac·firemonkey·tlistview
lincats5 天前
一步一步学习使用LiveBindings(13) TListView的进阶使用(1)
delphi·livebindings·delphi 12.3·firemonkey·tlistview
lincats6 天前
一步一步学习使用LiveBindings(12) LiveBindings与具有动态呈现的TListView
delphi·livebindings·delphi 12.3·firemonkey
chilavert3187 天前
技术演进中的开发沉思-62 DELPHI VCL系列:VCL下的设计模式
开发语言·delphi
lincats8 天前
一步一步学习使用LiveBindings(11) 绑定到自定义外观的ListBox
list·delphi·delphi 12.3·firedac·firemonkey·tlistview
lincats9 天前
# 一步一步学习使用LiveBindings(10) LiveBindings绑定到漂亮的TCombobox
ide·delphi·livebindings·delphi 12.3
lincats10 天前
一步一步学习使用LiveBindings(9) LiveBindings图像绑定与自定义绑定方法(2)
delphi·livebindings·delphi 12.3·firedac·firemonkey
lincats12 天前
一步一步学习使用LiveBindings(8) 使用向导创建用户界面,绑定格式化入门
delphi·livebindings·delphi 12.3·firedac·firemonkey
lincats16 天前
一步一步学习使用LiveBindings(7) 实现对JSON数据的绑定
android·delphi·livebindings·delphi 12.3·firedac