473,608 Members | 2,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using the MouseMove Property

missinglinq
3,532 Recognized Expert Specialist
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 MouseMoveMenuFo rm 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 MouseMoveHelpFo rm 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, 5173 views)
May 18 '07 #1
0 43684

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

Similar topics

112
10299
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, share your experience in using IDENTITY as PK .
3
1659
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 = A+B calculation before C is returned to user. When the Driver program at bottom is run, the behavior is very strange, the debug statement "in Calc" gets printed several times on entry to the constructor, and then again several times when T.A = 1...
2
1875
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. At the push of a button on the first form: Dim cfrmDeals As New frmDeals cfrmDeals.SellerNo = Convert.ToInt32(txtSellerID.Text) cfrmDeals.Visible = True cfrmDeals.Activate()
2
2409
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 have 2 dropdowns. According to their technique, I should create a public property on my previous page for these 2 dropdowns, and then I would would be able to get their settings on the target aspx page. I have added the 2 properties on the...
0
1549
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 initializing Data property with xml string that matches file exactly. Seems to be problem with binding because if I remove bindings, tree works both ways. I'm binding on server like so... TreeNodeBinding bind = new TreeNodeBinding(); bind.DataMember =...
11
1927
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: Public Class MyTest
16
17794
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 - Microsoft Office Object Library 10.0. Tks Control: TextBox - Display FileName Button - Open Code:
5
5957
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 trying to get the entire image so that it looks like animation. But this doesn't happen with the code below <html> <head> <style type="text/css"> .img1 { position:absolute;
2
4302
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 database with FirstName, LastName and IDnumber. How to Create folder named "LastName FirstName IDnumber" from ACCESS 2003 (on a click on a batton)? 3. And, additionaly, is it possible to add all files from this folder (folder created and opened in...
0
8067
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8501
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8483
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8349
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3967
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.