Building SQHMTree

Create a new project

The first step is to create a new project.

Add the HoTMetaL interfaces to the SQHMTree project

We made SQHMTree an automation client of HoTMetaL PRO so that it can efficiently manipulate HoTMetaL PRO objects (such as Document, DOMNode, etc.). SQHMTree needs to have the information about the server (HoTMetaL PRO) objects' properties and methods. We made this information available to SQHMTree by creating dispatch classes from HoTMetaL PRO's type library and adding them to SQHMTree project:

Design CMyTreeCtrl

CMyTreeCtrl is derived from a standard MFC class: CTreeCtrl. It contains the hierarchical structure of an HTML document. A left mouse click on a tree item will cause HoTMetaL PRO to move the insertion point of the current document to the beginning of the node represented by the tree item that was clicked on.

 BOOL CMyTreeCtrl::LoadXMLDocElements()
{
     // Connect to HoTMetaL
     COleException e;
     _Application xmetalApp;
     if (!xmetalApp.CreateDispatch(XMETALAPP_GUID, &e)) {
          ::AfxMessageBox(IDS_ERR_DISPATCH);
          return S_FALSE;
}
     _Document xmetalDoc = xmetalApp.GetActiveDocument( ); 
		   
     // If not document open, display stub
     if (!xmetalDoc ) {
          // Insert a empty root item when no active document is open
          SetNoDocument(); 
		         
           return S_FALSE;
      }     DOMNode domEle = xmetalDoc.GetDocumentElement( );     
     // If no document element available, display stub
     if (!domEle ) {
                                    
          // Insert a empty root item when no active document is open           
          TV_INSERTSTRUCT      tvstruct;
          tvstruct.hParent =      NULL;
          tvstruct.hInsertAfter = TVI_SORT;
          tvstruct.item.iImage = 0;
          tvstruct.item.iSelectedImage = 0;
          tvstruct.item.pszText = __T("(empty)"); 
          tvstruct.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE 
                                          | TVIF_TEXT | TVIF_PARAM;
          InsertItem( &tvstruct );
               
          return S_FALSE;
}     
     // Insert the element names into the tree, starting with the root
     int index = 0;
     InsertElement( NULL, domEle, index );     
     // Enable "Refresh" context menu      
     m_menu.EnableMenuItem( ITEM_REFRESH_TREE, TRUE );     
     // Expand the tree to the first level
     Expand(GetRootItem(), TVE_EXPAND);     
     return TRUE;
}     

Design the ActiveX control CSQHMTreeCtrl

CSQHMTreeCtrl is the ActiveX control generated by the wizard. We need to do some modifications:

After successfully compiling the project, we now embed this control in HoTMetaL PRO, and use it as a tool to navigate the structure of the active HoTMetaL PRO document:

Since the SQHMTree control has its own scroll bar, you may want to disable the Resource Manager scroll bar. To do so, you only need to create an empty file named noscrollbar.txt in the treeView folder.


Right arrow
Next Topic
Left arrow
Previous Topic
Table of contents
Table of Contents

Copyright © SoftQuad Software Inc. 1999