我想通过输入的坐标来划线,或点,不知道有没有相关的控件,我有其它软件里看到过相关的功能,但是就是不知道什么控件可以实现,哪位兄弟知道,告诉一声。相关图片在:http://www.xlhb.com/images/gps.jpg

解决方案 »

  1.   

    都是调用画布CANVAS.MoveTo和LineTo来实现,具体的原理是截获当前鼠标的DOWN和UP消息,然后绘制线
      

  2.   

    type
      TLineGriphic = class(TGraphicControl)
      private
        FPixelsRightX: Integer;
        FPixelsLeftY: Integer;
        FPixelsLeftX: Integer;
        FPixelsRightY: Integer;
        procedure SetPixelsLeftX(const Value: Integer);
        procedure SetPixelsLeftY(const Value: Integer);
        procedure SetPixelsRightX(const Value: Integer);
        procedure SetPixelsRightY(const Value: Integer);
      protected
        procedure Paint; override;
      public
      published
        property PixelsLeftX: Integer read FPixelsLeftX write SetPixelsLeftX;
        property PixelsLeftY: Integer read FPixelsLeftY write SetPixelsLeftY;
        property PixelsRightX: Integer read FPixelsRightX write SetPixelsRightX;
        property PixelsRightY: Integer read FPixelsRightY write SetPixelsRightY;
      end;implementation{ TLineGriphic }procedure TLineGriphic.Paint;
    begin
      inherited;
      Self.Canvas.Pen.Color := clred;
      Self.Canvas.MoveTo(0, 0);
      Self.Canvas.LineTo(Width, Height);
    end;procedure TLineGriphic.SetPixelsLeftX(const Value: Integer);
    begin
      Self.FPixelsLeftX := Value;
      Self.Left := Value;
    end;procedure TLineGriphic.SetPixelsLeftY(const Value: Integer);
    begin
      Self.FPixelsLeftY := Value;
      Self.Top := Value;
    end;procedure TLineGriphic.SetPixelsRightX(const Value: Integer);
    begin
      Self.FPixelsRightX := Value;
      Self.Width := Self.FPixelsRightX - Self.FPixelsLeftX + 1;
    end;procedure TLineGriphic.SetPixelsRightY(const Value: Integer);
    begin
      Self.FPixelsRightY := Value;
      Self.Height := Self.FPixelsRightY - Self.FPixelsLeftY + 1;
    end;
    自己看看. 再完善它吧..
      

  3.   

    谁传我一个Tline控件,要免费的,分不错我可以再开贴。
      

  4.   

    Canvas.MoveTO
    Canvas.LineTO
    这个就可以了
      

  5.   

    难道真的没有人有这个控件吗,在delphibbs里有个huizhang做过一个,我想要有人有吗?