473,402 Members | 2,055 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,402 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 43592

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: 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?
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.