Results 1 to 18 of 18

Thread: Webbrowser Zoom

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    19

    Webbrowser Zoom

    I am making a smal webbrowser, and i want the page t be able to zoom, 50%, 100%, 150% and 200%. Does anybody know how to do this?

    Thanks

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    You might want to take a look at the following:

    http://www.vbforums.com/showthread.php?t=506103

    There are lot's of helpful hints in there.

    As for your specific question....

    Have a look here:

    http://slingkid.blogsome.com/2007/04/13/ie-zoom/

    Gary

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    19

    Re: Webbrowser Zoom

    Thanks, ill have a look at them

    Thanks

    True

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    I have downloaded the sample code, and open it in Visual Studio 2008, and it works perfectly.

    Name:  Zoom Browser.png
Views: 16708
Size:  54.3 KB

    Can you provide some details as to why this isn't working for you?

    Gary

    Gary

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    19

    Re: Webbrowser Zoom

    Well, it worked but, the point is, its not code you can use to learn. I couldnt find any thing that was decent to learn from. Could you pick out the bits that are needed?
    Becuase i dont know!

    True
    Thanks

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    What you are trying to do isn't built directly in the WebBrowser. The person who wrote that article has had to extend the functionality of the WebBrowser by creating his own implementation. He has created his own user control, called MyBrowser, which inherits from WebBrowser:

    Code:
    public partial class MyBrowser : WebBrowser
    With that in place, you get all the functionality of the normal WebBrowser, but you can add more, or change existing. That is what he has done.

    He has overriden the AttachInterfaces and DetachInterfaces methods, to provide the basis for the zoom functionality. Then he has provided a new public method called Zoom, which does that actual work.

    In order to use this, you would need to replace your instance of a WebBrowser, with a MyBrowser. There are a few core concepts going on here, that you really need to become familiar with.

    Gary

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    19

    Re: Webbrowser Zoom

    Sounds wayyyy To hard for me....at my level and if rather miss it out until i can learn more.
    This would be a very good tutorial... haha

    Thanks though!

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    Yeah, there is a bit to get your head round with that one, but something you can easily slot in later once you get your head around a few things.

    I would highly recommend having a look at jmcilhinney's WebBrowser, the other link above. He is very good at what he does, and you can learn a lot from the way that he structures his code, and implements different aspects of the code.

    Gary

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Dec 2009
    Posts
    19

    Re: Webbrowser Zoom

    Okay will do Thanks mate!

  10. #10
    New Member
    Join Date
    Nov 2009
    Posts
    8

    Re: Webbrowser Zoom

    anybody can send me the sample 's code? I have the same question but in VB.net and I don't want to install C#; I just want for reference.
    Thanks so much!

  11. #11
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    Welcome to the forums!!

    You have two options.

    1) Convert the code in the sample to VB.Net.
    2) Take the source code in the example, compile it into a DLL, and reference that assembly in your project.

    Either way, there is going to be a bit of work to do.

    Gary

  12. #12
    New Member
    Join Date
    Nov 2009
    Posts
    8

    Re: Webbrowser Zoom

    I have try to do as you say, but when I call Zoom Funtion, it appear an error message showed in below image.
    Code:
    Imports ZoomBrowser
    Public Class Form1
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim myWebBrowser As New MyBrowser
            myWebBrowser.Dock = DockStyle.Fill
            myWebBrowser.Navigate("http://www.google.com")
            myWebBrowser.Zoom(ZoomValue.Text)
            Me.Controls.Add(myWebBrowser)
        End Sub
    End Class
    [IMG][/IMG]

  13. #13
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    Can you explain the exact steps that you have taken to get to the place that you are?

    Gary

  14. #14
    New Member
    Join Date
    Nov 2009
    Posts
    8

    Re: Webbrowser Zoom

    First, I open the sample, set the output as class library

    then I create a new VB project and add reference as zoombrowser.dll
    Drag a combobox named "ZoomValue", set value as " 50 75 100 125 150 ", default value as 75
    Write code ...
    just after I had added zoom funtion, the problem appeared.

  15. #15
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    Looks to me that you have set your class library project as the Startup Project, which is causing the error that you have shown.

    Have you got another project in your solution? If so, set that as the Startup Project.

    Also, I was expecting that you would create your own Class Library Project, and copy and paste the relevant sections of code, not directly change the existing project.

    Gary

  16. #16
    New Member
    Join Date
    Nov 2009
    Posts
    8

    Re: Webbrowser Zoom

    it seem to be impossible to create a class library using System.windows.Forms class! System.Drawing as well.
    Can you test this and show me the result?
    Thank you at all!

  17. #17
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Webbrowser Zoom

    Hey,

    You would simply need to add a reference to this assembly.

    I don't actually think you would need this reference though, as you aren't creating a form.

    I could be wrong though, as it has been a while this I have looked at that code.

    Gary

  18. #18
    New Member
    Join Date
    Jun 2012
    Posts
    1

    Re: Webbrowser Zoom

    Does anyone still have the sample code?!
    link requires password...

    I have exactly the same issue at hand, I'd love to get my hands on the specific implementation of WebBrowser : MyBrowser... it seems to be exactly what I'm looking for.

    PS: I'm working in C# (I know that's not this forms intent, but I thought I'd share this as the Sample Code seems to also be in C#)

    Hopefully ppl are still "out there"!!
    Cheers,

    MV

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