对呀,其他控件我就是这么做的,但是配合了ReleaseCapture和SetCapture这2各api函数,比如:If X < 0 Or Y < 0 Or X > sspanel1.Width Or Y > sspanel1.Height Then sspanel1.BevelOuter = 0 ReleaseCapture Else If sspanel1.BevelOuter <> 2 Then sspale1.BevelOuter = 2 SetCapture sspanel1.hwnd End If End If但是label没有hwnd不知老兄能否具体指导指导,多谢!
用label控件的父对象的mousemove事件使字体颜色恢复
if 字体颜色=恢复颜色 then exit else 字体颜色恢复 end if很快的
举双手同意ILoveThisGame,或者采取设立标志变量的方法
在form_mousemove中写一段代码。
VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 2880 ClientLeft = 60 ClientTop = 345 ClientWidth = 4725 LinkTopic = "Form1" ScaleHeight = 2880 ScaleWidth = 4725 StartUpPosition = 3 'Windows Default Begin VB.TextBox Text1 Height = 405 Left = 1080 TabIndex = 1 Text = "Text1" Top = 480 Width = 2775 End Begin VB.PictureBox Picture1 Height = 1215 Left = 1080 ScaleHeight = 1155 ScaleWidth = 2835 TabIndex = 0 Top = 1320 Width = 2895 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean MouseEnter = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
If MouseEnter Then ' SetCapture Picture1.hwnd Text1.Text = "Mouse in picuture!" Else Text1.Text = "Mouse out!" ReleaseCapture End If
End Sub '捕捉MouseEnter和MouseExit 事件
你试试,很简单的,马上就明白了 Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.ForeColor = vbGreen End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Label1.ForeColor = vbBlue End Sub
sspanel1.BevelOuter = 0
ReleaseCapture
Else
If sspanel1.BevelOuter <> 2 Then sspale1.BevelOuter = 2
SetCapture sspanel1.hwnd
End If
End If但是label没有hwnd不知老兄能否具体指导指导,多谢!
exit
else
字体颜色恢复
end if很快的
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2880
ClientLeft = 60
ClientTop = 345
ClientWidth = 4725
LinkTopic = "Form1"
ScaleHeight = 2880
ScaleWidth = 4725
StartUpPosition = 3 'Windows Default
Begin VB.TextBox Text1
Height = 405
Left = 1080
TabIndex = 1
Text = "Text1"
Top = 480
Width = 2775
End
Begin VB.PictureBox Picture1
Height = 1215
Left = 1080
ScaleHeight = 1155
ScaleWidth = 2835
TabIndex = 0
Top = 1320
Width = 2895
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim MouseEnter As Boolean
MouseEnter = (0 <= X) And (X <= Picture1.Width) And (0 <= Y) And (Y <= Picture1.Height)
If MouseEnter Then
'
SetCapture Picture1.hwnd
Text1.Text = "Mouse in picuture!"
Else
Text1.Text = "Mouse out!"
ReleaseCapture
End If
End Sub
'捕捉MouseEnter和MouseExit 事件
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = vbGreen
End SubPrivate Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.ForeColor = vbBlue
End Sub