procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  image1.Picture.Bitmap.Canvas.Brush.Style:=bsClear;
  image1.Picture.Bitmap.Canvas.TextOut(50,50,inttostr(x));
end;我想实现在(50,50)这点滚动显示鼠标的x值,不显示数字框,我上面的程得到结果是所有的数字重叠在一起,而不是数字的滚动效果,请各位指教.

解决方案 »

  1.   

    先定义全局变量用来保存X,Y的数据如 
    x1:integer
    给x1初值为0
    procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
     with image1.Picture.Bitmap.Canvas do
        begin
         Brush.Style:=bsClear;
         Font.Color:=clbtnface; //你的底色
         TextOut(50,50,inttostr(x1));
         Font.Color:=clbtntext; //你字体的颜色
         TextOut(50,50,inttostr(x));
         x1:=x;
        end;
    end;
      

  2.   

    你若想简单点就用一个Lable 就可以了。
    procedure TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      image1.Picture.Bitmap.Canvas.Brush.Style:=bsClear;
      //image1.Picture.Bitmap.Canvas.TextOut(50,50,inttostr(x));
      Lable1.Caption:=inttostr(x);
    end;
      

  3.   

    这招肯定不行
    既是Image那所谓底色一定不是单色的。
    把Bmp存成变量
    每次改变都重新画一遍数字所在Rect
    再写上字,这样还差不多。
      

  4.   

    这样可以:加入两个image控件,设置成等到大小,并且,把下边的image1载入图片,上边的image2设置为透明,然后,在image2的OnMousemove事件中写入:
      iamge2.canvas.brush.style:=bsClear;
      for i:=0 to image2.heigth-1 do
          begin
             image2.canvas.textout(0,i,'                              ');
          end;
      image2.canvas.textout(50,50,inttostr(x));