我自己用image作了一个浮动按钮的效果,还有点不足,哪位能帮个忙原理就是鼠标在图片框上移动和在窗体上移动时分别显示不图的图片方法如下1.在窗体上需要建立按钮的位置处建立一图片框(IMAGE1)
2.放上了imagelist控件,静态地加载上两张只有透明度不同的图片,标识号为1和2
3.加入代码
Dim ID as IntergerPrivate Sub Form1_Load()
ID=0
End Sub
Private Sub Image1_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)Image1.Picture = ImageList1.ListImages(0).Picture
ID=1End SubPrivate Sub Form1_MouseMove(Button As Integer,Shift As I nteger,X As Single,Y As Single)if ID=1 then
   Image1.Picture = ImageList1.ListImages(1).Picture
   ID=0
end ifEnd Sub实现是已经实现在,但是当鼠标在图片框边上路过时,也就是在图片切换时会有黒色的东西一闪,很不爽,希望哪位大侠能帮我解决一下

解决方案 »

  1.   

    //Image1.Picture = ImageList1.ListImages(0).Picture
    这句你调试的时候可以通过?我用picturebox试了一下,没有出现你说的问题:
    Option Explicit
    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        If (X >= 0) And (Y >= 0) And (X < Picture1.Width) And (Y < Picture1.Height) Then
            SetCapture Picture1.hwnd
            Set Picture1.Picture = ImageList1.ListImages(1).Picture
        Else
            Set Picture1.Picture = ImageList1.ListImages(2).Picture
            ReleaseCapture
        End If
    End Sub
      

  2.   

    //Image1.Picture = ImageList1.ListImages(0).Picture
    这句你调试的时候可以通过?
    可以通过的
    好吧
    我再试下你的
      

  3.   

    图像框的redraw。你试一下在换图片之前用此属性假值,换完之后再换回真值。我在表格控件中试过非常理想,因为这个网格控件在添写数据的时候不闪了。