-
December 25th, 2008, 04:37 AM
#1
Positioning a WebBrowser control
Hello all:
I need to include a WebBrowser control in a window -most exactly in a dialog box-. I'm using Visual C++ and the Windows API "bareback", I mean without MFC or ATL.
I managed to include it in a way that addresses the entire client area of the dialog box, but the problem is that I need that the Web control address only certain position, because the rest of the client area is occupied by the usual buttons, texts and other controls that are usually included in the dialog boxes.
I tried two ways of solution:
1 .- The control stems directly from the dialog box (say dialogHwnd) and use the methods
put_Left()
put_Top()
put_Width()
put_Height()
of the IWebBrowser2 interface to position de control, but without result, since the control does not change position (continues to occupy the entire space of the container).
2 .- I tried to derive the control of an child window defined within the dialog box (say of childWindowHwnd). The problem is that the control -the Web page you should see- does not appear inside of the window (or elsewhere).
Of course, any light or guidance on how to do it, or on what I'm wrong, will be largely rewarded :-)
-
December 26th, 2008, 02:50 AM
#2
Re: Positioning a WebBrowser control
Once your control lies in a dialog (which I presume is based on a dialog template resource) the most handy method is to set it's position/size from scratch in the resource editor.
However, if you realy need to move/resize it at run-time, then you can use MoveWindow or SetWindowPos. For that, you have to do the following steps:
- Using control's window handle get it's rectangle by a call of GetWindowRect; aso may be possible to need the window rectangle of other controls to further calculate your control's new position/size.
- Using parent window (dialog) handle call ScreenToClient to transform control's screen coordinates in coordinates relative to parent client area.
- Calculate new control's coordinates (or rectangle) as you need.
- Using the control's window handle call MoveWindow or SetWindowPos
-
December 26th, 2008, 02:24 PM
#3
Re: Positioning a WebBrowser control
ovidiucucu: thanks for your reply
My problem is not how to position or resize a child window in a dialog box. I believe is my lack of a good understand of the interaction between the WebBrowser control itself and its window container. At this moment I'm trying to understand just an example of this site: the Mausau's Web Custom Control ( http://www.codeguru.com/cpp/controls...cle.php/c5201/ )
Unfortunately it uses a rather advanced OOP technique and the logic is a hard to understand.
-
December 28th, 2008, 05:05 AM
#4
Re: Positioning a WebBrowser control
Just use the native OCX hosting control and position this one.
-
December 28th, 2008, 01:05 PM
#5
Re: Positioning a WebBrowser control
Originally Posted by fred100
Just use the native OCX hosting control and position this one.
Native of who?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|