Form上放一个PictureBox,设置它的BorderStyle=0,然后帖贴以下程序(可以到我的主页上下载平面按钮控件,解压出Form10.ocx,那个就是了,支持背景色,字体等属性,http://junwhj.51.net/):Option ExplicitPrivate Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Const BF_TOP = &H2 Private Const BF_LEFT = &H1 Private Const BF_RIGHT = &H4 Private Const BF_BOTTOM = &H8 Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)Private Const BDR_RAISEDINNER = &H4 Private Const BDR_SUNKENOUTER = &H2Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate rc As RECTPrivate Sub Form_Load() Picture1.AutoRedraw = True End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single) GetClientRect Picture1.hWnd, rc If x > 0 And x < Picture1.ScaleWidth And y > 0 And y < Picture1.ScaleHeight Then DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT Picture1.Refresh SetCapture Picture1.hWnd Else Picture1.Cls ReleaseCapture End If End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) DrawEdge Picture1.hdc, rc, BDR_SUNKENOUTER, BF_RECT Picture1.Refresh End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT Picture1.Refresh End Sub
请用如下代码一试:Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If X < 0 Or Y < 0 Or X > Text1.width Or Y > Text1.height Then ReleaseCapture Me.Text1.ForeColor = ffffff Me.Text1.BackColor = Me.Frame2.BackColor Else Me.Text1.Tag = "In" SetCapture Text1.hWnd Me.Text1.ForeColor = 222222 Me.Text1.BackColor = 12632319 End IfEnd Sub Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
http://www.vbcity.com/pubs/article.asp?alias=flatbuttonhttp://www.zarr.net/vb/download/codedetail.asp?code=44
SmartXpButton.ocx
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Const BF_TOP = &H2
Private Const BF_LEFT = &H1
Private Const BF_RIGHT = &H4
Private Const BF_BOTTOM = &H8
Private Const BF_RECT = (BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM)Private Const BDR_RAISEDINNER = &H4
Private Const BDR_SUNKENOUTER = &H2Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate rc As RECTPrivate Sub Form_Load()
Picture1.AutoRedraw = True
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
GetClientRect Picture1.hWnd, rc
If x > 0 And x < Picture1.ScaleWidth And y > 0 And y < Picture1.ScaleHeight Then
DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT
Picture1.Refresh
SetCapture Picture1.hWnd
Else
Picture1.Cls
ReleaseCapture
End If
End SubPrivate Sub Picture1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
DrawEdge Picture1.hdc, rc, BDR_SUNKENOUTER, BF_RECT
Picture1.Refresh
End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
DrawEdge Picture1.hdc, rc, BDR_RAISEDINNER, BF_RECT
Picture1.Refresh
End Sub
扁平按钮控件到处都有!上网搜索一下就ok
Me.Text1.ForeColor = ffffff
Me.Text1.BackColor = Me.Frame2.BackColor
Else
Me.Text1.Tag = "In"
SetCapture Text1.hWnd
Me.Text1.ForeColor = 222222
Me.Text1.BackColor = 12632319
End IfEnd Sub
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SetCapture Lib "user32" (ByVal hWnd As Long) As Long
可以添加属性和事件处理方法的
图片.label.自动画.有很多啦!!
junwhj(junwhj.51.net) 你的代码我也试了,不过还不是我所想要的效果,我在试着修改修改。