用下面的程序做数个VB模拟按钮,但在使用中遇到问题:picture边缘只有左边和上边有颜色,右边和下边没有。
还有按钮出现后,颜色与PICTURE的颜色不符,无法回复初始(未加载模拟按钮)状态。请教高手帮忙修改:一、如何在Form_MouseMove()时恢复原始(未加载模拟按钮时)状态。
二、如何让四边同时带色边,这样才更像一个按钮。
Private Sub DrawButton(ob As Object, an As Integer, tu As Integer)
Dim A As Integer
Dim B As Integer
A = ob.Width
B = ob.Height
ob.Line (0, 0)-(A, 0), QBColor(an)
ob.Line (0, 0)-(0, B), QBColor(an)
ob.Line (A, 0)-(A, B), QBColor(tu)
ob.Line (0, B)-(A, B), QBColor(tu)
End SubPrivate Sub Picture10_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then
Call DrawButton(Picture10(Index), 15, 0) ' tu
End If
End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
For i = 0 To 6
Call DrawButton(Picture10(i), 8, 8) ' tu
Next
For k = 0 To 3
Call DrawButton(Picture2(k), 8, 8) ' tu
Next
End Sub

解决方案 »

  1.   

    Private Sub DrawButton(ob As Object, an As Integer, tu As Integer)
    Dim A As Integer
    Dim B As Integer
    A = ob.Width - Screen.TwipsPerPixelX * 5
    B = ob.Height - Screen.TwipsPerPixelX * 5
    ob.Line (0, 0)-(A, 0), QBColor(an)
    ob.Line (0, 0)-(0, B), QBColor(an)
    ob.Line (A, 0)-(A, B), QBColor(tu)
    ob.Line (0, B)-(A, B), QBColor(tu)
    End Sub
    Sub Picture10_LostFocus(Index As Integer)
    Call DrawButton(Picture10(Index), 8, 8) ' tu
    End Sub
    Sub Picture2_LostFocus(Index As Integer)
    Call DrawButton(Picture2(Index), 8, 8) ' tu
    End SubPrivate Sub Picture10_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then
    Picture10(Index).SetFocus
    Call DrawButton(Picture10(Index), 15, 0) ' tu
    End If
    End Sub
    Private Sub Picture2_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then
    Picture2(Index).SetFocus
    Call DrawButton(Picture2(Index), 15, 0) ' tu
    End If
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    For i = 0 To 6
    Call DrawButton(Picture10(i), 8, 8) ' tu
    Next
    For k = 0 To 3
    Call DrawButton(Picture2(k), 8, 8) ' tu
    Next
    End Sub
      

  2.   

    希望的是:在MOUSEMOVE移出按钮位置之后,按钮边缘回复无色透明状态。
      

  3.   

    直接拿pictureBox控件做一个就是了~~轮换切换图片就实现了。
      

  4.   

    vb6中的按钮没有鼠标移出的触发事件,不过可以退而求其次用变通的办法,鼠标从按钮上移出了那么它肯定会移到其他控件上,例如按钮或者frame什么的,那么就在这些控件的mousemove中处理设置你的模拟按钮的样式。
    ps:在vb.net中就有mouseleave事件了。
      

  5.   


    试过了替换图片是达不到这样好的效果的。继续请各位大侠看一下:我的picture按钮颜色为天蓝色,但是QBColor(color)  color 参数是一个界于 0 到 15 的整型,没有天蓝色。我希望当FORM_MOUSEMOVE时,能够让picture边缘回复天蓝色(与FORM背景色一样的颜色),做到按钮边缘无缝无线条。
      

  6.   

    用RGB(xxx,yyy,zzz)
    可以得到256*256*256种颜色
      

  7.   


    在这里好像没法改成RGB()?
      

  8.   

    RGB中还有个亮度、饱和度、色度没法加入的。
      

  9.   

    一般是用Image控件来模拟按钮,代码就几行:
    Option ExplicitPrivate Sub Form_Load()
            Image1.Picture = LoadPicture("C:\Background Images\Background_1.gif")
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
            Image1.Picture = LoadPicture("C:\Background Images\Background_1.gif")
    End SubPrivate Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
            Image1.Picture = LoadPicture("C:\Background Images\Background_2.gif")
    End Sub
      

  10.   

    RGB确实可以了。非常感谢。
    但是出来一点小问题:当form_mousemove并离开picture_mousemove10(0)到新的按钮picture_mousemove10(1)时,picture_mousemove10(0)的右边和下边还有按钮的边缘颜色,要跨到下下个按钮才能消除。
    这个如何解决?是哪里有问题?Private Sub DrawButton(ob As Object, r As Integer, g As Integer, bs As Integer, rr As Integer, gg As Integer, bb As Integer)
    Dim A As Integer
    Dim b As Integer
    A = ob.Width - Screen.TwipsPerPixelX
    b = ob.Height - Screen.TwipsPerPixelX
    ob.Line (0, 0)-(A, 0), RGB(r, g, bs)
    ob.Line (0, 0)-(0, b), RGB(r, g, bs)
    ob.Line (A, 0)-(A, b), RGB(rr, gg, bb)
    ob.Line (0, b)-(A, b), RGB(rr, gg, bb)
    End Sub
    Sub Picture10_LostFocus(Index As Integer)
    Call DrawButton(Picture10(Index), 121, 202, 255, 182, 184, 194) 
    End Sub
    Sub Picture2_LostFocus(Index As Integer)
    Call DrawButton(Picture2(Index), 121, 202, 255, 182, 184, 194) 
    End SubPrivate Sub Picture10_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then
    Picture10(Index).SetFocus
    Call DrawButton(Picture10(Index), 255, 255, 255, 182, 184, 194) 
    End If
    End Sub
    Private Sub Picture2_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then
    Picture2(Index).SetFocus
    Call DrawButton(Picture2(Index), 255, 255, 255, 182, 184, 194) 
    End If
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    For i = 0 To 6
    Call DrawButton(Picture10(i), 121, 202, 255, 121, 202, 255) ' 
    Next
    For k = 0 To 3
    Call DrawButton(Picture2(k), 121, 202, 255, 121, 202, 255) ' 
    Next
    End Sub
      

  11.   


    因为你没给 Picture10 原始的 颜色配置, 边框配置
    当然我只能用预设颜色灰色表示
      

  12.   

    Private Sub DrawButton(ob As Object, an, tu)
    Dim A As Integer
    Dim B As Integer
    A = ob.Width - Screen.TwipsPerPixelX * 5
    B = ob.Height - Screen.TwipsPerPixelX * 5
    ob.Line (0, 0)-(A, 0), (an)
    ob.Line (0, 0)-(0, B), (an)
    ob.Line (A, 0)-(A, B), (tu)
    ob.Line (0, B)-(A, B), (tu)
    End SubPrivate Sub Form_Load()
    Me.BackColor = &HFF9900
    For i = 0 To 6
    Picture10(i).BorderStyle = 0
    Picture10(i).BackColor = Me.BackColor
    Next
    For i = 0 To 3
    Picture2(i).BorderStyle = 0
    Picture2(i).BackColor = Me.BackColor
    Next
    End SubSub Picture10_LostFocus(Index As Integer)
    Call DrawButton(Picture10(Index), Me.BackColor, Me.BackColor)  ' tu
    End Sub
    Sub Picture2_LostFocus(Index As Integer)
    Call DrawButton(Picture2(Index), Me.BackColor, Me.BackColor) ' tu
    End SubPrivate Sub Picture10_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then
    Picture10(Index).SetFocus
    Call DrawButton(Picture10(Index), &HDDDDDD, 0) ' tu
    End If
    End Sub
    Private Sub Picture2_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then
    Picture2(Index).SetFocus
    Call DrawButton(Picture2(Index), &HDDDDDD, 0) ' tu
    End If
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    For i = 0 To 6
    Call DrawButton(Picture10(i), Me.BackColor, Me.BackColor) ' tu
    Next
    For k = 0 To 3
    Call DrawButton(Picture2(k), Me.BackColor, Me.BackColor) ' tu
    Next
    End Sub
      

  13.   

    Mousemove  Mousedown MouseUp 制作的 立体感的音效按钮有兴趣的话可以去下载
    【CBM666 的按钮特效】
    http://cbm666.net/forum.php?mod=viewthread&tid=1789&fromuid=2
      

  14.   

    如果有懂vc++ 的人 能帮我将这个 VB源代码 转换为vc++ 源码, 对我学习vc++ 将是最大的帮助, 有人愿帮我吗? 在CSDN容许的方式下 我送 2000 分