need a little help cant figure out how to use mouse events to zoom on an image

Discussion in 'Programming General' started by 420tim, Nov 16, 2010.

need a little help cant figure out how to use mouse events to zoom on an image
  1. Unread #1 - Nov 16, 2010 at 1:16 PM
  2. 420tim
    Joined:
    May 8, 2007
    Posts:
    9
    Referrals:
    0
    Sythe Gold:
    0

    420tim Newcomer

    need a little help cant figure out how to use mouse events to zoom on an image

    hello ive got this webbrowser project ive been using as a client to play on a webhosted p server and have tried adding a map to the browser, now ive been trying to make it zoomable..... ive used buttons thats kinda lame and my whole picture Grows instead of actually zooming, ive talked to an instructor about this and he suggested to use sin and cos with mouseover and mouse events..... ive looked everywhere to figure out how the code would go but cant find much about sin and cos being used to zoom

    sorry forgot to mention im using visual basic 2008


    if it helps out to hel me out

    any input on some ways to coding a real way to zoom would very appreciated so i can use my map =]

    PublicClass Form1
    PrivateSub Gobtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Gobtn.Click
    IfMe.TB_Address.Text = ""ThenReturn
    Me.WebBrowser.Navigate(Me.TB_Address.Text)
    EndSub
    PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
    Me.WebBrowser.AllowNavigation = True
    Me.WebBrowser.AllowWebBrowserDrop = True
    EndSub
    PrivateSub WebBrowser_Navigated(ByVal sender AsObject, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles WebBrowser.Navigated
    Me.TB_Address.Text = Me.WebBrowser.Url.ToString
    EndSub
    PrivateSub Backbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Backbtn.Click
    Me.WebBrowser.GoBack()
    EndSub
    PrivateSub Forwardbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forwardbtn.Click
    Me.WebBrowser.GoForward()
    EndSub
    PrivateSub Refreshbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Refreshbtn.Click
    Me.WebBrowser.Refresh()
    EndSub
    PrivateSub Stopbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Stopbtn.Click
    Me.WebBrowser.Stop()
    EndSub
    PrivateSub btnMapON_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMapON.Click
    Me.picMap.Visible = True
    Me.btnZoomIn.Visible = True
    Me.btnZoomOut.Visible = True
    Me.pnlMapHolder.Visible = True
    EndSub
    PrivateSub btnMapOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMapOff.Click
    Me.picMap.Visible = False
    Me.btnZoomIn.Visible = False
    Me.btnZoomOut.Visible = False
    Me.pnlMapHolder.Visible = False
    EndSub
    PrivateSub btnZoomIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Me.picMap.Width += 10%
    Me.picMap.Height += 10%
    EndSub
    PrivateSub btnZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Me.picMap.Width -= 10%
    Me.picMap.Height -= 10%
    EndSub
     
  3. Unread #2 - Nov 17, 2010 at 8:07 AM
  4. Upgrator
    Joined:
    Oct 28, 2010
    Posts:
    312
    Referrals:
    0
    Sythe Gold:
    0

    Upgrator Forum Addict
    Banned

    need a little help cant figure out how to use mouse events to zoom on an image

    Try reinstalling mouse drivers.
     
  5. Unread #3 - Nov 17, 2010 at 6:53 PM
  6. 420tim
    Joined:
    May 8, 2007
    Posts:
    9
    Referrals:
    0
    Sythe Gold:
    0

    420tim Newcomer

    need a little help cant figure out how to use mouse events to zoom on an image

    mmk that has nothing to do with the programming.... what im am tryin to get help with is, im trying to figure out how i would use mouse click events in vb.net programming to zoom in and out on a picturebox for a windows application. hopefully that clears up any misunderstanding on what i need help with
     
  7. Unread #4 - Nov 18, 2010 at 12:28 PM
  8. Harlem9191
    Joined:
    Mar 10, 2009
    Posts:
    81
    Referrals:
    0
    Sythe Gold:
    0

    Harlem9191 Member

    need a little help cant figure out how to use mouse events to zoom on an image

    Where are your handlers?

    PrivateSub btnZoomIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomIn.Click
    Me.picMap.Width += 10%
    Me.picMap.Height += 10%
    EndSub
    PrivateSub btnZoomOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZoomOut.Click
    Me.picMap.Width -= 10%
    Me.picMap.Height -= 10%
    EndSub

    Also it grows because that is exactly what you are telling it to do. How is increasing the height and width of a picturebox zooming in?
    I have never actually tried this yet but I think it might be the ZoomFactor property. Very high chance that i'm wrong but just try it.
     
  9. Unread #5 - Nov 18, 2010 at 12:39 PM
  10. Harlem9191
    Joined:
    Mar 10, 2009
    Posts:
    81
    Referrals:
    0
    Sythe Gold:
    0

    Harlem9191 Member

    need a little help cant figure out how to use mouse events to zoom on an image

    Just found the following code on google, looks like it works to me.
    Code:
    Private ZOOMFACTOR As Double = 1.25    ' = 25% smaller or larger
    Private MINMAX As Integer = 5
    
    Private Sub ZoomOut(ByVal pic As PictureBox)
          If (pic.Width > (500 / MINMAX)) AndAlso (pic.Height > (500 / MINMAX)) Then
    
               pic.Width = Convert.ToInt32(pic.Width / ZOOMFACTOR)
               pic.Height = Convert.ToInt32(pic.Height / ZOOMFACTOR)
               pic.SizeMode = PictureBoxSizeMode.StretchImage
               'pbSourceImage.Location = New Point(0, 0)
           End If
       End Sub
    
    Private Sub ZoomIn(ByVal pic As Image, ByVal picbox As PictureBox)
         If (pic.Width < (MINMAX * picbox.Width)) AndAlso (pic.Height < (MINMAX * picbox.Height)) Then
    
              picbox.Width = Convert.ToInt32(pic.Width * ZOOMFACTOR)
               picbox.Height = Convert.ToInt32(pic.Height * ZOOMFACTOR)
               picbox.SizeMode = PictureBoxSizeMode.StretchImage
           End If
        End Sub
    
    Then use this code for your buttons.
     
  11. Unread #6 - Nov 18, 2010 at 5:45 PM
  12. 420tim
    Joined:
    May 8, 2007
    Posts:
    9
    Referrals:
    0
    Sythe Gold:
    0

    420tim Newcomer

    need a little help cant figure out how to use mouse events to zoom on an image

    well thanks for your help, i tried out the code in a new project and it works but is still changes the size of the actual image box..... and for me to be able to get the zoom in to work i had to remove the if statement, didnt feel like fixing it....

    still need some help on figuring out how to zoom in a a picture in a picturebox without resizing the picture box it self......
    help would be much appreciated on this =]
     
  13. Unread #7 - Mar 10, 2011 at 9:55 AM
  14. 420tim
    Joined:
    May 8, 2007
    Posts:
    9
    Referrals:
    0
    Sythe Gold:
    0

    420tim Newcomer

    need a little help cant figure out how to use mouse events to zoom on an image

    it has been awhile since i first tried to get help with this so here it goes....
    what im trying to achieve is to load the Runescape map into some type of picture box and zoom in on the picture while keeping the entire picture box its self the same size all the time....
     
  15. Unread #8 - Mar 11, 2011 at 8:54 AM
  16. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    need a little help cant figure out how to use mouse events to zoom on an image

    I'll explain how to do it, but i cbf doing it for you.
    1). Download the image to your computer. (use webclient or something)
    2). On your form place a picture box INSIDE a panel.
    3). Load the image inside the picture box.
    4). Resize the picture box to suit your 'zooming' functions.

    (make sure your picture property 'stretch' property is set to true.)
     
< need small c++ help please | VB6/.NET/C# which do i choose? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site