Hi
I have dialog that contains only wxHtmlWindow. In a dialog constructor I load html page to this wxHtmlWindow, and I want that window have normal size when appear. So, wxHtmlWindow control should show all html page without scroll bars and blank field and winwow's size should be == size of wxHtmlWindow control.
Problem is I can't force wxHtmlWindow to get real size of loaded html. Any ideas?
How to get size of wx wxHtmlWindow Topic is solved
How to get size of wx wxHtmlWindow
Best regards, Nikolay
wxWidgets in russian
Small Notes Manager and Clipboard Manager with History written with wxWidgets
wxWidgets in russian
Small Notes Manager and Clipboard Manager with History written with wxWidgets
-
- wxWorld Domination!
- Posts: 1471
- Joined: Tue Nov 14, 2006 7:58 am
- Location: Saint-Petersburg, Russia
Re: How to get size of wx wxHtmlWindow
Hi,
try this:Nikolay wrote:Hi
I have dialog that contains only wxHtmlWindow. In a dialog constructor I load html page to this wxHtmlWindow, and I want that window have normal size when appear. So, wxHtmlWindow control should show all html page without scroll bars and blank field and winwow's size should be == size of wxHtmlWindow control.
Problem is I can't force wxHtmlWindow to get real size of loaded html. Any ideas?
Code: Select all
wxSize vs = html_window->GetVirtualSize();
SetClientSize(vs); // For the parent
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10
This does not work in Create(). So, I have created timer and resize window after 10 ms... But there is still some problems with window visible and size - GetVirtualSize() returns correct width but incorect height. I'll try to fix it in few after week end.
Thanks for help.
Thanks for help.
Best regards, Nikolay
wxWidgets in russian
Small Notes Manager and Clipboard Manager with History written with wxWidgets
wxWidgets in russian
Small Notes Manager and Clipboard Manager with History written with wxWidgets
Re: How to get size of wx wxHtmlWindow
I just faced a very similar problem. I am using an instance wxHtmlWindow to show a super tool tip (like Excel), and I want no scroll bars and for it to be just large enough to display the contents. There is no predetermined way of doing that , but this is how I got the result I wanted . Works perfectly!
To get a nice rectangle around the outer edges of the window, I also did this:
And then my tip contents is wrapped around a matrix with a border but with the cell spacing set to zero.
The end result is you get an HTML window that is just big enough to show its contents, no scroll bars, and it has a nice border line around it.
Code: Select all
//There is no way to get the perfect height for the window.
//So we set it to something too small for starters:
int ySize = 50;
int xSize = 200;
mywxHTML->SetSize(xSize, ySize);
//Now if we got a vertical scroll bar, then make the window taller,
//to get rid of the scroll bar:
int vxSize=0;
int vySize=0;
mywxHTML->GetVirtualSize(&vxSize, &vySize);
if (vySize > ySize)
{
mywxHTML->SetSize(xSize, vySize);
}
//Now reset the text to make it redo the layout and sizes:
wxString wxEmpty;
mywxHTML->SetPage(wxEmpty);
mywxHTML->SetPage(html2);
//Now get the final size, which may have reduced more since the scroll bar
//is now gone.
wxHtmlContainerCell* cell = mywxHTML->GetInternalRepresentation();
if (cell)
{
int height = cell->GetHeight();
mywxHTML->SetSize(xSize, height + oborder + oborder);
}
//Show it:
mywxHTML->Show(true);
//Make sure it is seen:
mywxHTML->Raise();
Code: Select all
mywxHTML->SetBorders(1);
Code: Select all
<body bgcolor="xxx background colour goes here xxx">
<table width="100%" border="1" cellspacing="0" cellpadding="8"><tr><td>
xxx tip text HTML goes here xxx
</td></tr></table>
</body>