Home | Overview | How Do I | Sample | Tutorial
This article explains what you must do to implement in-place frame windows in your visual editing server application if you do not use AppWizard to create your server application. In place of following the procedure outlined in this article, you could use an existing in-place frame-window class from either an AppWizard-generated application or a sample provided with Visual C++.
To declare an in-place frame-window class
Declare an OnCreate message handler (using ClassWizard), Call Create for your COleResizeBar member, if you’ve defined it.
Override the OnCreateControlBars member function to create a toolbar when the server is active in place. For example:
BOOL CInPlaceFrame::OnCreateControlBars
(CWnd* pWndFrame, CWnd* pWndDoc)
{
// create toolbar on client's frame window
if (!m_wndToolBar.Create(pWndFrame) ||
!m_wndToolBar.LoadToolBar(IDR_PROJ_SRVR_IP))
{
TRACE("Failed to create toolbar\n");
return FALSE;
}
// set this window as owner, so messages are
// delivered to proper app
m_wndToolBar.SetOwner(this);
// enable docking for the toolbar
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
pWndFrame->EnableDocking(CBRS_ALIGN_ANY);
pWndFrame->DockControlBar(&m_wndToolBar);
// enable tooltips for the toolbar
m_wndToolBar.SetBarStyle(CBRS_TOOLTIPS |
CBRS_FLYBY | m_wndToolBar.GetBarStyle());
return TRUE;
}
See the discussion of this code following step 5.
The series of function calls in the if statement creates the toolbar from the resources the server provided. At this point, the toolbar is part of the container’s window hierarchy. Because this toolbar is derived from CToolBar, it will pass its messages to its owner, the container application’s frame window, unless you change the owner. That is why the call to SetOwner is necessary. This call changes the window where commands are sent to be the server’s in-place frame window, causing the messages to be passed to the server. This allows the server to react to operations on the toolbar that it provides.
The ID for the toolbar bitmap should be the same as the other in-place resources defined in your server application. See the article Menus and Resources: Server Additions for details.
For more information, see COleIPFrameWnd, COleResizeBar, and CDocTemplate::SetServerInfo in the Class Library Reference.
See Also Servers: Implementing a Server, Servers: Implementing Server Documents, Servers: Server Items