locked
WebBrowser Zoom

    Question

  • Hi every one

    i program a new webbrowser and i ask you for help about the code which can do zoom in webbrowser and thank you

    Wednesday, June 09, 2010 7:04 PM

Answers

  • This works for me without problem (Option Strict Of)


    'Visual Basic 2008 - .net 3.5 - Any CPU
     
      Private Enum Exec
        OLECMDID_OPTICAL_ZOOM = 63
      End Enum
    
      Private Enum execOpt
        OLECMDEXECOPT_DODEFAULT = 0
        OLECMDEXECOPT_PROMPTUSER = 1
        OLECMDEXECOPT_DONTPROMPTUSER = 2
        OLECMDEXECOPT_SHOWHELP = 3
      End Enum
    
      Private Sub Zoom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
          Dim Res As Object = Nothing
          Dim MyWeb As Object
          MyWeb = Me.WebBrowser1.ActiveXInstance
          MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, execOpt.OLECMDEXECOPT_PROMPTUSER, 150, IntPtr.Zero)
        Catch ex As Exception
          MsgBox(ex.Message)
        End Try
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        WebBrowser1.Navigate("www.google.com")
      End Sub

     


    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by AbdoAA Monday, June 14, 2010 7:44 PM
    Thursday, June 10, 2010 2:23 PM
  • Hi again,

    first i didn`t use the array of webbrowser comonents you did. I just plcaed a WebBrowser1 Control on my form. Second i just placed a Button1 Control on my form and let the Zoom_Click method handle the Button1.Click event. I guess the reason of the exception you are getting is here.

    The only thing i had changed from your code: no webbrowser array AND the zoom ratio of 150 instead of 50

     


    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by AbdoAA Monday, June 14, 2010 7:44 PM
    Monday, June 14, 2010 6:20 AM

All replies

  • hi every one

    i used this code but it dose not work, it show me an error message i do not know why can any one help me

    Private Enum Exec
        OLECMDID_OPTICAL_ZOOM = 63
      End Enum
    
      Private Enum execOpt
        OLECMDEXECOPT_DODEFAULT = 0
        OLECMDEXECOPT_PROMPTUSER = 1
        OLECMDEXECOPT_DONTPROMPTUSER = 2
        OLECMDEXECOPT_SHOWHELP = 3
      End Enum
    
     Private Sub Zoom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zoom.Click
        Try
          Dim Res As Object = Nothing
          Dim MyWeb As Object
          MyWeb = Me.wb(0).ActiveXInstance
          MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, execOpt.OLECMDEXECOPT_PROMPTUSER, 50, IntPtr.Zero)
        Catch ex As Exception
          MsgBox(ex.Message, "Navigator")
        End Try
      End Sub

    Thursday, June 10, 2010 2:06 PM
  • You should provide the errormessage here.
    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    Thursday, June 10, 2010 2:18 PM
  • This works for me without problem (Option Strict Of)


    'Visual Basic 2008 - .net 3.5 - Any CPU
     
      Private Enum Exec
        OLECMDID_OPTICAL_ZOOM = 63
      End Enum
    
      Private Enum execOpt
        OLECMDEXECOPT_DODEFAULT = 0
        OLECMDEXECOPT_PROMPTUSER = 1
        OLECMDEXECOPT_DONTPROMPTUSER = 2
        OLECMDEXECOPT_SHOWHELP = 3
      End Enum
    
      Private Sub Zoom_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
          Dim Res As Object = Nothing
          Dim MyWeb As Object
          MyWeb = Me.WebBrowser1.ActiveXInstance
          MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, execOpt.OLECMDEXECOPT_PROMPTUSER, 150, IntPtr.Zero)
        Catch ex As Exception
          MsgBox(ex.Message)
        End Try
      End Sub
    
      Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        WebBrowser1.Navigate("www.google.com")
      End Sub

     


    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by AbdoAA Monday, June 14, 2010 7:44 PM
    Thursday, June 10, 2010 2:23 PM
  • Hi Heslacher

    i used your code but it showed me this message error

    Trying to revoke a drop target that has not been registered (Exception from HRESULT: 0x80040100 (DRAGDROP_E_NOTREGISTERED))

    i use visual basic 2005 .net 2

    Friday, June 11, 2010 10:27 PM
  • Hi again,

    first i didn`t use the array of webbrowser comonents you did. I just plcaed a WebBrowser1 Control on my form. Second i just placed a Button1 Control on my form and let the Zoom_Click method handle the Button1.Click event. I guess the reason of the exception you are getting is here.

    The only thing i had changed from your code: no webbrowser array AND the zoom ratio of 150 instead of 50

     


    Hannes

    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET: http://www.developerfusion.com/tools/convert/csharp-to-vb/
    • Marked as answer by AbdoAA Monday, June 14, 2010 7:44 PM
    Monday, June 14, 2010 6:20 AM
  • Thank You Heslacher
    Monday, June 14, 2010 7:45 PM