Results 1 to 10 of 10
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    change image control when cursor hovers


    I have a text box with an image control positioned at the end of the text box, see screenshot. What I'd like is to mimic other apps where one sees the image enhance when the cursor hovers over the image which is like "okay, I see the cursor and the control is enabled". In my case, "if you click here now the search window will close". I.e., I need a "Hover" event so I can change the image from faded to sharp.

    Click image for larger version. 

Name:	000.jpg 
Views:	26 
Size:	11.9 KB 
ID:	38432

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Mousemove event for the image control where you swap the image? I guess you'd need another one to swap it back, but where to put it? Put it on the form and it will run every time cursor moves onto form. Maybe you'd need to surround the image with an underlying rectangle that is coloured the same as the form so that the rectangle can swap the image back again.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

  4. #4
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    they don't seem to deal with resetting the control properties back to what they were. Perhaps they just expect one to figure it out, but in doing so, I think some would find there's a lot of flicker if you simply reset with a mousemove over the form. As I suspected in my first post, it's not all that difficult, and if the form is where you reset, then test for the current image property to prevent flicker rather than just setting it in the move. Otherwise every move of the mouse over the form will cause the picture property to be reset to the same image, which likely will cause screen flicker.

    Click image for larger version. 

Name:	swap1.jpg 
Views:	19 
Size:	2.8 KB 
ID:	38433 Click image for larger version. 

Name:	swap2.jpg 
Views:	18 
Size:	3.0 KB 
ID:	38434
    . . over . . - --- - - . . off . .

    Simple as
    Code:
    If Me.Image3.Picture <> "C:\Users\Micron\Pictures\Australia4\DSC_0111b.JPG" Then
        Me.Image3.Picture = "C:\Users\Micron\Pictures\Australia4\DSC_0111b.JPG"
    End If
    or if one prefers
    Code:
    Dim strPath As String
    
    strPath = "C:\Users\Micron\Pictures\Australia4\DSC_0111b.JPG"
    If Me.Image3.Picture <> strPath Then Me.Image3.Picture = strPath
    Last edited by Micron; 05-18-2019 at 04:10 PM. Reason: spelin and gramur

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Post #4 stirred my brain, as I had already had running code using the MouseMove in and around an image control but had not yet thought of how to get rid of the flicker. I was experimenting with a super-imposed empty image control where its MouseMove event would switch the images but the form's header section real-estate is quite congested with other controls so that approach didn't work very well and I discarded the empty image control. Anyway, I resized whatever controls I could so as much open space as could be made available would allow the header-section's MouseMove event to "test" the picture property and change as necessary.

    Here's how it all shakes out. The user clicks on any one of the column headings to sort the listing. With that binary function the sort reverses accordingly..... nothing new here. If the user holds down the Ctrl key and clicks on a column heading the search window is made visible and its "Left" position adjusted to match that of the column heading. The normal transparency level of the "red & white Close" toggles with image changes as the mouse moves about in the header section.

    Click image for larger version. 

Name:	001.jpg 
Views:	14 
Size:	168.5 KB 
ID:	38435

    Code:
    Private Sub FormHeader_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  Change image control picture to the lighter transparency picture as needed.
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    If Me.imSearchClose.Picture <> IPPath & "\imCloseLite.jpg" Then _
        Me.imSearchClose.Picture = IPPath & "\imCloseLite.jpg"
    End Sub
    
    Private Sub imSearchClose_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    '  Mouse is hovering over the "Close" control.  Show reduced transparency as needed.
    '=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
    If Me.imSearchClose.Picture <> IPPath & "\imClose.jpg" Then _
        Me.imSearchClose.Picture = IPPath & "\imClose.jpg"
    End Sub
    As always, thanks to all,
    Bill

  6. #6
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Glad you got it sorted out, although to these tired eyes the name of the image for the respective sections kinda looks backwards. Never mind, I'm sure you know what you're doing now.

  7. #7
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    name of the image for the respective sections kinda looks backwards
    What are you referring to? "imSearchClose" versus more like "imCloseSearch"?

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Bill,

    In case its any use to you, have a look at my example app that accompanies this article http://www.mendipdatasystems.co.uk/m...ols/4594549378
    That includes a form (form 5) where the displayed image changes as you hover over each item in a listbox. There is no flicker.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  9. #9
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Quote Originally Posted by GraeagleBill View Post
    What are you referring to? "imSearchClose" versus more like "imCloseSearch"?
    No, it looks like you show the lite close pic on header mouse over and a normal close pic on image mouse over. Like I said, doesn't matter what it seems like to me if it works for you.

  10. #10
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    No, it's as you would expect, lite until mouse over.

    Normal: Click image for larger version. 

Name:	SearchLite.jpg 
Views:	8 
Size:	5.5 KB 
ID:	38491


    Mouse Over: Click image for larger version. 

Name:	SearchHover.jpg 
Views:	8 
Size:	6.9 KB 
ID:	38492

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 10
    Last Post: 02-25-2019, 07:36 PM
  2. Replies: 2
    Last Post: 03-14-2018, 11:10 AM
  3. Barcode cursor control
    By davidpm in forum Programming
    Replies: 3
    Last Post: 11-23-2016, 02:03 PM
  4. Replies: 3
    Last Post: 07-13-2015, 12:07 PM
  5. Replies: 2
    Last Post: 02-17-2012, 04:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums