Announcement

Collapse
No announcement yet.

Maximum Zoom in Browser

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maximum Zoom in Browser

    When I zoom in on a page of a browser, created with Jose's embedded browser code, there seems to be a maximum text size of about about 2 inches in height - perhaps 200 pixels or so.

    I've read on the web that some browsers do have zoom limits, but the numbers I've seen have been 1000+ pixels.

    Does anyone know how to override the height limitation that I'm seeing, or know that the limit cannot be overridden?

    I'm interested in creating text sizes of 10+ inches in height.

    Here's my

    Code:
    Sub ZoomIn
       Local pIWebBrowser2 As IWebBrowser2
       Local  vZoom        As Variant            ' // Zoom
       ' // Call the ExecWB method to get the current zoom factor
       pIWebBrowser2 = OC_GetDispatch(hBrowser)
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, ByVal %NULL, vZoom
       ZoomFactor *= 1.5    'somewhere around 2K this no longer changes the display size
       ' // Call the ExecWB method to set the new zoom factor
       vZoom = ZoomFactor As Long   ' The 'AS LONG' part is important!
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
       pIWebBrowser2 = Nothing
    End Sub
    I can do it easily with a textbox or graphic control. They don't seem to have any built-in limitation on size - accepting/displaying whatever font size I give them.

  • #2
    Compilable version to play with ...

    Code:
    'Compilable Example:
    #Compile Exe
    #Dim All
    %Unicode = 1
    %UseWebBrowser = 1            ' // Use the WebBrowser control
    #Include Once "CWindow.inc"   ' // CWindow class
    %IDC_WebBrowser = 1001
    %IDC_ZoomIn      = 1002
    %IDC_ZoomOut    = 1003
    %IDC_Zoom100    = 1004
    
    Global hDlg, hBrowser As Dword
    
    Function PBMain
       Local pWindow As IWindow
       Dialog New Pixels, 0, "WebBrowser",0, 40, 800, 600, %WS_OverlappedWindow To hDlg
       Control Add Button, hDlg, %IDC_ZoomIn, "ZoomIn", 10,10,50,25
       Control Add Button, hDlg, %IDC_ZoomOut, "ZoomOut", 110,10,50,25
       Control Add Button, hDlg, %IDC_Zoom100, "Zoom100", 210,10,50,25
       pWindow = Class "CWindow"
       hBrowser = pWindow.AddWebBrowserControl(hDlg, %IDC_WEBBROWSER, "http://www.garybeene.com", Nothing, 0, 40, 800,600)
       Dialog Show Modal hDlg, Call DlgProc
    End Function
    
    CallBack Function DlgProc() As Long
       Local pIWebBrowser2 As IWebBrowser2
       Select Case Cb.Msg
           Case %WM_Command
               Select Case Cb.Ctl
                   Case %IDC_ZoomIn  : ZoomIn
                   Case %IDC_ZoomOut : ZoomOut
                   Case %IDC_Zoom100 : Zoom100
               End Select
       End Select
    End Function
    
    Sub ZoomIn
       Local pIWebBrowser2 As IWebBrowser2
       Local  nZoom        As Long               ' // Zoom
       Local  vZoom        As Variant            ' // Zoom
       ' // Call the ExecWB method to get the current zoom factor
       pIWebBrowser2 = OC_GetDispatch(hBrowser)
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, ByVal %NULL, vZoom
       nZoom = Variant#(vZoom)
       'If nZoom < 990 Then nZoom +=10
       nZoom +=100
       Dialog Set Text hDlg, "nZoom = " + Str$(nZoom)
       ' // Call the ExecWB method to set the new zoom factor
       vZoom = nZoom As Long   ' The 'AS LONG' part is important!
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
       pIWebBrowser2 = Nothing
    End Sub
    
    Sub ZoomOut
       Local pIWebBrowser2 As IWebBrowser2
       Local  nZoom        As Long               ' // Zoom
       Local  vZoom        As Variant            ' // Zoom
       ' // Call the ExecWB method to get the current font zoom scale
       pIWebBrowser2 = OC_GetDispatch(hBrowser)
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, ByVal %NULL, vZoom
       nZoom = Variant#(vZoom)
       If nZoom > 20 Then nZoom -=10
       ' // Call the ExecWB method to set the new font zoom scale
       vZoom = nZoom As Long   ' The 'AS LONG' part is important!
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
    End Sub
    
    Sub Zoom100
       Local pIWebBrowser2 As IWebBrowser2
       Local  vZoom        As Variant            ' // Zoom
       pIWebBrowser2 = OC_GetDispatch(hBrowser)
       vZoom = 100 As Long   ' The 'AS LONG' part is important!
       pIWebBrowser2.ExecWB %OLECMDID_OPTICAL_ZOOM, %OLECMDEXECOPT_DONTPROMPTUSER, vZoom
    End Sub
    
    'gbs_01336
    'Date: 05-11-2013

    Comment


    • #3
      > I've read on the web that some browsers do have zoom limits, but the numbers I've seen have been 1000+ pixels.

      It does not say pixels, but percent.

      OLECMDID_OPTICAL_ZOOM
      Windows Internet Explorer 7 and later. Sets the zoom factor of the browser. Takes a VT_I4 parameter in the range of 10 to 1000 (percent).
      https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment

      Working...
      X