Solved

my Usercontrol Backcolor & the mouse

Posted on 2002-03-30
5
393 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

773 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