PDA

Click to See Complete Forum and Search --> : HighLight Label with move move over label


Troy Mac
Nov 10th, 1999, 01:06 AM
I have a program that when a mouse moves over a label it changes color. I can do the first color change fine but when the mouse moves off the label I want it to change back to the original color. If anyone knows how to do this I would appreciate the help. I did find some code that does this with VB6 but its to large and confusing plus its for the Web and not for an exe program.

Please help

Troy

------------------
Troy MacPherson
Customer Suport Software Analyst
t_macpherson@yahoo.com

Serge
Nov 10th, 1999, 01:30 AM
Sure thing:


Private Sub Form_Load()
m_lColor = Label1.BackColor
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = m_lColor
End Sub


Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = vbRed
End Sub




Regards,

------------------

Serge

Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)

shan1
Nov 10th, 1999, 01:32 AM
Dim temp As Double
Private Sub Form_Load()
temp = Label1.BackColor
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = temp
End Sub

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = 10 'some color
End Sub

try this out!!!!!!

Troy Mac
Nov 10th, 1999, 04:45 PM
Thanks guys but I had already tried these things and I guess the problem is that I have 4 labels on the for and I can get label 1 to work but the other three just wont light up? I got some code from another BBS and its good code but when I use it I can't click the label of my choice and get the results i need. Here is the code that I got maybe one of you guys can figure out whats wrong? Pay attention to the SetCapture when I rem that out it works better.
'Module
Public Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long

'code
Private Sub LblNewGame_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

'Put this in the mouse_move event of your control:

With LblNewGame
If Button = 0 Then
If (X < 0) Or (Y < 0) Or (X > .Width) Or (Y > .Height) Then
ReleaseCapture
'Do your 'mouse-exit' stuff here
.ForeColor = &HFFFF00 '&H808000
' Else
SetCapture (hwnd)
' Do your 'mouse-enter' stuff here
.ForeColor = &HFFFF00
End If
End If
End With
End Sub

Any ideas?

Thanks


------------------
Troy MacPherson
Customer Suport Software Analyst
t_macpherson@yahoo.com

Aaron Young
Nov 10th, 1999, 08:11 PM
If you're going to be using alot of these "Hover" Labels then you'd be better off making a Control or using a Class, e.g.

In a Class Module, Named: HoverLabel..

Public WithEvents Label As Label

Private Sub Label_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If TypeName(oLastLabel) = "Nothing" Then
Set oLastLabel = Label
Label.ForeColor = vbBlue
Label.FontUnderline = True
End If
End Sub

In a Module..

Public oLastLabel As Label

In a Form with 3 Labels..

Private Link1 As New HoverLabel
Private Link2 As New HoverLabel
Private Link3 As New HoverLabel

Private Sub Form_Load()
Set Link1.Label = Label1
Set Link2.Label = Label2
Set Link3.Label = Label3
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If TypeName(oLastLabel) = "Nothing" Then Exit Sub
oLastLabel.ForeColor = vbWindowText
oLastLabel.FontUnderline = False
Set oLastLabel = Nothing
End Sub

Private Sub Label1_Click()
'Play Code to Jump to URL in Label1 Here..
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net