Webpage Width on first launch

I have a need to resize a control on a Webpage. It appears that the Webpage.WIDTH property is set to the size in the inspector dialog width value DESIGN TIME value when first shown even if the browser window is a different width. The Webpage RESIZED event DOES correctly reflect the correct browser with if you reset the size.

How can I detect the initial browser width when the program launches?

Does the resized event not fire when the page is loaded?

I’m not seeing this. In my tests, the Page size in the Page Shown event reflects the actual browser window size, and also in the control’s Shown event. Now, in the control’s Resize event (a WebTextArea), the Page size does shows the design time size. But interestingly though, if you use locking on the control to make it automatically resize, it resizes to the correct size before it’s Resize event. So the resize logic must be getting the page size values from somewhere else.

Not me in 2014r1.

This shows the design time setting when put into the WebPage Shown event of the page in question.

system.debuglog("Shown "+str(WebPagePATadviceSingle.Width))

[quote=74698:@Mark Strickland]Not me in 2014r1.

This shows the design time setting when put into the WebPage Shown event of the page in question.

system.debuglog("Shown "+str(WebPagePATadviceSingle.Width))[/quote]
Again, not for me, also in 2014r1. But mine is in a brand new project. There must be something else in your project that’s causing this. Try it in a new project and see what you get.

This is on OSX for me and Safari as the browser.

Yep, OS X 10.9.2 here - Firefox, Chrome and Safari all show the correct results.


Thanks for the insight. Obviously something is odd about my project.

If I ever resize the browser then the correct page with is then always returned. If I display a slide down dialog for any reason I get a resize event on that page and again the page width is always returned correctly.

OK — I found it. I put a debug to display the WebPage.Width of the logon screen (first screen to launch) and it is correct.

The page in question I was testing uses Taylor Design WebCustomControls on that particular page. It appears that is interfering with the ability to get the page width until a resize event occurs.

My solution will be to set up a session variable to capture the page width of the login screen then use that to resize my control. (Actually it is one of the Taylor Design controls). I will have to pass this on to Daniel Taylor.

Thanks for the help.

Interesting. Which WCC control are you using? I can test it to see if I get the same behavior.


I am using the HtmlAreaTD control on this page.

The control has a very odd look if you lock the left AND right if the browser page is bigger than the design time of the page. The vertical scroll bar ends up at the location as if the browser window was at the design time width BUT the control is clearly wider. The effect is the text is to the left and the vertical scroll bar is in the middle of the control (more or less depending on the browser width).

I discovered that if you resize the control in the SHOWN event it does work as expected but without knowing the browser window width I could not calculate a resize.

I contacted Daniel Taylor some time ago about the odd behavior of the vertical scroll bar and he gave me the suggestion of resizing the control but I have just now started to look at that issue.

It appears that there is some sort of interaction with the control and XOJO regarding the page width.

When you test let me know what you see and maybe we can report to Daniel with something he can find.


Ahh, I know what you’re missing - I learned this the hard way myself, as this is not in the docs for the WebHtmlAreaTD control but in the docs for the base class WebCustomControlTD. You have to call the .AdjustLayout method on the control whenever it is resized. It’s easiest to just add the wccContentResize event to the control and then issue Me.AdjustLayout there.