resize web browser control
I have a dialog based MFC application using Microsoft web browser control(IWebBrowser2). From the first version, I disabled the maximize box and used non-resizable border to avoid the painful layout of GUI elements. Now I want to make it resizable, so I edited the properties in resources: now the dialog itself is resizable, but the Active X control doesn't.
I truned to google and hope it can be sovled in 5 minutes, but the search is
not very successful. After about an hour I solved the problem myself, even though it is very simple, I decided to write it down so that another poor man can get helped.
The solution is to use the OnSize() Event to size our control:
I truned to google and hope it can be sovled in 5 minutes, but the search is
not very successful. After about an hour I solved the problem myself, even though it is very simple, I decided to write it down so that another poor man can get helped.
The solution is to use the OnSize() Event to size our control:
BEGIN_MESSAGE_MAP(CWebBrwoserDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_SIZE()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CWebBrwoserDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);//Call parent's OnSize first
if (m_browser.GetSafeHwnd() != NULL))//Make sure the windows is created.
{
m_browser.MoveWindow(0, 0, cx, cy);//resize browser control
}
}
0 Comments:
Post a Comment
<< Home