|
-
Jan 11th, 2003, 04:23 PM
#1
Thread Starter
Addicted Member
Need Code
I have been looking without success to find info on making a label show different text upon a mouse hovering over the label.
I know this can be done with very little effort but I just can’t find any info on that.
What I would like to do is, have a Label called E-Mail Me that changes to my email address when the mouse hovers over it then on click opens mail client.
Thanks!
-
Jan 11th, 2003, 04:35 PM
#2
For the first part..put a label on a form, and then copy this code to your form...
VB Code:
Option Explicit
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
-
Jan 11th, 2003, 04:36 PM
#3
Frenzied Member
Place Label (Label1) on the form, copy and paste this code
VB Code:
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
HoverLabel Label1, "E-mail Me", False, vbBlack
End Sub
Private Sub Label1_Click()
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
End Sub
Private Sub HoverLabel(LBL As Label, strText As String, FontUnderline As Boolean, FontColor As ColorConstants)
With LBL
.Caption = strText
.Font.Underline = FontUnderline
.ForeColor = FontColor
End With
End Sub
-
Jan 11th, 2003, 04:38 PM
#4
Lively Member
Here's the rest
That guys code will change the button when you move your mouse on top of it. If you want the button to revert back to its original state, add some code to the form's mouse_move event to change the caption back. You could set booleans on each to make sure you're not constantly changing captions on controls.
-
Jan 11th, 2003, 04:38 PM
#5
Lively Member
Man andreys... you beat me to it...
-
Jan 11th, 2003, 04:47 PM
#6
The picture isn't missing
but it will not work very well, ie if you move your mouse really fast the form will not register the mouse move on the form, or if you move over other controls it wont reset.
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Jan 11th, 2003, 04:51 PM
#7
That is true...any other ideas???
-
Jan 11th, 2003, 05:16 PM
#8
Thread Starter
Addicted Member
Andreys!
OK that works great, however, would someone please take the time to explain I don’t want to use it if I don’t understand it.
Just a short explanation would be much appreciated.
Thanks a lot!!!!!!!!!!!!!!!!!!!!!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|