473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,387 developers and data experts.

Using the MouseMove Property

missinglinq
3,532 Expert 2GB
Having been asked, for the umpteenth time, how to use the MouseMove property to change the appearance of an object, I put together this short tutorial and sample database today. Perhaps it will be of use to some of you.

The MouseMove Event is used to trigger an action when the user moves the mouse cursor over an object such as a textbox, label or command button. This can be applied to a number of routines. The attached zip file, MouseOverDemo, shows both of the routines outlined below in action.

The following code is used to set up a Menu Form for opening other forms or reports, using the the Click Event of labels. The label default appearance has the background color the same as the form, with the background color changing when the mouse rolls over a label. The MouseMoveMenuForm in the zipped database shows this code in action, presenting a Menu Form with four options.

Sets up the default appearance of the labels before the mouse is ever moved
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Sets up the default appearance of the labels
  3.     lblMenuOptionA.ForeColor = vbBlack 'Sets the text color to black
  4.     lblMenuOptionA.SpecialEffect = 1   'Gives the label a raised, button-like appearance
  5.     lblMenuOptionA.BackStyle = 0       'Makes the label transparent. The color of the form behind the control is visible.
  6. End Sub
  7.  
Changes the background color of a label when the mouse rolls over the label
Expand|Select|Wrap|Line Numbers
  1. Private Sub lblMenuOptionA_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     lblMenuOptionA.ForeColor = vbWhite 'Sets the text color to white
  3.     lblMenuOptionA.SpecialEffect = 1   'Gives the label a raised, button-like appearance
  4.     lblMenuOptionA.BackStyle = 1     'Makes the label's background color, as set in the Property Box, show
  5. End Sub
  6.  
Resets the default appearance of the label after the mouse moves off of the label
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.     lblMenuOptionA.ForeColor = vbBlack
  3.     lblMenuOptionA.SpecialEffect = 1
  4.     lblMenuOptionA.BackStyle = 0
  5. End Sub
Another application for MouseMove would be to show a label with a help message as a replacement for Access’ rather anemic ControlTips. The label is created and positioned in an appropriate place on the form. Unlike ControlTips, all of the usual label formatting functions can be utilized. In the label’s Property Box, the Visible property is set to NO so that the label doesn’t appear until called by the MouseMove event. When the mouse cursor moves over a form object, the label appears, then disappears when the mouse rolls off of the object. This is demonstrated in the MouseMoveHelpForm in the zipped database.

This pops up the Help message
Expand|Select|Wrap|Line Numbers
  1.  Private Sub ClientName_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.    lblClientNameHelp.Visible = True
  3. End Sub
  4.  
This causes the Help message to disappear when the mouse rolls off of the textbox
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2.    lblClientNameHelp.Visible = False
  3. End Sub
  4.  
Please remember that the above only presents two examples of how MouseMove can be utilized. The actual number of uses is only limited by your users’ needs and youR own creativity!
Attached Files
File Type: zip MouseOverDemo.zip (27.9 KB, 5170 views)
May 18 '07 #1
0 43583

Sign in to post your reply or Sign up for a free account.

Similar topics

112
by: Andy | last post by:
Hi All! We are doing new development for SQL Server 2000 and also moving from SQL 7.0 to SQL Server 2000. What are cons and pros for using IDENTITY property as PK in SQL SERVER 2000? Please,...
3
by: Gary | last post by:
Hi, In the program below, C = A+B, and the aim is to delay the calculation of C until the user asks for C. The boolean mUTD (UpToDate) is used indicate when Calc() must be run to make the C =...
2
by: Richard | last post by:
I'm trying to open a form based on the value that I am passing through to it. I'm trying to open the Deals form on the basis of a sellerid that I am trying to pass through to that second form. ...
2
by: theWizard1 | last post by:
Using Visual Studio.Net 2005, Asp.Net 2.0, and trying to use technique shown in the Programming Asp.Net 3rd Edition by O'Reily, page 257. On the first page, this would become the previous page, I...
0
by: Charlie | last post by:
Hi: I get a TreeNode binding error when using Data property of XmlDataSource control. When I switch to TextFile property and point to xml file on hard drive, problem goes anyway. I'm...
11
by: dgk | last post by:
If I have a class with a public variable, isn't this the same as a private variable with a property? ie, isn't this: Public Class MyTest Public MyVar as String End Class the same as this: ...
16
by: technocraze | last post by:
Hi pals, I would like to know how to display the FileName of the selected file in the textbox and open it using FileDialog property. I have imported the necessary reference from the library -...
5
cameokid
by: cameokid | last post by:
Can someone help me out with this. Here is what i am trying to do. I have an image of size 310x310. Initially i am displaying only 50x50 using clip property. Later using setTimeout property i am...
2
by: sajtovi007 | last post by:
Hi, I've found code in thread: Using FileDialog property to open File and display FileName in a textbox but: 1. I do not know how to add it in to ACCESS 2003 database. 2. I have fields in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.