Results 1 to 9 of 9

Thread: [RESOLVED] CommandButton Text: Zoom In/Zoom Out on Mouse Events

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2008
    Location
    New Zealand
    Posts
    62

    Resolved [RESOLVED] CommandButton Text: Zoom In/Zoom Out on Mouse Events

    I have a CommandButton and I've tried the obvious ways to make the Font Zoom Up to a certain level on the MouseOver Event and Zoom Out when the mouse is not on the CommandButton but none have worked.

    There is probably something really simple I'm not doing so can someone please help me out?

    Thanks Heaps (I love this Forum xD)

  2. #2
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Maybe something like this?
    Code:
    Option Explicit
    Private Declare Function GetCapture Lib "user32" () As Long
    Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function ReleaseCapture Lib "user32" () As Long
    
    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        
        With Command1
            If GetCapture() = .hwnd Then
                If ((X < 0) Or (X > .Width)) Or ((Y < 0) Or (Y > .Height)) Then
                    Call ReleaseCapture
                     .FontSize = 8
                End If
            Else
                Call SetCapture(.hwnd)
                .FontSize = 10
            End If
        End With
    
    End Sub
    Last edited by Edgemeal; Sep 27th, 2008 at 05:49 AM.

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 2008
    Location
    New Zealand
    Posts
    62

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Doesn't wont to work, there are no error but the code does not change anything.

    Just to rephrase my question: When I have the MouseOver the CommandButton the font will gradually get bigger eg 8 -> 10 -> 12 -> 14. When the mouse finally leaves the CommandButton the font will the cycle back down like 14 -> 12 -> 10 ->8

  4. #4
    VB For Fun Edgemeal's Avatar
    Join Date
    Sep 2006
    Location
    WindowFromPoint
    Posts
    4,255

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Quote Originally Posted by MongooseRoadkill
    Doesn't wont to work, there are no error but the code does not change anything.

    Just to rephrase my question: When I have the MouseOver the CommandButton the font will gradually get bigger eg 8 -> 10 -> 12 -> 14. When the mouse finally leaves the CommandButton the font will the cycle back down like 14 -> 12 -> 10 ->8
    Odd that code has always worked for me.
    Do you have button on the form named "Command1"?

  5. #5

    Thread Starter
    Member
    Join Date
    Aug 2008
    Location
    New Zealand
    Posts
    62

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Yea it's called Command1 but for some reason it won't work?

  6. #6

    Thread Starter
    Member
    Join Date
    Aug 2008
    Location
    New Zealand
    Posts
    62

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Sorry to bump, but does anyone have an answer?

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Edgemeal's code works just fine. When you say it doesn't is it because it doesn't gradually increase the font size but rather just switch between 8pt and 10pt? Maybe it's just because the font that your using doesn't come in 8 and 10pt size? Which font are you using?

  8. #8
    Frenzied Member longwolf's Avatar
    Join Date
    Oct 2002
    Posts
    1,343

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    Try using Edgemeal's code again, but set the text Bold then back.
    Might be more noticeable

  9. #9

    Thread Starter
    Member
    Join Date
    Aug 2008
    Location
    New Zealand
    Posts
    62

    Re: CommandButton Text: Zoom In/Zoom Out on Mouse Events

    I've found out the problem now, It was becuase I had the Manifest file that converts VB6 IDE to the current theme of your XP but I just removed it and now the code works fine and I got it to cycle up and down aswell In the end the code I wrote it the first place was correct but the Manifest file was bugging it out...

    Plus Reps for those who helped (All of you)
    Last edited by MongooseRoadkill; Sep 29th, 2008 at 01:10 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
  •  



Click Here to Expand Forum to Full Width