PDA

View Full Version : can't set size of webbrowser-control



martin
03-08-2009, 11:53
Hi everybody,

I have a TAB control.
In one of the tab windows I created a WebBrowser-control with: WebBrowser_Create cbhndl, 999, "", 0, 25, -1,-1

So far so good, but changing the size of the WebBrowser-control doesn't work good:
DIM xx,yy AS LONG
DIALOG GET CLIENT cbhndl TO xx, yy
CONTROL SET SIZE cbhndl,999,xx,yy

The values returned by XX and YY are okay, but somehow the Webbrowser does not respond to those values. Is there a way to solve this?

B.t.w. same problem with Viewport control. But textbox for example works fine.

:? :? :?

Petr Schreiber
03-08-2009, 12:26
Hi Martin,

I am sorry, but it seems to work for me, see this:


'------------------------------------------------------------------
' Pre-processor prerequisites
'------------------------------------------------------------------
#minversion 1.7.8.0

'------------------------------------------------------------------
' Declare needed thinBasic modules
'------------------------------------------------------------------
USES "UI"
USES "UIAdv"

'------------------------------------------------------------------
' Global declarations
'------------------------------------------------------------------
begin const
%ID_WEB1 = 200
%ID_Main_TAB
end const

'------------------------------------------------------------------
' Main script entry point
'------------------------------------------------------------------
function TBMain() as long
local hDlg AS LONG
local Count as long

'---Create a new window
DIALOG NEW pixels, 0, "Web Browser control test", _
-1, -1, 640, 500, _
%WS_CLIPCHILDREN or _
%WS_CLIPSIBLINGS or _
%WS_DLGFRAME OR _
%DS_CENTER OR _
%WS_CAPTION OR _
%WS_SYSMENU OR _
0 _
TO hDlg


'---Show new window and assign it callback function
DIALOG SHOW MODAL hDlg, call cbDialog_Proc

end function

'------------------------------------------------------------------
' Window callback handle. Use to handle message pump of main window
'------------------------------------------------------------------
callback function cbDialog_Proc() as long
local sStr as string
local lValue as long
local dw, dh as long
SELECT CASE cbMsg

CASE %WM_INITDIALOG
dialog get client cbhndl to dw, dh
CONTROL ADD TAB, cbhndl, %ID_Main_TAB, "", 5, 0, dw-200, dh-200

TAB_PageInsert cbhndl, %ID_Main_TAB, 1, 0, "First" call cbTabWithBrowser
TAB_PageInsert cbhndl, %ID_Main_TAB, 2, 0, "Second"

TAB_SetSelected(cbhndl, %ID_Main_TAB, 1)


case %WM_DESTROY

case %WM_COMMAND
select case cbctl
case %ID_OK
'sStr = WebBRowser_Doc2_GetElementAttributeById(cbhndl, %ID_WEB1, "WouldLike", "innerHTML")
'msgbox 0, sStr
'sStr = WebBRowser_Doc2_GetElementInnerHtmlById(cbhndl, %ID_WEB1, "Output")
'msgbox 0, acode$(sStr)

end select
END SELECT

end function

callback function cbTabWithBrowser()
local xx, yy as long

select case cbMsg
case %WM_INITDIALOG
WebBrowser_Create cbhndl, %ID_WEB1, "", 0, 0, 620, 430, %WS_CHILD Or %WS_VISIBLE, 0
WebBrowser_Navigate2(cbhndl, %ID_WEB1, "http://www.google.com/")

DIALOG GET CLIENT cbhndl TO xx, yy
CONTROL SET SIZE cbhndl,%ID_WEB1,xx,yy

end select

end function


Are you sure 999 is not ID of something else? For this reason I use and recommend begin const / end const autobuilding of IDs.

Or maybe you got CBHNDL of the main dialog, and not of the TAB frame itself?


Petr

martin
03-08-2009, 12:35
Hi Petr!

Thanks for you code. When I run it I get this:

http://i30.tinypic.com/av0c2u.jpg

This is not good I suppose....

Petr Schreiber
03-08-2009, 12:37
Martin,

I thought ... that is exactly what you want :shock:?

The webbrowser, created inside tab, fits whole client of the "First" frame.

Could you explain in more detail what do you need? :)


Petr

martin
03-08-2009, 13:38
Sorry Petr, you are right your example does exactly what I was asking. I only thought the tab should be as big as the window but that was my mistake, I should have looked at your code first.

However I think I discovered now my problem. I created a dialog in UNITS, not PIXELS like you did. I changed this and it works fine now! :occasion:

But still strange that it doesn't work correctly with a dialog in units...

Greetings,

Martin

Petr Schreiber
03-08-2009, 13:42
Martin,

good point!
I will make a bug report, this should work for both cases.

martin
04-08-2009, 08:23
Hi Petr,

Sorry one more question:

If you change this line in your script (remove the zero to enable maximize and resize buttons):

DIALOG NEW pixels, 0, "Web Browser control test", -1, -1, 640, 500, %WS_CLIPCHILDREN | %WS_DLGFRAME | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW | %WS_CLIPSIBLINGS TO hDlg

Now run your script and MAXIMIZE the dialog and then move another window over it (i.e. thinair or your internet browser). You will notice that the dialog doesn't redraw. I noticed this in other examples too and in my own script as well. Is this a bug or can I redraw the dialog somewhere in a callback event? I already tried %wm_paint but no succes.

Thanks in advance for your time.

Martin

Petr Schreiber
04-08-2009, 08:31
Hi Martin,

no problem.
This is the same case as we discussed for tab example few weeks ago - the bestial curse of %WS_CLIPCHILDREN :)

Just remove it, so dialog creation will look like:


DIALOG NEW pixels, 0, "Web Browser control test", -1, -1, 640, 500, %WS_DLGFRAME | %WS_CAPTION | %WS_SYSMENU | %WS_OVERLAPPEDWINDOW | %WS_CLIPSIBLINGS TO hDlg


Now the redraw will be handled correctly.

martin
04-08-2009, 09:24
Oops I forgot that :oops: :oops:
It works fine now, thanks a lot! :eusadance: