Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-06-2018, 01:43 PM   #1
jjake
Newly Registered User
 
Join Date: Oct 2015
Location: Texas, USA
Posts: 242
Thanks: 60
Thanked 0 Times in 0 Posts
jjake is on a distinguished road
Problem with font changing using mouse move event

I am using the following code to change numerous images/text/buttons on my home navigation screen from white to orange when they are highlighted and then returned to white when the mouse is moved back over the background that is behind/ separates the boxes.

Code:
Private Sub ButMOC_Click()
Me.tabMOC.SetFocus
End Sub

Private Sub butPI_Click()
Me.TabPlantInfo.SetFocus
End Sub

Private Sub butPI_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)

If Not Me!arr1.ForeColor = FontOrange Then
Me!arr1.ForeColor = FontOrange
Me!cmdPI.ForeColor = FontOrange
Me!ImgPIOn.Visible = True

End If
End Sub

Private Sub butPM_Click()
Me.TabPM.SetFocus
End Sub

Private Sub butPM_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr2.ForeColor = FontOrange Then
Me!arr2.ForeColor = FontOrange
Me!cmdPM.ForeColor = FontOrange
Me!ImgPMOn.Visible = True

End If
End Sub

Private Sub butPur_Click()
Me.TabPur.SetFocus
End Sub

Private Sub butWO_Click()
Me.TabWO.SetFocus
End Sub

Private Sub butWO_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr3.ForeColor = FontOrange Then
Me!arr3.ForeColor = FontOrange
Me!cmdWO.ForeColor = FontOrange
Me!imgWOOn.Visible = True

End If
End Sub



Private Sub ButPro_Click()

Me.TabPro.SetFocus
End Sub

Private Sub ButAdm_Click()

Me.TabAdm.SetFocus
End Sub

Private Sub ButUpd_Click()

Me.Tabupd.SetFocus
End Sub




Private Sub butMOC_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr4.ForeColor = FontOrange Then
Me!arr4.ForeColor = FontOrange
Me!cmdMOC.ForeColor = FontOrange
Me!imgMOCOn.Visible = True

End If
End Sub

Private Sub ButPUR_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr5.ForeColor = FontOrange Then
Me!arr5.ForeColor = FontOrange
Me!cmdPur.ForeColor = FontOrange
Me!imgPurOn.Visible = True

End If
End Sub

Private Sub ButPro_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr6.ForeColor = FontOrange Then
Me!arr6.ForeColor = FontOrange
Me!cmdPro.ForeColor = FontOrange
Me!ImgproOn.Visible = True

End If
End Sub

Private Sub ButAdm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr7.ForeColor = FontOrange Then
Me!arr7.ForeColor = FontOrange
Me!cmdAdm.ForeColor = FontOrange
Me!imgadmOn.Visible = True

End If
End Sub

Private Sub ButUpd_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontOrange = RGB(237, 125, 49)
    
If Not Me!arr8.ForeColor = FontOrange Then
Me!arr8.ForeColor = FontOrange
Me!cmdUpd.ForeColor = FontOrange
Me!imgUpdOn.Visible = True


End If
End Sub

Private Sub Box5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    FontWhite = RGB(255, 255, 255)

If Not Me!arr1.ForeColor = FontWhite Then
Me!arr1.ForeColor = FontWhite
Me!cmdPI.ForeColor = FontWhite
Me!ImgPIOn.Visible = False
End If

If Not Me!arr2.ForeColor = FontWhite Then
Me!arr2.ForeColor = FontWhite
Me!cmdPM.ForeColor = FontWhite
Me!ImgPMOn.Visible = False
End If

If Not Me!arr3.ForeColor = FontWhite Then
Me!arr3.ForeColor = FontWhite
Me!cmdWO.ForeColor = FontWhite
Me!imgWOOn.Visible = False
End If

If Not Me!arr4.ForeColor = FontWhite Then
Me!arr4.ForeColor = FontWhite
Me!cmdMOC.ForeColor = FontWhite
Me!imgMOCOn.Visible = False
End If

If Not Me!arr5.ForeColor = FontWhite Then
Me!arr5.ForeColor = FontWhite
Me!cmdPur.ForeColor = FontWhite
Me!imgPurOn.Visible = False
End If

If Not Me!arr6.ForeColor = FontWhite Then
Me!arr6.ForeColor = FontWhite
Me!cmdPro.ForeColor = FontWhite
Me!ImgproOn.Visible = False
End If

If Not Me!arr7.ForeColor = FontWhite Then
Me!arr7.ForeColor = FontWhite
Me!cmdAdm.ForeColor = FontWhite
Me!imgadmOn.Visible = False
End If

If Not Me!arr8.ForeColor = FontWhite Then
Me!arr8.ForeColor = FontWhite
Me!cmdUpd.ForeColor = FontWhite
Me!imgUpdOn.Visible = False
End If


End Sub

Private Sub Command92_Click()
Me.TabPlantInfo.SetFocus
End Sub

Private Sub Command92_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    FontOrange = RGB(237, 125, 49)

If Not Me!arr1.ForeColor = FontOrange Then
Me!arr1.ForeColor = FontOrange
Me!ImgPIOn.Visible = True
Me!cmdPI.ForeColor = FontOrange

End If
End Sub

Private Sub Command95_Click()

End Sub

Private Sub Form_Load()

Me.Move 0, 0

End Sub

Private Sub Image67_Click()
'Me.TabHome.SetFocus

DoCmd.OpenForm "home screen"
End Sub


Private Sub MainTabctl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    FontWhite = RGB(255, 255, 255)

If Not Me!arr1.ForeColor = FontWhite Then
Me!arr1.ForeColor = FontWhite
Me!cmdPI.ForeColor = FontWhite
Me!ImgPIOn.Visible = False
End If

If Not Me!arr2.ForeColor = FontWhite Then
Me!arr2.ForeColor = FontWhite
Me!cmdPM.ForeColor = FontWhite
Me!ImgPMOn.Visible = False
End If

If Not Me!arr3.ForeColor = FontWhite Then
Me!arr3.ForeColor = FontWhite
Me!cmdWO.ForeColor = FontWhite
Me!imgWOOn.Visible = False
End If

If Not Me!arr4.ForeColor = FontWhite Then
Me!arr4.ForeColor = FontWhite
Me!cmdMOC.ForeColor = FontWhite
Me!imgMOCOn.Visible = False
End If

If Not Me!arr5.ForeColor = FontWhite Then
Me!arr5.ForeColor = FontWhite
Me!cmdPur.ForeColor = FontWhite
Me!imgPurOn.Visible = False
End If

If Not Me!arr6.ForeColor = FontWhite Then
Me!arr6.ForeColor = FontWhite
Me!cmdPro.ForeColor = FontWhite
Me!ImgproOn.Visible = False
End If

If Not Me!arr7.ForeColor = FontWhite Then
Me!arr7.ForeColor = FontWhite
Me!cmdAdm.ForeColor = FontWhite
Me!imgadmOn.Visible = False
End If

If Not Me!arr8.ForeColor = FontWhite Then
Me!arr8.ForeColor = FontWhite
Me!cmdUpd.ForeColor = FontWhite
Me!imgUpdOn.Visible = False
End If


End Sub
I'm sure there was a cleaner way to do this but i am a novice when it comes to VBA.

My problem is that if i swipe my mouse fast enough between the text boxes i can make multiple of them change color, until i slowly move my mouse over the background. Is there a way to speed up this response time? or another method to my madness?

jjake is offline   Reply With Quote
Old 12-09-2018, 06:52 AM   #2
The_Doc_Man
Happy Retired Curmudgeon
 
Join Date: Feb 2001
Location: Suburban New Orleans, LA, USA
Posts: 12,591
Thanks: 62
Thanked 1,208 Times in 1,108 Posts
The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold The_Doc_Man is a splendid one to behold
Re: Problem with font changing using mouse move event

I have no specific answer for you, but will tell you that the more you try to do in an event routine, the longer it will take to run. And remember that one event CANNOT interrupt another event. So the slowness MIGHT be caused simply by building a backlog of mouse-move events, which MUST be processed linearly.

Since I have never played that much with mouse-move, I can't tell you what to do, but perhaps my answer will explain what you see.

I never worried about mouse movement. What I did was worry about focus. If a user used a mouse click OR the TAB key, focus would change. So I did my color highlighing in the control's GotFocus event and did my control color normalization in the LostFocus event. Worked in my situation quite well.

You might want to consider that if your mouse's last position was greater than X away from the current position, it is moving fast and you don't want to do ANYTHING.

And one more note: I could never find a good "orange" either, but your FontWhite is simply the Access color constant vbWhite.
__________________
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.
The_Doc_Man is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
On mouse move event of label, change font color aman Modules & VBA 4 03-22-2018 05:30 AM
[SOLVED] Form on mouse move event? hfl Forms 23 10-05-2017 02:04 AM
Code problem with On Format event (Changing Font Colors) RHubbard Reports 1 09-15-2006 03:45 PM
ON Mouse Move event L'apprentis Forms 3 08-21-2006 12:04 AM
On Mouse Move Event Help. Talismanic Modules & VBA 13 06-07-2001 09:30 AM




All times are GMT -8. The time now is 11:58 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World