Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Cannot resize my IWebBrowser2 Web Browser Control

Cannot resize my IWebBrowser2 Web Browser Control

Scheduled Pinned Locked Moved C / C++ / MFC
hardwarehelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Johann Gerell
    wrote on last edited by
    #1

    I have a problem with my embedded web browser control (IWebBrowser2). I try to resize it when it's host (which is a child of the main frame) gets WM_SIZING while the main frame is resized. I was under the apparently naîve impression that I could do this by calling put_Width and put_Height on the web browser in WM_SIZING. Making these calls actually triggers the DWebBrowserEvents2 events DISPID_WINDOWSETHEIGHT and DISPID_WINDOWSETWIDTH, but the size of the web browser control remains unchanged. Any guesses as to why this happen?

    -- Time you enjoy wasting is not wasted time - Bertrand Russel

    L 1 Reply Last reply
    0
    • J Johann Gerell

      I have a problem with my embedded web browser control (IWebBrowser2). I try to resize it when it's host (which is a child of the main frame) gets WM_SIZING while the main frame is resized. I was under the apparently naîve impression that I could do this by calling put_Width and put_Height on the web browser in WM_SIZING. Making these calls actually triggers the DWebBrowserEvents2 events DISPID_WINDOWSETHEIGHT and DISPID_WINDOWSETWIDTH, but the size of the web browser control remains unchanged. Any guesses as to why this happen?

      -- Time you enjoy wasting is not wasted time - Bertrand Russel

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Johann Gerell wrote:

      I try to resize it when it's host (which is a child of the main frame)

      Is there some reason you are not using CHtmlView?

      led mike

      J 1 Reply Last reply
      0
      • L led mike

        Johann Gerell wrote:

        I try to resize it when it's host (which is a child of the main frame)

        Is there some reason you are not using CHtmlView?

        led mike

        J Offline
        J Offline
        Johann Gerell
        wrote on last edited by
        #3

        led mike wrote:

        Is there some reason you are not using CHtmlView?

        Yes. If possible, I'm not letting MFC within a mile of my codebase. But please let's not discuss that now... :cool: Anyway, I'm now bypassing IWebBrowser2::put_Width/Height by moving the actual OLE object window, roughly like this (error checks omitted):

        ATL::CComPtr<IOleWindow> oleWindow;
        iOleObject_->QueryInterface(&oleWindow);

        HWND hwndBrowser = NULL;
        oleWindow->GetWindow(&hwndBrowser);

        ::MoveWindow(hwndBrowser, 0, 0, cx, cy, TRUE);

        As an interesting addition, I noticed that IWebBrowser2::get_HWND gives NULL for the window, where I expected the same result as querying the IOleWindow interface. :confused:

        -- Time you enjoy wasting is not wasted time - Bertrand Russel

        L 1 Reply Last reply
        0
        • J Johann Gerell

          led mike wrote:

          Is there some reason you are not using CHtmlView?

          Yes. If possible, I'm not letting MFC within a mile of my codebase. But please let's not discuss that now... :cool: Anyway, I'm now bypassing IWebBrowser2::put_Width/Height by moving the actual OLE object window, roughly like this (error checks omitted):

          ATL::CComPtr<IOleWindow> oleWindow;
          iOleObject_->QueryInterface(&oleWindow);

          HWND hwndBrowser = NULL;
          oleWindow->GetWindow(&hwndBrowser);

          ::MoveWindow(hwndBrowser, 0, 0, cx, cy, TRUE);

          As an interesting addition, I noticed that IWebBrowser2::get_HWND gives NULL for the window, where I expected the same result as querying the IOleWindow interface. :confused:

          -- Time you enjoy wasting is not wasted time - Bertrand Russel

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Johann Gerell wrote:

          Yes. If possible, I'm not letting MFC within a mile of my codebase.

          Ah, I see, you believe there is something wrong with MFC but you are fine with writing COM code. Did you read your own post?

          Johann Gerell wrote:

          As an interesting addition, I noticed that IWebBrowser2::get_HWND gives NULL for the window, where I expected the same result as querying the IOleWindow interface.

          Ok then, good luck.

          led mike

          J 1 Reply Last reply
          0
          • L led mike

            Johann Gerell wrote:

            Yes. If possible, I'm not letting MFC within a mile of my codebase.

            Ah, I see, you believe there is something wrong with MFC but you are fine with writing COM code. Did you read your own post?

            Johann Gerell wrote:

            As an interesting addition, I noticed that IWebBrowser2::get_HWND gives NULL for the window, where I expected the same result as querying the IOleWindow interface.

            Ok then, good luck.

            led mike

            J Offline
            J Offline
            Johann Gerell
            wrote on last edited by
            #5

            led mike wrote:

            you believe there is something wrong with MFC

            Yes.

            led mike wrote:

            but you are fine with writing COM code

            No. I'd avoid it if I could, but I'm not going to throw in MFC into my project just because I need HTML display functionality.

            led mike wrote:

            Did you read your own post?

            Yes. Multiple times. Since I'm not a native English speaker, I want to maximize the likelihood for anyone to understand what I mean. Why did you wonder that?

            led mike wrote:

            Ok then, good luck.

            Thanks.

            -- Time you enjoy wasting is not wasted time - Bertrand Russel

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups