Solved

my Usercontrol Backcolor & the mouse

Posted on 2002-03-30
5
391 Views
Last Modified: 2008-02-26
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
Comment
Question by:toni2002
5 Comments
 
LVL 1

Accepted Solution

by:
COAtheGREAT earned 50 total points
ID: 6907774
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
 
LVL 1

Expert Comment

by:alaplume
ID: 6907846
Or better yet, Mouse_Over.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6908320
Where do you found Mouse_over event?
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 6910469
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
 

Author Comment

by:toni2002
ID: 6910810
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now