// TreeViewDlg.cpp // // (c)1998-2025 Codejock Software, All Rights Reserved. // // THIS SOURCE FILE IS THE PROPERTY OF CODEJOCK SOFTWARE AND IS NOT TO BE // RE-DISTRIBUTED BY ANY MEANS WHATSOEVER WITHOUT THE EXPRESSED WRITTEN // CONSENT OF CODEJOCK SOFTWARE. // // THIS SOURCE CODE CAN ONLY BE USED UNDER THE TERMS AND CONDITIONS OUTLINED // IN THE XTREME TOOLKIT PRO LICENSE AGREEMENT. CODEJOCK SOFTWARE GRANTS TO // YOU (ONE SOFTWARE DEVELOPER) THE LIMITED RIGHT TO USE THIS SOFTWARE ON A // SINGLE COMPUTER. // // CONTACT INFORMATION: // support@codejock.com // http://www.codejock.com // ///////////////////////////////////////////////////////////////////////////// #include "StdAfx.h" #include "Resource.h" #include "TreeViewDlg.h" #include "MessageRecord.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif const int COLUMN_MAIL_ICON = 0; const int COLUMN_CHECK_ICON = 2; ///////////////////////////////////////////////////////////////////////////// // CTreeViewDlg dialog CTreeViewDlg::CTreeViewDlg(CWnd* pParent) : CDialog(CTreeViewDlg::IDD, pParent) { //{{AFX_DATA_INIT(CTreeViewDlg) m_bNotificationExpanded = FALSE; //}}AFX_DATA_INIT } void CTreeViewDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CTreeViewDlg) DDX_Control(pDX, IDC_GRID, m_wndGrid); DDX_Check(pDX, IDC_NOTIFICATION_EXPANDED, m_bNotificationExpanded); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CTreeViewDlg, CDialog) //{{AFX_MSG_MAP(CTreeViewDlg) ON_BN_CLICKED(IDC_EXPAND, OnExpand) ON_BN_CLICKED(IDC_COLLAPSE, OnCollapse) ON_BN_CLICKED(IDC_NOTIFICATION_EXPANDED, OnNotificationExpanded) //}}AFX_MSG_MAP ON_NOTIFY(NM_RCLICK, IDC_GRID, OnGridRClick) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CTreeViewDlg message handlers BOOL CTreeViewDlg::OnInitDialog() { CDialog::OnInitDialog(); // Set the default font for all dialog controls. SendMessageToDescendants(WM_SETFONT, (WPARAM)(HFONT)XTPFontManager()->GetFont()); int nWidth = 0; CString type = _T("RT_SVG"); CXTPImageManager* imgMgr = m_wndGrid.GetImageManager(); nWidth = XTP_DPI_X(16); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_DOCUMENT, 0, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_EXCLAMATION_BLUE, 1, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_BOOKMARK, 2, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_MAIL, 3, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_MAIL_OPEN, 4, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_MAIL_ARROW_LEFT, 5, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_EXCLAMATION_RED, 6, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_PIN_BLUE, 7, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_PIN_RED, 8, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_SMALL_BUTTON_ARROW_DOWN, 9, nWidth); nWidth = XTP_DPI_X(32); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_DOCUMENT, 0, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_EXCLAMATION_BLUE, 1, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_BOOKMARK, 2, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_MAIL, 3, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_MAIL_OPEN, 4, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_MAIL_ARROW_LEFT, 5, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_EXCLAMATION_RED, 6, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_PIN_BLUE, 7, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_PIN_RED, 8, nWidth); imgMgr->SetVectorIcon(type, IDR_SVG_GRID_LARGE_BUTTON_ARROW_DOWN, 9, nWidth); m_wndGrid.ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP); m_wndGrid.GetGridHeader()->AllowColumnRemove(FALSE); m_wndGrid.GetPaintManager()->m_nTreeIndent = XTP_DPI_X(10); ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS); // // Add sample columns // CXTPGridColumn* pColumn = NULL; pColumn = m_wndGrid.AddColumn( new CXTPGridColumn(COLUMN_ICON, _T(""), 18, FALSE, COLUMN_MAIL_ICON)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn( new CXTPGridColumn(COLUMN_CHECK, _T(""), 18, FALSE, COLUMN_CHECK_ICON)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn(new CXTPGridColumn(COLUMN_SUBJECT, _T("Subject"), 280)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn(new CXTPGridColumn(COLUMN_FROM, _T("From"), 180)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn(new CXTPGridColumn(COLUMN_SENT, _T("Sent"), 150)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn(new CXTPGridColumn(COLUMN_SIZE, _T("Size"), 50)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn(new CXTPGridColumn(COLUMN_PRICE, _T("Price"), 80)); pColumn->SetEditable(FALSE); pColumn = m_wndGrid.AddColumn(new CXTPGridColumn(COLUMN_CONTACTS, _T("Contacts"), 280)); pColumn->SetMask(_T("Phone No: (000) 000-0000"), _T("Phone No: (___) ___-____")); // // Add sample records in tree // COleDateTime odtSent(COleDateTime::GetCurrentTime()); COleDateTime odtCreated(COleDateTime::GetCurrentTime()); COleDateTime odtReceived(COleDateTime::GetCurrentTime()); CString strMessage(" "); CString strEmpty(" "); m_wndGrid.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 5, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4761"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; m_wndGrid.AddRecord(new CMessageRecord(msgImportanceLow, FALSE, FALSE, _T("Clark Kent"), _T("RE: Hi Louis"), odtSent, 14, FALSE, 4.3, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4762"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; CMessageRecord* pParentRec1 = new CMessageRecord(msgImportanceNormal, TRUE, TRUE, _T("Bruce Wayne"), _T("RE:"), odtSent, 24, FALSE, 56, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4763"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; m_wndGrid.AddRecord(pParentRec1); pParentRec1->GetChilds()->Add(new CMessageRecord( msgImportanceHigh, TRUE, FALSE, _T("Peter Parker [pparker@codetoolbox.com]"), _T("Re: it's me again"), odtSent, 14, TRUE, 12.2, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec1->GetChilds()->Add( new CMessageRecord(msgImportanceLow, FALSE, TRUE, _T("QueryReply"), _T("Re: it's me again"), odtSent, 13, FALSE, 1.345, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; CMessageRecord* pParentRec2 = new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Bruce Wayne"), _T("I don't understand:"), odtSent, 24, FALSE, 5.4321, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; pParentRec1->GetChilds()->Add(pParentRec2); pParentRec2->GetChilds()->Add( new CMessageRecord(msgImportanceHigh, FALSE, FALSE, _T("Programmers - www.codetoolbox.com"), _T("Am I a programmer?"), odtSent, 14, TRUE, 45, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 8; pParentRec2->GetChilds()->Add( new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Oswald Cobblepot"), _T("Yeah I know"), odtSent, 13, TRUE, 0.5, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 8; m_wndGrid.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 10, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4761"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 80; // m_wndGrid.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 5, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4765"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; m_wndGrid.AddRecord(new CMessageRecord(msgImportanceLow, FALSE, FALSE, _T("Clark Kent"), _T("RE: Hi Louis"), odtSent, 14, FALSE, 4.3, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4769"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec1 = new CMessageRecord(msgImportanceNormal, TRUE, TRUE, _T("Bruce Wayne"), _T("RE:"), odtSent, 24, FALSE, 56, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4767"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; m_wndGrid.AddRecord(pParentRec1); pParentRec1->GetChilds()->Add(new CMessageRecord( msgImportanceHigh, TRUE, FALSE, _T("Peter Parker [pparker@codetoolbox.com]"), _T("Re: it's me again"), odtSent, 14, TRUE, 12.2, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec1->GetChilds()->Add( new CMessageRecord(msgImportanceLow, FALSE, TRUE, _T("QueryReply"), _T("Re: it's me again"), odtSent, 13, FALSE, 1.345, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec2 = new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Bruce Wayne"), _T("I don't understand:"), odtSent, 24, FALSE, 5.4321, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; pParentRec1->GetChilds()->Add(pParentRec2); pParentRec2->GetChilds()->Add( new CMessageRecord(msgImportanceHigh, FALSE, FALSE, _T("Programmers - www.codetoolbox.com"), _T("Am I a programmer?"), odtSent, 14, TRUE, 45, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 8; pParentRec2->GetChilds()->Add( new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Oswald Cobblepot"), _T("Yeah I know"), odtSent, 13, TRUE, 0.5, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 8; m_wndGrid.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 10, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4767"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 80; m_wndGrid.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 5, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4767"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; m_wndGrid.AddRecord(new CMessageRecord(msgImportanceLow, FALSE, FALSE, _T("Clark Kent"), _T("RE: Hi Louis"), odtSent, 14, FALSE, 4.3, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4768"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec1 = new CMessageRecord(msgImportanceNormal, TRUE, TRUE, _T("Bruce Wayne"), _T("RE:"), odtSent, 24, FALSE, 56, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4764"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; m_wndGrid.AddRecord(pParentRec1); pParentRec1->GetChilds()->Add(new CMessageRecord( msgImportanceHigh, TRUE, FALSE, _T("Peter Parker [pparker@codetoolbox.com]"), _T("Re: it's me again"), odtSent, 14, TRUE, 12.2, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec1->GetChilds()->Add( new CMessageRecord(msgImportanceLow, FALSE, TRUE, _T("QueryReply"), _T("Re: it's me again"), odtSent, 13, FALSE, 1.345, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; pParentRec2 = new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Bruce Wayne"), _T("I don't understand:"), odtSent, 24, FALSE, 5.4321, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4766"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; pParentRec1->GetChilds()->Add(pParentRec2); pParentRec2->GetChilds()->Add( new CMessageRecord(msgImportanceHigh, FALSE, FALSE, _T("Programmers - www.codetoolbox.com"), _T("Am I a programmer?"), odtSent, 14, TRUE, 45, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 8; pParentRec2->GetChilds()->Add( new CMessageRecord(msgImportanceNormal, TRUE, FALSE, _T("Oswald Cobblepot"), _T("Yeah I know"), odtSent, 13, TRUE, 0.5, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 8; m_wndGrid.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 10, odtCreated, odtReceived, strEmpty, _T("Phone No: (989) 472-4766"), strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 80; m_wndGrid.GetColumns()->Find(COLUMN_SUBJECT)->SetTreeColumn(TRUE); // Populate all data on control m_wndGrid.Populate(); m_wndGrid.AllowEdit(TRUE); m_bNotificationExpanded = m_wndGrid.GetBehavior()->Notifications->Row->bRowExpanded; UpdateData(FALSE); return FALSE; } void CTreeViewDlg::OnExpand() { m_wndGrid.ExpandAll(TRUE); } void CTreeViewDlg::OnCollapse() { m_wndGrid.CollapseAll(); } void CTreeViewDlg::OnOK() { CDialog::OnOK(); } void CTreeViewDlg::OnNotificationExpanded() { UpdateData(); m_wndGrid.GetBehavior()->Notifications->Row->bRowExpanded = m_bNotificationExpanded; } void CTreeViewDlg::OnGridRClick(NMHDR* pNotifyStruct, LRESULT* /*result*/) { XTP_NM_GRIDRECORDITEM* pItemNotify = (XTP_NM_GRIDRECORDITEM*)pNotifyStruct; if (pItemNotify->pRow) { TRACE(_T("Right click on row %d\n"), pItemNotify->pRow->GetIndex()); } }