Results 1 to 9 of 9

Thread: Re-paint, mouseover and move !

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Manchester
    Posts
    266

    Re-paint, mouseover and move !



    Okay, here is my problem as it stands. This has been 'bugging' me for ages. I would appreciate any help.
    Basically, I have a form in the attached project, this form has a button image on it. When the mouse is moved over this image the image lights up (changes image), when the user moves the cursor off the image, it goes back to normal. However, I am having quite a few problems with it as follows and would like it if someone could help me to:
    • Stop the Re-painting of the entire form every time as it really looks un-professional
    • Help to try and ensure that the image doesn't indent itself out of view as it currently does!
    • And finally, perhaps improve upon my current code to make it more efficient.


    If you could take a second to download the .zip file, it contains all appropriate project files and the images.

    I really do need some help on this and would appreciate anyones efforts or input into how I can resolve these problems.


    Thanks, and merry christmas

    Jord
    Attached Files Attached Files
    Last edited by intraman; Dec 25th, 2004 at 03:12 PM.

  2. #2
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: Re-paint, mouseover and move !

    You fogot to attach your project :O
    Zeegnahtuer?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Manchester
    Posts
    266

    Re: Re-paint, mouseover and move !

    Sorry, I have edited the original post and it is now attached

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Re-paint, mouseover and move !

    You could use a graphical checkbox. It has a down image built in. Except for a border around the edge of the picture, it switches the images automatically with no flicker, and no offset. there is no mouseover, though.

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Re-paint, mouseover and move !

    Hi intraman.

    Take a good look at your modified project. You'll find two new Images on the form. It might not be the best way arround (resource file would probably be much cleaner), also VBisn't great to work with GIF type images so ordinary BMP perform much better (new images are included in the zip).
    Buzz me if you have any questions.

    Cheers.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Manchester
    Posts
    266

    Re: Re-paint, mouseover and move !

    Wow, thanks.

    Only problem now is that I don't understand the code so i couldnt implement it for other mouseovers very easily!

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Re-paint, mouseover and move !

    Which part isn't clear? I had some comments in there ...
    Anyway, the following is what I sent you and I think it's self-explanatory:
    VB Code:
    1. 'general declaration section
    2. Option Explicit
    3.  
    4. Private Type RECT
    5.     Left As Long
    6.     Top As Long
    7.     Right As Long
    8.     Bottom As Long
    9. End Type
    10. Private Type POINTAPI
    11.     X As Long
    12.     Y As Long
    13. End Type
    14.  
    15. Private Const IDC_HAND = 32649&
    16.  
    17. Private Declare Function SetCursor Lib "user32" _
    18.     (ByVal hCursor As Long) As Long
    19. Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" _
    20.     (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
    21.  
    22. Private Declare Function GetCursorPos Lib "user32" _
    23.     (lpPoint As POINTAPI) As Long
    24. Private Declare Function GetWindowRect Lib "user32" _
    25.     (ByVal hwnd As Long, lpRect As RECT) As Long
    26.  
    27. Private Sub Picture4_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    28.     'change mouse pointer to bring some attention from user
    29.     SetCursor LoadCursor(0, IDC_HAND)
    30. End Sub
    31.  
    32. Private Sub filetime_Timer()
    33. Dim Rec As RECT, Point As POINTAPI
    34.  
    35.     ' Get Left, Right, Top and Bottom of Picture4
    36.     GetWindowRect Picture4.hwnd, Rec
    37.    
    38.     ' Get current position of the cursor
    39.     GetCursorPos Point
    40.    
    41.     'check if cursor if within control's boundaries
    42.     If Point.X >= Rec.Left And Point.X <= Rec.Right And _
    43.         Point.Y >= Rec.Top And Point.Y <= Rec.Bottom Then
    44.         'cursor is right above the control
    45.         Picture4.Picture = imgTemp(0).Picture
    46.     Else
    47.         'cursor is outside of control's boundaries
    48.         Picture4.Picture = imgTemp(1).Picture
    49.     End If
    50.  
    51. End Sub

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Manchester
    Posts
    266

    Re: Re-paint, mouseover and move !

    Okay, yeah - with your combined PM i now understand. Thanks.

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Re-paint, mouseover and move !

    sure, any time.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width