Click to open or copy the HIERSVR project files.
HIERSVR is an example of a Visual Editing server application that supports linked objects as well as in-place edited objects. In addition, as a "full" server, this application also can directly open and save files. The HIERSVR object is a multiple-level hierarchy diagram, where each node in the hierarchy consists of text surrounded by a rectangle or other shapes. In addition to illustrating server functionality, HIERSVR also illustrates OLE drag and drop, and copying to the Clipboard.
You must run HIERSVR as a stand-alone application once to register its ActiveX™ type with the system.
The type of document or object HIERSVR edits and displays is a single inheritance hierarchy diagram. Each node in the diagram, except the root node, has only one parent node. Each parent may have multiple children. A company's organization chart is an example of a hierarchy diagram. So is the list of the Microsoft Foundation Class Library (MFC) classes, since they do not use C++ multiple inheritance. In fact, Mfcclass.hie is included as an example HIERSVR document.
Every node in the hierarchy has a minimal set of attributes.
A new HIERSVR diagram begins as a single node with the text "Root node." To add a node, first select its parent node by clicking it. Then click Add Node on the Edit menu. In the Add Node dialog box, specify the three attributes described above. To change the attributes of a node, select it with a mouse click, and then click Change Node. To move a node, click it and drag to the new location.
HIERSVR will import hierarchy information from a text file formatted as follows: The text in each line (delimited by a line feed) is the node's Description. The number of tab characters preceding the text determines the level of the node in the hierarchy. In the HIERSVR sample directory, Mfcclass.txt is the text import file for Mfcclass.hie, the native HIERSVR file.
To link a hierarchy diagram to a client document, you must first save the file in HIERSVR. Then select the node you want to copy using Edit Copy. This will copy the link to the Clipboard. The text of the selected node will also be copied to the Clipboard in the CF_TEXT format, and the entire hierarchy of nodes will be copied in a HIERSVR-native clipboard format. Saving the document is required because the link format requires a document name. Finally, in the client application, click Edit Paste Link (or click Paste Link on the Edit Paste Special menu). The link will be displayed in the client document as the node that you selected before clicking Edit Copy. The rectangle will also be displayed.
To embed a hierarchy diagram in a client document, you can either use a clipboard procedure similar to that above for linking the object, or click Insert New Object in the client application. If you choose the clipboard procedure, use Edit Paste rather than Edit Paste Link in the client application. Only the subhierarchy starting at the selected node will be embedded in the client document.
Whether you link or embed the diagram, only the top selected node will be displayed in the client application window. To see the rest of the diagram, you will need to launch HIERSVR from the client application by double-clicking the item.
HIERSVR illustrates the class derivations necessary to implement a fully functional Visual Editing server application, and also illustrates some of the most common client application user interfaces that require additional code.
The three framework classes used to implement a Visual Editing server application are illustrated by the following.
See Help: Compiling and Testing Your Help File for information on how to compile your help file.
This sample demonstrates the following keywords:
AfxGetMainWnd; AfxMessageBox; AfxOleInit; AfxThrowMemoryException; AfxThrowNotSupportedException; AfxThrowResourceException; CArchive::Close; CCmdTarget::BeginWaitCursor; CCmdTarget::EndWaitCursor; CCmdUI::Enable; CCmdUI::SetCheck; CControlBar::EnableDocking; CControlBar::GetBarStyle; CControlBar::SetBarStyle; CDC::GetDeviceCaps; CDC::LPtoDP; CDC::LPtoHIMETRIC; CDC::SelectObject; CDC::SetMapMode; CDC::SetViewportExt; CDC::SetWindowExt; CDialog::DoModal; CDialog::OnInitDialog; CDocTemplate::SetServerInfo; CDocument::DeleteContents; CDocument::GetFirstViewPosition; CDocument::GetNextView; CDocument::OnNewDocument; CDocument::SetModifiedFlag; CDocument::UpdateAllViews; CFile::Open; CFileDialog::DoModal; CFileDialog::GetPathName; CFontDialog::DoModal; CFontDialog::GetColor; CFrameWnd::Create; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::LoadFrame; CMenu::GetSubMenu; CMenu::LoadMenu; CMenu::TrackPopupMenu; CObList::AddHead; CObList::AddTail; CObList::GetCount; CObList::GetHeadPosition; CObList::GetNext; CObList::GetTail; CObList::RemoveAll; CObList::RemoveAt; CObject::AssertValid; CObject::Dump; CObject::Serialize; COleDataObject::AttachClipboard; COleDataObject::GetFileData; COleDataObject::IsDataAvailable; COleIPFrameWnd::OnCreateControlBars; COleLinkingDoc::OnGetLinkedItem; COleServerDoc::GetItemPosition; COleServerDoc::IsInPlaceActive; COleServerDoc::OnDeactivateUI; COleServerDoc::OnGetEmbeddedItem; COleServerDoc::OnSetItemRects; COleServerDoc::RequestPositionChange; COleServerDoc::UpdateAllItems; COleServerItem::CopyToClipboard; COleServerItem::DoDragDrop; COleServerItem::GetClipboardData; COleServerItem::GetDataSource; COleServerItem::GetDocument; COleServerItem::GetItemName; COleServerItem::IsLinkedItem; COleServerItem::OnDraw; COleServerItem::OnGetClipboardData; COleServerItem::OnGetExtent; COleServerItem::OnOpen; COleServerItem::OnRenderFileData; COleServerItem::SetItemName; COleTemplateServer::ConnectTemplate; COleTemplateServer::UpdateRegistry; CPen::CreatePen; CRect::BottomRight; CRect::Height; CRect::InflateRect; CRect::IntersectRect; CRect::OffsetRect; CRect::PtInRect; CRect::Size; CRect::TopLeft; CScrollView::GetDeviceScrollPosition; CScrollView::ScrollToPosition; CScrollView::SetScrollSizes; CString::Empty; CString::GetLength; CString::IsEmpty; CToolBar::Create; CToolBar::LoadBitmap; CToolBar::SetButtons; CView::GetDocument; CView::OnDragEnter; CView::OnDragLeave; CView::OnDragOver; CView::OnDraw; CView::OnDrop; CView::OnInitialUpdate; CView::OnPrepareDC; CView::OnUpdate; CWinApp::AddDocTemplate; CWinApp::Enable3dControls; CWinApp::EnableShellOpen; CWinApp::ExitInstance; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::RegisterShellFileTypes; CWnd::ClientToScreen; CWnd::DoDataExchange; CWnd::GetClientRect; CWnd::GetParentFrame; CWnd::Invalidate; CWnd::InvalidateRect; CWnd::OnCreate; CWnd::OnKeyDown; CWnd::OnLButtonDblClk; CWnd::OnLButtonDown; CWnd::OnRButtonDown; CWnd::OnSize; CWnd::SetOwner; CWnd::ShowWindow; CWnd::UpdateWindow; CreateFontIndirect; DragAcceptFiles; EnableWindow; ExtTextOut; GetDeviceCaps; GetSysColor; GetTextExtent; GetWindowTextLength; IsChild; LPtoDP; LineTo; LoadBitmap; MoveTo; MulDiv; RGB; RectVisible; Rectangle; RegisterClipboardFormat; RoundRect; SelectObject; SetTextColor; SetViewportExt; SetWindowExt; SetWindowOrg; _alloca; afxMemDF; lstrcpy; memset; min; strlen; wcstombs