|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Neil Martin
|
Feb 19, 2004 - 3:27 PM
|
Is it possible to use a CHtmlView as the child of a CExtControlBar? If so, could someone provide me with some sample code which achieves this? thanks Neil
|
|
Sergiy Lavrynenko
|
Feb 20, 2004 - 4:01 AM
|
Dear Neil,
You can create and use any window as a child of any other window. So, you can freely use any view inside the Prof-UIS resizable bar. The question is only how to do this ;-) I assume your main frame has m_wndResizableBarWithHtmlView resizable bar and it is created in CMainFrame::OnCreate() :
if( ! m_wndResizableBarWithHtmlView.Create(
NULL, // _T("Optional control bar caption"),
this,
ID_VIEW_RESIZABLEBAR_HTML_VIEWER
)
)
{
TRACE0("Failed to create m_wndResizableBarWithHtmlView\n");
ASSERT( FALSE );
return -1; // fail to create
}
Now create CHtmlView as a child of the resizable bar:
CHtmlView * pView =
STATIC_DOWNCAST(
CHtmlView,
RUNTIME_CLASS(CHtmlView) -> CreateObject()
);
if( ! pView->Create(
::AfxRegisterWndClass(0),
_T(""),
WS_CHILD|WS_VISIBLE,
CRect(0,0,0,0),
&m_wndResizableBarWithHtmlView,
UINT(IDC_STATIC),
NULL
)
)
{
TRACE0("Failed to create html view\n");
ASSERT( FALSE );
return -1; // fail to create
}
pView->Navigate2( _T("http:\\\\www.prof-uis.com") );
That’s all. You can keep the pView pointer and use it. Please note, any kind of CView is deleted automatically in CView::PostNcDestroy() . So, your app should never invoke something like delete pView .
You can download the sample project which creates CHtmlView window inside CExtControlBar window here (please take a look at the CMainFrame::OnCreate() method in this sample).
Best regards, Sergiy.
|
|