我图像框里装了一个按钮图片,大小是18*21像素,按钮图片的四周3像素的地方是按钮获得焦点时的黄色线,如何把四周3像素的地方不拉伸,然后中间的部分拉伸显示到图片框1里(也就是打印按钮拉大后的效果),下面是按钮控件里的方法,但是不知道怎么应用到图像框和图片框之间.Public Sub PrintB(z)
    brx = UserControl.Width - 45
    bry = UserControl.Height - 45
    bw = UserControl.Width - 90
    bh = UserControl.Height - 90
    'im(z).Picture是按钮控件里的图像框 im(1)、im(2)、im(3),分别代表常规,鼠标松开,鼠标按下的3个状态的图片
    UserControl.PaintPicture im(z).Picture, 0, 0, 45, 45, 0, 0, 45, 45
    UserControl.PaintPicture im(z).Picture, brx, 0, 45, 45, 225, 0, 45, 45
    UserControl.PaintPicture im(z).Picture, brx, bry, 45, 45, 225, 270, 45, 45
    UserControl.PaintPicture im(z).Picture, 0, bry, 45, 45, 0, 270, 45, 45
    UserControl.PaintPicture im(z).Picture, 45, 0, bw, 45, 45, 0, 180, 45
    UserControl.PaintPicture im(z).Picture, brx, 45, 45, bh, 225, 45, 45, 225
    UserControl.PaintPicture im(z).Picture, 0, 45, 45, bh, 0, 45, 45, 225
    UserControl.PaintPicture im(z).Picture, 45, bry, bw, 45, 45, 270, 180, 45
    UserControl.PaintPicture im(z).Picture, 45, 45, bw, bh, 45, 45, 180, 225
 
          If UserControl.Tag <> "" Then
              UserControl.CurrentX = (UserControl.Width - TextWidth(caption)) / 2
              UserControl.CurrentY = (UserControl.Height - TextHeight(caption)) / 2
          End If
      UserControl.Print UserControl.Tag
End Sub

解决方案 »

  1.   

    需要一堆API~~~
    建议看看(laviewpbt)的一些文章~
      

  2.   

    把图片分为9宫格123
    456
    7892 4 6 8 的位置使用BITBLT进行平铺5的位置进行拉伸不知道LZ是否是想用来做BUTTON?自定义的图片BUTTON
      

  3.   

    如果是做皮肤的话参考一下我做的DXSKIN,这样做BUTTON要好的多!
    http://www.vbgood.com/thread-100891-1-1.html
      

  4.   

    你一楼的代码:
    首先 PictureBox 的 ScaleMode 也应该是 vbTwips;
    如果 PictureBox 是无边框的,直接将 UserControl 对象换成具体的 PictureBox 对象实例即可;
    如果 PictureBox 是有边框的,处理上面的替换,还要将 Width、Height 属性替换成 ScaleWidth、ScaleHeight。Image 控件不能绘图,不直接支持。但是你可以将 PictureBox 的缩放结果给 Image 控件用:
    '在 Picture1.AutoRedraw = True 前提下'
    Set Image1.Picture = Picture1.Image
      

  5.   


    终于把我贴的代码按你的方法改好了,奇怪的是,我的图片框是无边框的,ScaleMode属性也是vbTwips了,但是你说要有边框才把图片框的Width、Height 属性替换成 ScaleWidth、ScaleHeight,,,,可是我无边框的图片框也要把Width、Height 属性替换成 ScaleWidth、ScaleHeight 才行,不然出来的图片只有不到米大小
      

  6.   

    单独的图片框可以用 Cls 清除,但是数组好像不起作用,数组如何清除图片?还有就是图像框不管是单独的还是数组,都不能用 Cls 清除,那图像框数组的图片又怎么清除呢?????
      

  7.   

    图片框使用Set Me.Picture1.Picture = Nothing清除图片。
      

  8.   

    PictureBox 的上级容器(通常是窗体)的 ScaleMode 不是 vbTwips,所以即使无边框,ScaleWidth 和 Width 由于度量单位不同,值也就不同。
    既然你不统一 ScaleMode,那么无论 UserControl 还是 PictureBox 都应该用 ScaleWidth、ScaleHeight。