// GridDialogDlg.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 "GridDialog.h" #include "GridDialogDlg.h" #include "MessageRecord.h" #ifdef _DEBUG # define new DEBUG_NEW # undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CGridDialogDlg dialog CGridDialogDlg::CGridDialogDlg(CWnd* pParent /*=NULL*/) : CXTPResizeDialog(CGridDialogDlg::IDD, pParent) { //{{AFX_DATA_INIT(CGridDialogDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } CGridDialogDlg::~CGridDialogDlg() { } void CGridDialogDlg::DoDataExchange(CDataExchange* pDX) { CXTPResizeDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CGridDialogDlg) DDX_Control(pDX, IDC_GRIDCTRL, m_wndGridCtrl); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CGridDialogDlg, CXTPResizeDialog) //{{AFX_MSG_MAP(CGridDialogDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_WM_DESTROY() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CGridDialogDlg message handlers enum { COLUMN_IMPORTANCE, COLUMN_ICON, COLUMN_ATTACHMENT, COLUMN_FROM, COLUMN_SUBJECT, COLUMN_SENT, COLUMN_SIZE, COLUMN_CHECK, COLUMN_PRICE, COLUMN_CREATED, COLUMN_RECEIVED, COLUMN_CONVERSATION, COLUMN_CONTACTS, COLUMN_MESSAGE, COLUMN_CC, COLUMN_CATEGORIES, COLUMN_AUTOFORWARD, COLUMN_DO_NOT_AUTOARCH, COLUMN_DUE_BY, }; const int COLUMN_MAIL_ICON = 0; const int COLUMN_CHECK_ICON = 2; BOOL CGridDialogDlg::OnInitDialog() { CXTPResizeDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. _ASSERTE((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); _ASSERTE(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the default font for all dialog controls. SendMessageToDescendants(WM_SETFONT, (WPARAM)(HFONT)XTPFontManager()->GetFont()); // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // // Add images // int nWidth = 0; CString type = _T("RT_SVG"); CXTPImageManager* imgMgr = m_wndGridCtrl.GetImageManager(); nWidth = XTP_DPI_X(16); BOOL res = 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); // // Add sample columns // m_wndGridCtrl.AddColumn( new CXTPGridColumn(COLUMN_ICON, _T(""), XTP_DPI_X(18), FALSE, COLUMN_MAIL_ICON)); m_wndGridCtrl.AddColumn( new CXTPGridColumn(COLUMN_CHECK, _T(""), XTP_DPI_X(18), FALSE, COLUMN_CHECK_ICON)); m_wndGridCtrl.AddColumn(new CXTPGridColumn(COLUMN_SUBJECT, _T("Subject"), 280)); m_wndGridCtrl.AddColumn(new CXTPGridColumn(COLUMN_FROM, _T("From"), 180)); m_wndGridCtrl.AddColumn(new CXTPGridColumn(COLUMN_SENT, _T("Sent"), 150)); m_wndGridCtrl.AddColumn(new CXTPGridColumn(COLUMN_SIZE, _T("Size"), 50)); m_wndGridCtrl.AddColumn(new CXTPGridColumn(COLUMN_PRICE, _T("Price"), 80)); // // Add sample records in tree // COleDateTime odtSent(COleDateTime::GetCurrentTime()); COleDateTime odtCreated(COleDateTime::GetCurrentTime()); COleDateTime odtReceived(COleDateTime::GetCurrentTime()); CString strMessage(" "); CString strEmpty(" "); m_wndGridCtrl.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 5, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; m_wndGridCtrl.AddRecord(new CMessageRecord(msgImportanceLow, FALSE, FALSE, _T("Clark Kent"), _T("RE: Hi Louis"), odtSent, 14, FALSE, 4.3, odtCreated, odtReceived, strEmpty, strEmpty, 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, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; m_wndGridCtrl.AddRecord(pParentRec1); m_wndGridCtrl.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 10, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 80; m_wndGridCtrl.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 5, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; m_wndGridCtrl.AddRecord(new CMessageRecord(msgImportanceLow, FALSE, FALSE, _T("Clark Kent"), _T("RE: Hi Louis"), odtSent, 14, FALSE, 4.3, odtCreated, odtReceived, strEmpty, strEmpty, 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, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; m_wndGridCtrl.AddRecord(pParentRec1); m_wndGridCtrl.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 10, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 80; m_wndGridCtrl.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, FALSE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 5, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 0.8; m_wndGridCtrl.AddRecord(new CMessageRecord(msgImportanceLow, FALSE, FALSE, _T("Clark Kent"), _T("RE: Hi Louis"), odtSent, 14, FALSE, 4.3, odtCreated, odtReceived, strEmpty, strEmpty, 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, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage); odtSent -= 0.8; m_wndGridCtrl.AddRecord(pParentRec1); m_wndGridCtrl.AddRecord( new CMessageRecord(msgImportanceNormal, FALSE, TRUE, _T("postmaster@mail.codejock.com"), _T("Undeliverable Mail"), odtSent, 7, TRUE, 10, odtCreated, odtReceived, strEmpty, strEmpty, strMessage, strEmpty, strEmpty, strEmpty, strEmpty, strEmpty, strMessage)); odtSent -= 80; // // define style attributes for the Grid control. // m_wndGridCtrl.GetColumns()->Find(COLUMN_SUBJECT)->SetTreeColumn(TRUE); // // after columns and data have been added call Populate to // populate all of the date for the control. // m_wndGridCtrl.Populate(); m_wndGridCtrl.EnableDragDrop(_T("GridDialog"), xtpGridAllowDrag | xtpGridAllowDrop); #ifdef _XTP_INCLUDE_CONTROLS // Set control resizing. SetResize(IDC_GRIDCTRL, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDCANCEL, XTP_ANCHOR_BOTTOMRIGHT, XTP_ANCHOR_BOTTOMRIGHT); SetResize(IDOK, XTP_ANCHOR_BOTTOMRIGHT, XTP_ANCHOR_BOTTOMRIGHT); // Load window placement LoadPlacement(_T("CGridDialogDlg")); #endif // Set the appearance for the Grid control. m_wndGridCtrl.SetTheme(xtpGridThemeOfficeXP); return TRUE; // return TRUE unless you set the focus to a control } void CGridDialogDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CXTPResizeDialog::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CGridDialogDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM)dc.GetSafeHdc(), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CXTPResizeDialog::OnPaint(); } } // The system calls this to obtain the cursor to display while the user drags // the minimized window. HCURSOR CGridDialogDlg::OnQueryDragIcon() { return (HCURSOR)m_hIcon; } void CGridDialogDlg::OnDestroy() { CXTPResizeDialog::OnDestroy(); #ifdef _XTP_INCLUDE_CONTROLS // Save window placement SavePlacement(_T("CGridDialogDlg")); #endif }