我想实现程序的 image 加载一个图片,然后鼠标像股票软件那种跟随十字线效果,请问如何实现呢?有人能帮帮我吗?

解决方案 »

  1.   

    取鼠标位置,水平和垂直画线
    moveto
    lineto
      

  2.   

    procedure TfrmMain.PaintBoxCMouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);  Procedure DrawCross(AX, AY: Integer);
      begin
        With PaintBoxC.Canvas do
        begin
          Pen.Color := CrossColor;
          Pen.Style := CrossStyle;
          Pen.Mode := pmXor;
          Pen.Width := 1;
          MoveTo(AX, 0);
          LineTo(AX, PaintBoxC.Height);
          MoveTo(0, AY);
          LineTo(PaintBoxC.Width, AY);
          TextOut(5,5,'('+IntTostr(AX)+','+IntTostr(AY)+')');
        end;
      end;Var
      tmpX, tmpY: Double;
    begin
      if (OldX <> -1) then
      begin
        DrawCross(OldX, OldY); { draw old crosshair }
        OldX := -1;
      end;
      //PaintBoxC.Canvas.
      { check if mouse is inside Chart rectangle }
      if PtInRect(Rect(0, 0, PaintBoxC.Width, PaintBoxC.Height), Point(X, Y)) then
      begin
        DrawCross(X, Y); { draw crosshair at current position }
        { store old position }
        OldX := X;
        OldY := Y;
      end;