Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 404
  • Last Modified:

my Usercontrol Backcolor & the mouse

Hi Sirs,

in my own usercontrol, i want it to change its colour whenever the mouse just comes over it then i typed this code and it is OK

Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Shape1.BackColor = &H404080
Shape2.BackColor = &H80000001
End Sub

the problem is when i put the mouse away of the usercontrol it stay by the new Backcolor (as shown in the code above) but i want its Backcolor to return into the original color whenever i put the mouse away of it.

note: my usercontrol consists of 2 shapes as shown above  

Please i need your help to amend this code to let me do that.

Many Thanks in advance
Toni2002
0
toni2002
Asked:
toni2002
1 Solution
 
COAtheGREATCommented:
You should use mouse_move of the form that holds control and made public sub to set colors to original, so form call that sub when resive mouse_move.
0
 
alaplumeCommented:
Or better yet, Mouse_Over.
0
 
Richie_SimonettiCommented:
Where do you found Mouse_over event?
0
 
rspahitzCommented:
The problem with VB is that it doesn't support a mouse_out event.  This means that the only way to tell (through VB) when a mouse has left your control is to guess.

One way to "guess" is to set a timer in the mousemove event procedure.  If the timer goes off, either the mouse is elsewhere or the person stopped moving the mouse.

The only other way to handle this is to have another part of the VB project recognize that the mouse has moved over IT, and have IT report back to your usercontrol that the mouse has moved away from the control.

Other than that, I think there's a Windows API to detect mouse movement, with which you can get the coordinates.  If the coordinates are not over your control, reset the color.
0
 
toni2002Author Commented:
changing Backcolor of the usercontrol using this answer is failed, BUT I USED CHANGING "FONTBOLD" INSTEAD THEN IT SUCCEED !!!!!!!
I don't know why .......!!!
May someone knows..
Anyway have something is better than nothing.

Toni2002
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now