Cannot resize my IWebBrowser2 Web Browser Control
-
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) getsWM_SIZING
while the main frame is resized. I was under the apparently naîve impression that I could do this by callingput_Width
andput_Height
on the web browser inWM_SIZING
. Making these calls actually triggers theDWebBrowserEvents2
eventsDISPID_WINDOWSETHEIGHT
andDISPID_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
-
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) getsWM_SIZING
while the main frame is resized. I was under the apparently naîve impression that I could do this by callingput_Width
andput_Height
on the web browser inWM_SIZING
. Making these calls actually triggers theDWebBrowserEvents2
eventsDISPID_WINDOWSETHEIGHT
andDISPID_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
-
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
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 theIOleWindow
interface. :confused:-- Time you enjoy wasting is not wasted time - Bertrand Russel
-
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 theIOleWindow
interface. :confused:-- Time you enjoy wasting is not wasted time - Bertrand Russel
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
-
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
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