/***********************************************************************/ /* Copyright (C) 2002 Definitive Solutions, Inc. All Rights Reserved. */ /* THIS COMPUTER PROGRAM IS PROPRIETARY AND CONFIDENTIAL TO DEFINITIVE */ /* SOLUTIONS, INC. AND ITS LICENSORS AND CONTAINS TRADE SECRETS OF */ /* DEFINITIVE SOLUTIONS, INC. THAT ARE PROVIDED PURSUANT TO A WRITTEN */ /* AGREEMENT CONTAINING RESTRICTIONS ON USE AND DISCLOSURE. ANY USE, */ /* REPRODUCTION, OR TRANSFER EXCEPT AS PROVIDED IN SUCH AGREEMENT */ /* IS STRICTLY PROHIBITED. */ /***********************************************************************/ ///////////////////////////////////////////////////////////////////////////// // // How to add this class to your application. // // Add MyListCtrl.cpp, MyListCtrl.h, MyListCtrlResource.h, and // MyListCtrl.rc2 to your project in the usual folders. // // Add this line to the top of your RC2 file: // #include "MyListCtrlResource.h" // MyListCtrl resources. // // Add this line to the end of your RC2 file: // #include "MyListCtrl.rc2" // MyListCtrl resources. // // Since this class has a dependancy on MyRichEditCtrl, you'll also have to // add that to your project. See the header file for that class for more // instructions. // ///////////////////////////////////////////////////////////////////////////// #if !defined(AFX_MYLISTCTRL_H__631D63C3_CD61_11D5_8A6C_00B0D0529ED2__INCLUDED_) #define AFX_MYLISTCTRL_H__631D63C3_CD61_11D5_8A6C_00B0D0529ED2__INCLUDED_ #pragma once #include "MyToolTipCtrl.h" ///////////////////////////////////////////////////////////////////////////// // Defines #define MYLISTCTRL_FIRST_COLUMN_MENUID 41000 #define MYLISTCTRL_LAST_COLUMN_MENUID 41127 ///////////////////////////////////////////////////////////////////////////// // Forward declarations. class MyRichEditCtrl; ///////////////////////////////////////////////////////////////////////////// // MyHeaderCtrl window class MyHeaderCtrl : public CHeaderCtrl { // Construction. public: MyHeaderCtrl(); virtual ~MyHeaderCtrl(); // Operations. public: //{{AFX_VIRTUAL(MyHeaderCtrl) //}}AFX_VIRTUAL // Generated message map functions. protected: //{{AFX_MSG(MyHeaderCtrl) afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// // MyListCtrl // Declare the class depending on this file is in an EXE project or a DLL one. class #ifdef _WINDLL AFX_EXT_CLASS #endif MyListCtrl : public CListCtrl { // Construction. public: MyListCtrl(); virtual ~MyListCtrl(); DECLARE_DYNAMIC(MyListCtrl) // Declared but not defined. private: MyListCtrl(const MyListCtrl& rhs); MyListCtrl& operator=(const MyListCtrl& rhs); // Operations. public: bool IsItem(int nItem) const; bool IsColumn(int nCol) const; int GetSelectedItem(int nStartItem = -1) const; bool SelectItem(int nItem, bool bSelect = true); bool IsSelected(int nItem) const; bool SelectAll(bool bSelect = true); int GetSelItems(int nMaxItems, int* pnItemArray) const; bool FocusItem(int nItem) ; bool IsFocused(int nItem) const; int GetFocusedItem() const; bool IsItemVisible(int nItem) const; int GetColumnCount() const; int GetColumnAlignment(int nCol) const; int GetTotalColumnWidth() const; CString GetHeaderText(int nCol) const; void GetHeadersText(CString& sHeader); CString GetItemTextWorks(int nItem, int nSubItem) const; int GetCellRectFromPoint(const CPoint& point, CRect& rcCell, int& nCol) const; void SelectTheFont(const CString& sFace, int nPoints); bool CopySelectedToClipboard(CWnd* pwndCount = NULL); bool AppendSelectedToRichEdit(MyRichEditCtrl& richedit, bool& bCancel, CWnd* pwndCount, bool bIncludeZerothColumn, int nTwips); int FindExactMatch(const CStringList& slCells, int nItemStart = -1, int nColStart = -1) const; int FindInAnyColumn(const CString& sText, int nItemStart = -1, int nColStart = -1) const; void SortColumn(int nColumn, bool bToggle = true); static int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort); void SaveColumnWidthsToRegistry(const CString& sKey, const CString& sValue); void ReadColumnWidthsFromRegistry(const CString& sKey, const CString& sValue); void SaveColumnOrderToRegistry(const CString& sKey, const CString& sValue); void ReadColumnOrderFromRegistry(const CString& sKey, const CString& sValue); void SaveGridLinesToRegistry(const CString& sKey, const CString& sValue); void ReadGridLinesFromRegistry(const CString& sKey, const CString& sValue); void SaveSelItemsToRegistry(const CString& sKey, const CString& sValue); void ReadSelItemsFromRegistry(const CString& sKey, const CString& sValue); //{{AFX_VIRTUAL(MyListCtrl) public: virtual BOOL PreTranslateMessage(MSG* pMsg); protected: virtual void PreSubclassWindow(); //}}AFX_VIRTUAL // Generated message map functions. protected: //{{AFX_MSG(MyListCtrl) afx_msg void OnRclick(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnMylistctrlCopy(); afx_msg void OnMylistctrlSelectAll(); afx_msg void OnMylistctrlFontUp(); afx_msg void OnMylistctrlFontDown(); afx_msg void OnMylistctrlGridlines(); afx_msg void OnMylistctrlColumns(); afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); afx_msg void OnColumnclick(NMHDR* pNMHDR, LRESULT* pResult); //}}AFX_MSG void OnColumnMenuSelect(UINT uiID); DECLARE_MESSAGE_MAP() // Implementation. protected: void CreateTheFont(); // Data. protected: MyHeaderCtrl m_Header; // Header control for the CListCtrl. MyToolTipCtrl m_ToolTip; // Tooltip for the list control. CString m_sFaceName; // Name of the font: i.e., "Courier New". int m_nPoints; // Point size of the font; i.e., 10. CFont* m_pFont; // Font for this control. Fixed pitch is a good choice. int m_nColumnSort; // The last column sorted on. bool m_bSortAscending; // Are we sorting that way? bool m_bNumericSort; // Are we sorting that way? }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MYLISTCTRL_H__631D63C3_CD61_11D5_8A6C_00B0D0529ED2__INCLUDED_)