473,382 Members | 1,329 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,382 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, 5169 views)
May 18 '07 #1
0 43573

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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.