 |
|
 |
To get this to work with Visual Basic,
you need to set the zoom percentage value to a long value with CLng(newValue)
Otherwise you will get the error message:
"Run-time error '-2147221248 (80040100)': Method ExecWB of object 'IWebBrowser2' failed."
This is my code:
On Error Resume Next
Call WebBrowser1.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, CLng(newPercentageValue), vbNull)
You can get the zoom range with: Dim pvaIn As Variant
Dim pvaOut As Variant
On Error Resume Next
pvaIn = vbNull
pvaOut = vbNull
Call WebBrowser1.ExecWB(OLECMDID_OPTICAL_GETZOOMRANGE, OLECMDEXECOPT_DODEFAULT, pvaIn, pvaOut)
modified 2 Oct '11.
|
|
|
|
 |
|
 |
How I Can Get Selected Tags In WebBrowser When selected Any Part Of text
Or how get Selected Blocks??
|
|
|
|
 |
|
 |
I not sure if this is the right place to post this question but I have run out of idea's on how to fix this problem, so any assistance you could give me would be a big help!
Development System I'm using
Vista Home Edition
Vb.net 2008 Express
Problem !!!!
I am making a simple web browser using the "Web Browser Control" I can load a web page and navigate until my hearts content. But I can't view Flash content, a screen comes up and say's that I need to download the "Flash Plugin". When I go to the Adobe Flash page and try to get the plugin another page says the "Flash Plugin" is not supported in a 64bit browser. If I use Internet Explorer 7 which was pre installed on the machine when I got it, everything works fine. I have been looking for a work around or a soluion to this problem for months. Any suggestions would be a great help
|
|
|
|
 |
|
 |
Does any 1 know how to set the '%' of the zoom?
|
|
|
|
 |
|
|
 |
|
 |
First off thanks for posting this solution on Code Project. This has plagued me as well, and it is nice to see a solution....well sort of. I implemented the code as described in your post, both with VS2005 and VS2008 and in both cases the following error is thrown: "Trying to revoke a drop target that has not been registered (Exception from HRESULT: 0x80040100 (DRAGDROP_E_NOTREGISTERED))". This obscure error message makes it difficult to resolve the source of the Interop error....Do you have any suggestions for resolving this? Thanks in advance,
|
|
|
|
 |
|
 |
I'm running the application on Vista and have Internet Explorer installed. Here is the full source code which definitely works. I assume you are using the Webbrowser component 2.0 which is standard in the toolbox.
Public Class Form1
Private Enum Exec
OLECMDID_OPEN = 1
OLECMDID_NEW = 2
OLECMDID_SAVE = 3
OLECMDID_SAVEAS = 4
OLECMDID_SAVECOPYAS = 5
OLECMDID_PRINT = 6
OLECMDID_PRINTPREVIEW = 7
OLECMDID_PAGESETUP = 8
OLECMDID_SPELL = 9
OLECMDID_PROPERTIES = 10
OLECMDID_CUT = 11
OLECMDID_COPY = 12
OLECMDID_PASTE = 13
OLECMDID_PASTESPECIAL = 14
OLECMDID_UNDO = 15
OLECMDID_REDO = 16
OLECMDID_SELECTALL = 17
OLECMDID_CLEARSELECTION = 18
OLECMDID_ZOOM = 19
OLECMDID_GETZOOMRANGE = 20
OLECMDID_UPDATECOMMANDS = 21
OLECMDID_REFRESH = 22
OLECMDID_STOP = 23
OLECMDID_HIDETOOLBARS = 24
OLECMDID_SETPROGRESSMAX = 25
OLECMDID_SETPROGRESSPOS = 26
OLECMDID_SETPROGRESSTEXT = 27
OLECMDID_SETTITLE = 28
OLECMDID_SETDOWNLOADSTATE = 29
OLECMDID_STOPDOWNLOAD = 30
OLECMDID_ONTOOLBARACTIVATED = 31
OLECMDID_FIND = 32
OLECMDID_DELETE = 33
OLECMDID_HTTPEQUIV = 34
OLECMDID_HTTPEQUIV_DONE = 35
OLECMDID_ENABLE_INTERACTION = 36
OLECMDID_ONUNLOAD = 37
OLECMDID_PROPERTYBAG2 = 38
OLECMDID_PREREFRESH = 39
OLECMDID_SHOWSCRIPTERROR = 40
OLECMDID_SHOWMESSAGE = 41
OLECMDID_SHOWFIND = 42
OLECMDID_SHOWPAGESETUP = 43
OLECMDID_SHOWPRINT = 44
OLECMDID_CLOSE = 45
OLECMDID_ALLOWUILESSSAVEAS = 46
OLECMDID_DONTDOWNLOADCSS = 47
OLECMDID_UPDATEPAGESTATUS = 48
OLECMDID_PRINT2 = 49
OLECMDID_PRINTPREVIEW2 = 50
OLECMDID_SETPRINTTEMPLATE = 51
OLECMDID_GETPRINTTEMPLATE = 52
OLECMDID_PAGEACTIONBLOCKED = 55
OLECMDID_PAGEACTIONUIQUERY = 56
OLECMDID_FOCUSVIEWCONTROLS = 57
OLECMDID_FOCUSVIEWCONTROLSQUERY = 58
OLECMDID_SHOWPAGEACTIONMENU = 59
OLECMDID_ADDTRAVELENTRY = 60
OLECMDID_UPDATETRAVELENTRY = 61
OLECMDID_UPDATEBACKFORWARDSTATE = 62
OLECMDID_OPTICAL_ZOOM = 63
OLECMDID_OPTICAL_GETZOOMRANGE = 64
OLECMDID_WINDOWSTATECHANGED = 65
OLECMDID_ACTIVEXINSTALLSCOPE = 66
End Enum
Private Enum ExecOpt
OLECMDEXECOPT_DODEFAULT = 0
OLECMDEXECOPT_PROMPTUSER = 1
OLECMDEXECOPT_DONTPROMPTUSER = 2
OLECMDEXECOPT_SHOWHELP = 3
End Enum
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim MyWeb As Object
MyWeb = Me.WebBrowser1.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, 50, IntPtr.Zero)
Catch ex As Exception
MsgBox("Error:" & ex.Message)
End Try
End Sub
End Class
|
|
|
|
 |
|
 |
RocLab, thanks for the quick reply. I am running XP2 Pro SP2 with VS2005 and WebBrowser 2.0 as you describe in the article. After doing a little investigation it would appear that this is a side effect of the IE6 browser not implementing the appropriate IWebBrowser2 message constants, which is what my work uses as its standard build. When I implemented this on my home machine (same OS, VS, and WB) but using IE7 the code works fine....Thanks for the help. Looks like one needs to be extra careful, as we will not have control over the machines IE DLL versions and thus may have to disable this feature on pre-IE7 builds. Cheers TerriTop
|
|
|
|
 |
|
|
 |
|
|
 |
|
 |
i have solved the problem very simply if you use variable in the magnifcation size instade of
a number the error is raised so for example:
dim fsize as integer
fsize=180
'this create error
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, fsize , IntPtr.Zero)
'this one no error simple subtraction FSIZE-0 use this instead
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, _
ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, fsize - 0, IntPtr.Zero)
|
|
|
|
 |
|
 |
The reason the exception is raised in the first place is because the ExecWB third parameter expects an Object, and you are passing it an integer. The argument, fsize - 0, is interpreted as an Object, which is why the code does not produce an error. Therefore, the entire code snippet can be written like this:
Dim fsize As Object = CObj(180)
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, fsize , Nothing)
confused and bemused, maligned and resigned... bewilderment is not a balm for the pain !
|
|
|
|
 |
|
 |
Thanks for that.
I tried using a trackbar to give the value (percent of zoom) and came to the same problem, after putting trackbar1.value - 0 it work perfectly
Thanks
|
|
|
|
 |
|
 |
Hi , I too have the same problem . I tried the solution provided from u. But it says invalid arguments . I have to provide ref arguments ? What shall i do ? i want so save my webpage from the browser contol to a local file ?
|
|
|
|
 |
|
 |
Also if you try this while the IsBusy property is set to true then you will get an error. So, don't try to set the zoom level on form_load ... instead maybe use the DocumentCompleted event of the webbrowser control.
|
|
|
|
 |
|
 |
"-0" helped me out ..
The code..
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 Zoom25Percent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Zoom25Percent.Click
Try
Dim Res As Object = Nothing
Dim MyWeb As Object
MyWeb = Me.wbMain.ActiveXInstance
MyWeb.ExecWB(Exec.OLECMDID_OPTICAL_ZOOM, ExecOpt.OLECMDEXECOPT_DONTPROMPTUSER, 25 - 0, IntPtr.Zero)
Catch
End Try
End Sub
|
|
|
|
 |