|
-
Dec 2nd, 1999, 09:18 AM
#1
Thread Starter
Fanatic Member
I want to change color of let's say label when coursor is on it and then I want to restore its original color after the cursor is somewhere else. I know how to do it actually, but I'm using a lot of code just to change the color to original (I put my code in Form_MouseMove, Frame_MouseMove etc.) is there a way to put the code in just one place so it will work correctly?
I hope you know what I mean
------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.
-
Dec 2nd, 1999, 01:04 PM
#2
Member
hi,
Try this..
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private mpoiCursorPos As POINTAPI
Dim flag As Boolean
Private Sub Timer1_Timer()
Dim lonCstat As Long
Dim lonCurrhWnd As Long
lonCstat = GetCursorPos(mpoiCursorPos)
lonCurrhWnd = WindowFromPoint(mpoiCursorPos.x, mpoiCursorPos.y)
If lonCurrhWnd = UserControl.hWnd Then
Shape1.FillColor = RGB(255, 0, 0)
Label1.BackColor = RGB(255, 0, 0)
Else
Shape1.FillColor = RGB(0, 0, 0)
Label1.BackColor = RGB(0, 0, 0)
End If
End Sub
kandan.
-
Dec 2nd, 1999, 01:35 PM
#3
Hyperactive Member
This simpler might help you out...
Private Sub lblurl_DragDrop(Source As Control, X As Single, Y As Single)
If Source Is lblUrl Then
With lblUrl
.Font.Underline = False
.ForeColor = vbBlack
Call ShellExecute(0&, vbNullString, .Caption, vbNullString, vbNullString, vbNormalFocus)
End With
End If
End Sub
Private Sub lblUrl_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
If State = vbLeave Then
With lblUrl
.Drag vbEndDrag
.Font.Underline = False
.ForeColor = vbBlack
End With
End If
End Sub
Private Sub lblUrl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With lblUrl
.ForeColor = vbBlue
.Font.Underline = True
.Drag vbBeginDrag
End With
End Sub
---------
Venkat.
-
Dec 2nd, 1999, 08:17 PM
#4
It's actually alot easier:
Code:
Private m_lOrigColor As Long
Private Sub Form_Load()
m_lOrigColor = Label1.BackColor
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = m_lOrigColor
End Sub
Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.BackColor = vbRed
End Sub
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
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
|