Example code for this program. Go back to Blitzcode.NET. |
#include "Shiny.h"
#include "resource.h"
class CMyApp : public _ShApp, public _ShWindow
{
public:
int Main()
{
_ShMenu mnuMain(IDM_MENU);
Create(WS_SYSMENU, NULL, NULL, "XML Tree", NULL, mnuMain);
Reshape(300, 450);
CenterOnScreen();
m_wndTree.Create(this);
m_wndTree.SetWindowPos(GetClientRect());
_ShXMLFile cXML;
_ShXMLFile::XMLNode *pNode = cXML.Parse("Test.xml");
Recurse(pNode, NULL);
cXML.Delete(pNode);
m_wndTree.ExpandAll();
ShowWindow();
return _ShMainLoop();
}
protected:
_SH_BEGIN_MSG_MAP()
_SH_MSG_HANDLER(WM_CLOSE, OnClose)
_SH_BEGIN_CMD_HANDLER()
_SH_CMD_HANDLER(ID_FILE_EXIT, OnClose)
_SH_END_CMD_HANDLER_BASE()
_SH_END_MSG_MAP_BASE()
_ShTreeView m_wndTree;
void Recurse(_ShXMLFile::XMLNode *pNode, HTREEITEM hParent)
{
HTREEITEM hNewParent = hParent;
if (pNode->bWord)
hNewParent = m_wndTree.AddItemToTree(pNode->pszWord, NULL, hParent);
else
Recurse(pNode->pList, hParent);
if (pNode->pNext)
Recurse(pNode->pNext, hNewParent);
}
_SH_DECL_MSG(OnClose)
{
PostQuitMessage(0);
return 0;
}
};
_SH_DECLARE(CMyApp)