如题:
   想在Shap上贴上图标,要求可以自适应shap的大小

解决方案 »

  1.   

    Tshap有shap.Brush.Bitmap.Canvas属性
      

  2.   

    shap.Brush.Bitmap.Canvas好像不能用StretchDraw方法哦
    我这样用过,刚写的不知道procedure TForm1.Button1Click(Sender: TObject);
    var
      Img:TImage;
      Grap:TBitmap;
    begin
      try
        Grap:=Tbitmap.Create;
        Img:=TImage.Create(nil);
        grap.LoadFromFile('splash.bmp');
        Img.Height:=shape1.Height;
        Img.Width:=shape1.Width;
        Img.Canvas.StretchDraw(Img.ClientRect,Grap);
        shape1.Brush.Bitmap:=Img.Picture.Bitmap;
      finally
        Grap.Free;
      end;
    end;
      

  3.   

    hmzgz81(哩翱) :
    我试了
    好像不行
      

  4.   

    为什么不用image呢?
    应该是Tshape的没有canvas属性的原因吧,而他的shap.Brush.Bitmap.Canvas我用了会不行,而image可以直接用canvas。
    下面是image的,我试了可以的。
    procedure TForm1.Button1Click(Sender: TObject);
    var
      grp:TBitmap;
    begin
      grp:=TBitmap.Create;
      grp.LoadFromFile('splash.bmp');
      image1.Canvas.StretchDraw(image1.ClientRect,grp);
    end;
      

  5.   

    hmzgz81(哩翱) :
       是啊,谢谢,我代码已写完了,不想改太多
    那听你的就用image了,呵呵,谢谢哦!20分给你,早日变猩猩!