CGridListCtrlEx
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CGridListCtrlEx Class Reference

CGridListCtrlEx extends the CListCtrl with several features. More...

Inheritance diagram for CGridListCtrlEx:
CGridListCtrlGroups

Public Member Functions

virtual ~CGridListCtrlEx ()
 Destructor.
 
LRESULT EnableVisualStyles (bool bValue)
 Activate visual style for the list control (Vista Theme) More...
 
bool UsingVisualStyle () const
 
virtual CFont * GetCellFont ()
 Retrieves the font used to draw cells in the list control. More...
 
virtual void SetCellMargin (double margin)
 Takes the current font and increases the font with the given margin multiplier. More...
 
void SetEmptyMarkupText (const CString &strText)
 Update the markup text displayed when the list control is empty. More...
 
void SetTooltipMaxWidth (int width)
 
int GetTooltipMaxWidth () const
 
int GetFocusRow () const
 Retrieve row with the LVIS_FOCUSED state flag set. More...
 
void SetFocusRow (int nRow)
 Sets LVIS_FOCUSED state flag for the specified row. More...
 
bool IsRowSelected (int nRow) const
 Checks if the LVIS_SELECTED state flag set for the specified row. More...
 
BOOL SelectRow (int nRow, bool bSelect)
 Sets the LVIS_SELECTED state flag for the specified row. More...
 
virtual CGridRowTraitGetRowTrait (int nRow)
 Retrieves the row trait for the specified row. More...
 
virtual void SetDefaultRowTrait (CGridRowTrait *pRowTrait)
 Sets the default row trait used by default for drawing rows. More...
 
const CHeaderCtrl * GetHeaderCtrl () const
 Retrieves the header control of a list control. More...
 
CHeaderCtrl * GetHeaderCtrl ()
 
int GetColumnCount () const
 Retrieves the number of columns from the header control. More...
 
int GetColumnData (int nCol) const
 The column version of GetItemData(), one can specify an unique identifier when using InsertColumn() More...
 
int GetColumnOrder (int nCol) const
 Get column position in the CHeaderCtrl's display order array. More...
 
CString GetColumnHeading (int nCol) const
 Retrieve column title of a column in the list control NOTE! It will only return the first 255 characters of the header. More...
 
virtual BOOL EnsureColumnVisible (int nCol, bool bPartialOK)
 Scrolls the view, so the column becomes visible. More...
 
virtual BOOL SetColumnWidthAuto (int nCol=-1, bool bIncludeHeader=false)
 Resizes the width of a column according the contents of the cells below. More...
 
virtual void SetSortArrow (int nCol, bool bAscending)
 Puts a sort-icon in the column header of the specified column. More...
 
virtual BOOL ShowColumn (int nCol, bool bShow)
 Changes the visible state of column. More...
 
virtual bool IsColumnVisible (int nCol)
 Retrieves the column visible state from the column trait. More...
 
virtual bool IsColumnResizable (int nCol)
 Checks if a column is allowed to be resized. More...
 
virtual bool IsColumnAlwaysVisible (int nCol)
 Checks if a column is fixed to be always visible. More...
 
virtual bool IsColumnAlwaysHidden (int nCol)
 Checks if a column is fixed to be always hidden. More...
 
virtual int GetFirstVisibleColumn ()
 Retrieves the column index of the first visible column. More...
 
virtual int InsertHiddenLabelColumn ()
 Inserts the label column (first column) with invisible state The label column behaves differently from the rest of the columns, and to get the uniform look, then it should be hidden away. More...
 
virtual int InsertColumnTrait (int nCol, const CString &strColumnHeading, int nFormat=LVCFMT_LEFT, int nWidth=-1, int nSubItem=-1, CGridColumnTrait *pTrait=NULL)
 Inserts a new column in the list control, and gives the option to customize the column using a trait. More...
 
virtual CGridColumnTraitGetColumnTrait (int nCol)
 Retrieves the column trait for the entire column. More...
 
virtual int GetColumnTraitSize () const
 Retrieves the number of column traits registered. More...
 
UINT CellHitTest (const CPoint &pt, int &nRow, int &nCol) const
 Replicates the SubItemHitTest() but in a const version. More...
 
BOOL GetCellRect (int nRow, int nCol, int nCode, CRect &rect)
 Improved version of GetSubItemRect(). More...
 
int GetFocusCell () const
 
virtual void SetFocusCell (int nCol, bool bRedraw=false)
 Changes the focus cell. More...
 
virtual CWnd * EditCell (int nRow, int nCol)
 Starts the edit of a cell and sends a message to the parent window. More...
 
virtual CWnd * EditCell (int nRow, int nCol, CPoint pt)
 Starts the edit of a cell and sends a message to the parent window. More...
 
bool IsCellEditorOpen () const
 Checks if the cell value editor is open for a cell. More...
 
bool IsCellCallback (int nRow, int nCol) const
 Checks if the current cell is using callback to retrieve its text value. More...
 
int GetCellImage (int nRow, int nCol) const
 Retrieves the icon index of the specified cell. More...
 
BOOL SetCellImage (int nRow, int nCol, int nImageId)
 Sets the icon of the specified cell. More...
 
virtual CGridColumnTraitGetCellColumnTrait (int nRow, int nCol)
 Retrieves the column trait of a specified cell. More...
 
virtual void SetupColumnConfig (CViewConfigSectionProfiles *pColumnConfig, bool bConfigOwner=true)
 Sets the interface for handling state persistence for the list control. More...
 
virtual void LoadState (CViewConfigSection &config)
 Loads and applies the column configuration for the list control. More...
 
virtual void SaveState (CViewConfigSection &config)
 Saves the column configuration of the list control. More...
 
virtual void LoadColumnState (int nConfigCol, int nOwnerCol, CViewConfigSection &config)
 Loads the column state of a single column. More...
 
virtual void SaveColumnState (int nConfigCol, int nOwnerCol, CViewConfigSection &config)
 Saves the column state of a single column. More...
 
virtual bool HasColumnEditor (int nCol, CString &strTitle)
 Is there a column configuration editor available for this column ? More...
 
virtual void OpenColumnEditor (int nCol)
 Open the column configuration editor for the column (If one available) More...
 
virtual bool HasColumnPicker (CString &strTitle)
 Is there a column picker available that can add / remove columns. More...
 
virtual void OpenColumnPicker ()
 Open the column picker for the list control.
 
virtual bool HasColumnDefaultState (CString &strTitle)
 Has the ability to reset the column configuration to its default configuration. More...
 
virtual void ResetColumnDefaultState ()
 Reset the column configuration to its default configuration.
 
virtual CString HasColumnProfiles (CSimpleArray< CString > &profiles, CString &strTitle)
 Can switch between multiple column configurations. More...
 
virtual void SwichColumnProfile (const CString &strProfile)
 Switch to different column configurations profile. More...
 
virtual void OnSaveStateColumnPick ()
 Called after a column has been added / removed.
 
virtual void OnSaveStateColumnResize ()
 Called after a column has been resized.
 
virtual void OnSaveStateKillFocus ()
 Called when the list control looses focus to another control.
 
virtual void OnDisplayCellItem (LVITEM &lvi)
 Override this method to provide text string and image index when drawing cells. More...
 
virtual bool OnDisplayCellText (int nRow, int nCol, CString &strResult)
 Override this method to provide text string when drawing cells Only called when using LPSTR_TEXTCALLBACK with CListCtrl::SetItemText() More...
 
virtual bool OnDisplayCellImage (int nRow, int nCol, int &nImageId)
 Override this method to provide icon index when drawing cells Only called when using I_IMAGECALLBACK with SetCellImage() More...
 
virtual bool OnDisplayCellTooltip (const CPoint &point) const
 Override this method if wanting to specify whether a tooltip is available. More...
 
virtual bool OnDisplayColumnTooltip (int nCol, CString &strResult) const
 Override this method to display a custom tooltip text when holding the mouse over a column header. More...
 
virtual bool OnDisplayCellTooltip (int nRow, int nCol, CString &strResult)
 Override this method to display a custom tooltip text when holding the mouse over a cell. More...
 
virtual bool OnDisplayCellColor (NMLVCUSTOMDRAW *pLVCD)
 Override this method to change the colors used for drawing a cell. More...
 
virtual bool OnDisplayCellColor (int nRow, int nCol, COLORREF &textColor, COLORREF &backColor)
 Override this method to change the colors used for drawing a cell. More...
 
virtual bool OnDisplayCellFont (NMLVCUSTOMDRAW *pLVCD, LOGFONT &font)
 Override this method to change the font used for drawing a cell. More...
 
virtual bool OnDisplayCellFont (int nRow, int nCol, LOGFONT &font)
 Override this method to change the font used for drawing a cell. More...
 
virtual bool OnDisplayRowColor (int nRow, COLORREF &textColor, COLORREF &backColor)
 Override this method to change the color used for drawing a row. More...
 
virtual bool OnDisplayRowFont (int nRow, LOGFONT &font)
 Override this method to change the font used for drawing a row. More...
 
virtual void OnDisplayDragOverRow (int nRow)
 Override this method to react to mouse over event during drag drop. More...
 
virtual bool OnDisplayToClipboard (CString &strResult, bool includeHeader=true)
 Override this method to control what is placed in the global clipboard. More...
 
virtual bool OnDisplayToClipboard (int nRow, CString &strResult)
 Override this method to control what to place in the clipboard for a single row. More...
 
virtual bool OnDisplayToClipboard (int nRow, int nCol, CString &strResult)
 Override this method to control what to place in the clipboard for a single cell. More...
 
virtual bool OnDisplayToDragDrop (CString &strResult)
 Override this method to control what data is selected for drag drop operation. More...
 
virtual bool OnOwnerDataDisplayCheckbox (int nRow)
 Override this method to display checkbox state for LVS_OWNERDATA (virtual list). More...
 
virtual void OnOwnerDataToggleCheckBox (int nRow, bool bChecked)
 Override this method to react to check box being toggled for LVS_OWNERDATA (virtual list). More...
 
virtual int OnKeyboardSearch (int nCol, int nStartRow, const CString &strSearch)
 Override this method to optimize the keyboard search for LVS_OWNERDATA (virtual list) More...
 

Static Public Member Functions

static bool CheckOSVersion (WORD requestOS)
 Checks if the current OS version against the requested OS version. More...
 

Protected Member Functions

virtual void InsertColumnTrait (int nCol, CGridColumnTrait *pTrait)
 Internal maintenance function for the column trait container. More...
 
virtual void DeleteColumnTrait (int nCol)
 Internal maintenance function for the column trait container. More...
 
int InternalColumnPicker (CMenu &menu, UINT offset)
 Internal method to add all available columns to the context menu. More...
 
int InternalColumnProfileSwitcher (CMenu &menu, UINT offset, CSimpleArray< CString > &profiles)
 Internal method to add all available column profiles to the context menu. More...
 
virtual void MoveFocusCell (bool bMoveRight)
 Shifts the cell focus left or right in the same row. More...
 
virtual bool SortColumn (int nCol, bool bAscending)
 Changes the row sorting in regard to the specified column. More...
 
virtual BOOL RegisterDropTarget ()
 Registers the CListCtrl as a valid OLE drag drop target. More...
 
virtual DROPEFFECT DoDragDrop (COleDataSource &oleDataSource, COleDropSource *pDropSource=NULL, DWORD dropEffects=DROPEFFECT_COPY|DROPEFFECT_MOVE|DROPEFFECT_LINK, LPCRECT lpRectStartDrag=NULL)
 Takes the contents of the selected rows, and starts a drag-drop operation. More...
 
virtual DROPEFFECT OnDragEnter (COleDataObject *pDataObject, DWORD dwKeyState, CPoint point)
 Called by the framework when the cursor is first dragged into the window. More...
 
virtual DROPEFFECT OnDragOver (COleDataObject *pDataObject, DWORD dwKeyState, CPoint point)
 Called by the framework when the cursor is dragged over the window. More...
 
virtual SCODE OnDragGiveFeedback (DROPEFFECT dropEffect)
 Called by the framework during drag-drop operation, and allows one to give visual feedback to the end user during a drag-and-drop operation. More...
 
virtual void OnDragLeave ()
 Called by the framework when the cursor leaves the window while a dragging operation is in effect.
 
virtual BOOL OnDrop (COleDataObject *pDataObject, DROPEFFECT dropEffect, CPoint point)
 Called by the framework when a drop operation is to occur. More...
 
virtual BOOL OnDropSelf (COleDataObject *pDataObject, DROPEFFECT dropEffect, CPoint point)
 Called by the framework when a drop operation is to occur, where the origin is the CGridListCtrlEx itself. More...
 
virtual BOOL OnDropExternal (COleDataObject *pDataObject, DROPEFFECT dropEffect, CPoint point)
 Called by the framework when a drop operation is to occur, where the origin is an external source. More...
 
virtual bool MoveSelectedRows (int nDropRow)
 Inserts the selected rows before the specified row. More...
 
virtual void OnCustomDrawRow (int nRow, NMLVCUSTOMDRAW *pLVCD, LRESULT *pResult)
 Performs custom drawing of the CListCtrl using CGridRowTrait. More...
 
virtual void OnCustomDrawCell (int nRow, int nCol, NMLVCUSTOMDRAW *pLVCD, LRESULT *pResult)
 Performs custom drawing of the CListCtrl using CGridColumnTrait. More...
 
virtual int OnClickEditStart (int nRow, int nCol, CPoint pt, bool bDblClick)
 Override this method to control whether cell edit should be started when clicked with the mouse. More...
 
virtual CWnd * OnEditBegin (int nRow, int nCol)
 Override this method to control whether cell editing is allowed for a cell. More...
 
virtual CWnd * OnEditBegin (int nRow, int nCol, CPoint pt)
 Override this method to control whether cell editing is allowed for a cell. More...
 
virtual bool OnEditComplete (int nRow, int nCol, CWnd *pEditor, LV_DISPINFO *pLVDI)
 Override this method to validate the new value after a cell edit. More...
 
virtual void OnContextMenuGrid (CWnd *pWnd, CPoint point)
 Override this method to change the context menu when activating context menu in client area with no rows. More...
 
virtual void OnContextMenuHeader (CWnd *pWnd, CPoint point, int nCol)
 Override this method to change the context menu when activating context menu for the column headers. More...
 
virtual void OnContextMenuKeyboard (CWnd *pWnd, CPoint point)
 Override this method to change the context menu when using the keyboard shortcut SHIFT+F10. More...
 
virtual void OnContextMenuCell (CWnd *pWnd, CPoint point, int nRow, int nCol)
 Override this method to change the context menu when activating context menu for a single cell. More...
 
virtual void OnCreateStyle ()
 Configures the initial style of the list control when the it is created.
 
virtual void OnCopyToClipboard ()
 Copies the contents of the selected rows into the global clipboard.
 
virtual void PreSubclassWindow ()
 Normally used for subclassing controls, but here used to configure initial style when list control is created. More...
 
virtual int OnToolHitTest (CPoint point, TOOLINFO *pTI) const
 Called by the MFC framework during mouse over to detemine whether a point is in the bounding rectangle of the specified tool. More...
 
virtual afx_msg int OnCreate (LPCREATESTRUCT lpCreateStruct)
 WM_CREATE message handler. More...
 
virtual afx_msg LRESULT OnDeleteColumn (WPARAM wParam, LPARAM lParam)
 LVM_DELETECOLUMN message handler to ensure the column trait container is updated when columns are removed. More...
 
virtual afx_msg LRESULT OnInsertColumn (WPARAM wParam, LPARAM lParam)
 LVM_INSERTCOLUMN message handler to ensure the column trait container is updated when columns are inserted. More...
 
virtual afx_msg BOOL OnItemClick (NMHDR *pNMHDR, LRESULT *pResult)
 NM_CLICK message handler called when left-clicking in a cell. More...
 
virtual afx_msg BOOL OnItemDblClick (NMHDR *pNMHDR, LRESULT *pResult)
 NM_DBLCLK message handler called when double-clicking in a cell. More...
 
virtual afx_msg BOOL OnGetDispInfo (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_GETDISPINFO message handler, which is called when details are needed for an item that specifies callback. More...
 
virtual afx_msg void OnChar (UINT nChar, UINT nRepCnt, UINT nFlags)
 WM_CHAR message handler for performing keyboard search with subitems. More...
 
virtual afx_msg void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
 WM_KEYDOWN message handler for performing keyboard navigation. More...
 
virtual afx_msg void OnLButtonDown (UINT nFlags, CPoint point)
 WM_LBUTTONDOWN message handler called when the user presses the left mouse button while the cursor is in the client area of a window. More...
 
virtual afx_msg void OnRButtonDown (UINT nFlags, CPoint point)
 WM_RBUTTONDOWN message handler called when the user presses the right mouse button while the cursor is in the client area of a window. More...
 
virtual afx_msg void OnLButtonDblClk (UINT nFlags, CPoint point)
 The WM_LBUTTONDBLCLK message is posted when the user double-clicks the left mouse button while the cursor is in the client area of a window Used to flip the checkbox image even when double-clicking. More...
 
virtual afx_msg void OnCustomDraw (NMHDR *pNMHDR, LRESULT *pResult)
 Performs custom drawing of the CListCtrl. More...
 
virtual afx_msg LRESULT OnSetColumnWidth (WPARAM wParam, LPARAM lParam)
 LVM_SETCOLUMNWIDTH message handler called when wanting to resize a column. More...
 
virtual afx_msg BOOL OnHeaderDividerDblClick (UINT, NMHDR *pNMHDR, LRESULT *pResult)
 HDN_DIVIDERDBLCLICK message handler called when double clicking the divider in the columns of the CHeaderCtrl. More...
 
virtual afx_msg BOOL OnHeaderBeginResize (UINT, NMHDR *pNmhdr, LRESULT *pResult)
 HDN_BEGINTRACK message handler called when resizing columns. More...
 
virtual afx_msg BOOL OnHeaderBeginDrag (UINT, NMHDR *pNMHDR, LRESULT *pResult)
 HDN_BEGINDRAG message handler called when about to move a column to a new position. More...
 
virtual afx_msg BOOL OnHeaderEndResize (UINT, NMHDR *pNMHDR, LRESULT *pResult)
 HDN_ENDTRACK message handler called after column resize. More...
 
virtual afx_msg BOOL OnHeaderItemChanging (UINT, NMHDR *pNMHDR, LRESULT *pResult)
 HDN_ITEMCHANGING message handler called during column resize. More...
 
virtual afx_msg BOOL OnHeaderEndDrag (UINT, NMHDR *pNmhdr, LRESULT *pResult)
 HDN_ENDDRAG message handler called after a column have been dragged, but before the column order has been updated. More...
 
virtual afx_msg BOOL OnHeaderClick (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_COLUMNCLICK message handler called when clicking a column header. More...
 
virtual afx_msg BOOL OnToolNeedText (UINT, NMHDR *pNMHDR, LRESULT *pResult)
 TTN_NEEDTEXT message handler called when the tooltip timer fires. More...
 
virtual afx_msg BOOL OnBeginLabelEdit (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_BEGINLABELEDIT message handler called when start editing a cell. More...
 
virtual afx_msg BOOL OnEndLabelEdit (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_ENDLABELEDIT message handler called when completed a cell edit. More...
 
virtual afx_msg BOOL OnOwnerDataFindItem (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_ODFINDITEM message handler for performing keyboard search when LVS_OWNERDATA (virtual list) More...
 
virtual afx_msg void OnHScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
 WM_HSCROLL message handler called when scrolling in the list control. More...
 
virtual afx_msg void OnVScroll (UINT nSBCode, UINT nPos, CScrollBar *pScrollBar)
 WM_VSCROLL message handler called when scrolling in the list control. More...
 
virtual afx_msg void OnContextMenu (CWnd *, CPoint point)
 WM_CONTEXTMENU message handler to show popup menu when mouse right click is used (or SHIFT+F10 on the keyboard) More...
 
virtual afx_msg void OnDestroy ()
 Notify that the window has been destroyed.
 
virtual afx_msg void OnPaint ()
 WM_PAINT message handler called when needing to redraw list control. More...
 
virtual afx_msg void OnSetFocus (CWnd *pOldWnd)
 WM_SETFOCUS message handler called when list control is receiving focus from other control. More...
 
virtual afx_msg void OnKillFocus (CWnd *pNewWnd)
 WM_KILLFOCUS message handler called when list control is loosing focus to other control. More...
 
virtual afx_msg LRESULT OnCopy (WPARAM wParam, LPARAM lParam)
 WM_COPY message handler. More...
 
virtual afx_msg LRESULT OnSetFont (WPARAM wParam, LPARAM lParam)
 WM_SETFONT message handler. More...
 
virtual afx_msg BOOL OnBeginDrag (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_BEGINDRAG message handler called when performing left-click drag. More...
 
virtual afx_msg BOOL OnItemChanged (NMHDR *pNMHDR, LRESULT *pResult)
 LVN_ITEMCHANGED message handler called when a row changes state When using LVS_OWNERDATA style, this only gets called for single item state change. More...
 
 DECLARE_MESSAGE_MAP ()
 

Protected Attributes

CSimpleArray< CGridColumnTrait * > m_ColumnTraits
 Column traits registered (One for each column)
 
CViewConfigSectionProfilesm_pColumnConfig
 Column state persistence.
 
bool m_bConfigOwner
 Column state persistence object is freed by destructor.
 
CGridRowTraitm_pDefaultRowTrait
 Default row trait used for special row drawing.
 
int m_FocusCell
 Column currently having focus (-1 means entire row)
 
CString m_LastSearchString
 Last search criteria for keyboard search.
 
CTime m_LastSearchTime
 Time of last search attempt for keyboard search.
 
int m_LastSearchCell
 Last column used in keyboard search.
 
int m_LastSearchRow
 Last row matched in keyboard search.
 
int m_RepeatSearchCount
 How many times the same search have been repeated (same key pressed)
 
int m_SortCol
 Rows are sorted according to this column.
 
bool m_Ascending
 Rows are sorted ascending / descending.
 
CWnd * m_pEditor
 Cell value editor currently in use.
 
bool m_UsingVisualStyle
 Vista Style has been enabled (alpha blend)
 
int m_TooltipMaxWidth
 Whether tooltips should be split in multiple lines.
 
CFont m_GridFont
 Original font of the the list control.
 
CFont m_CellFont
 Current font to draw rows.
 
double m_Margin
 Current margin between original font and cell font.
 
CString m_EmptyMarkupText
 Text to display when list control is empty.
 
bool m_InvalidateMarkupText
 Ensure that the empty markup text is cleared properly.
 
COleDropTargetWnd< CGridListCtrlEx > * m_pOleDropTarget
 Maintains OLE drag drop target.
 

Friends

class COleDropTargetWnd< CGridListCtrlEx >
 
class COleDropSourceWnd< CGridListCtrlEx >
 

Detailed Description

CGridListCtrlEx extends the CListCtrl with several features.

Member Function Documentation

UINT CGridListCtrlEx::CellHitTest ( const CPoint &  pt,
int &  nRow,
int &  nCol 
) const

Replicates the SubItemHitTest() but in a const version.

Finds the cell below the given mouse cursor position.

Parameters
ptThe position to hit test, in client coordinates.
nRowThe index of the row (Returns -1 if no row)
nColThe index of the column (Returns -1 if no column)
Returns
Returns the location of the cell hit (LVHT_NOWHERE, LVHT_ONITEMICON, LVHT_ONITEMLABEL, LVHT_ONITEMSTATEICON, LVHT_ONITEM)
bool CGridListCtrlEx::CheckOSVersion ( WORD  requestOS)
static

Checks if the current OS version against the requested OS version.

Parameters
requestOSThe full version number of the OS required (Ex 0x0600)
void CGridListCtrlEx::DeleteColumnTrait ( int  nCol)
protectedvirtual

Internal maintenance function for the column trait container.

Parameters
nColThe index of the column just deleted
DROPEFFECT CGridListCtrlEx::DoDragDrop ( COleDataSource &  oleDataSource,
COleDropSource *  pDropSource = NULL,
DWORD  dropEffects = DROPEFFECT_COPY | DROPEFFECT_MOVE | DROPEFFECT_LINK,
LPCRECT  lpRectStartDrag = NULL 
)
protectedvirtual

Takes the contents of the selected rows, and starts a drag-drop operation.

Parameters
oleDataSourceCache for placing the data selected for drag-drop operation
dropEffectsDrag-and-drop operations that are allowed on this data source
lpRectStartDragPointer to the rectangle that defines where the drag actually starts
pDropSourcePoints to a drop source.
Returns
Drop effect generated by the drag-and-drop operation; otherwise DROPEFFECT_NONE
CWnd * CGridListCtrlEx::EditCell ( int  nRow,
int  nCol 
)
virtual

Starts the edit of a cell and sends a message to the parent window.

Parameters
nRowThe index of the row
nColThe index of the column
Returns
Pointer to the cell editor (If NULL then block cell editing)
CWnd * CGridListCtrlEx::EditCell ( int  nRow,
int  nCol,
CPoint  pt 
)
virtual

Starts the edit of a cell and sends a message to the parent window.

Parameters
nRowThe index of the row
nColThe index of the column
ptThe position clicked, in client coordinates.
Returns
Pointer to the cell editor (If NULL then block cell editing)
LRESULT CGridListCtrlEx::EnableVisualStyles ( bool  bValue)

Activate visual style for the list control (Vista Theme)

Parameters
bValueSpecifies whether the visual styles should be enabled or not
Returns
S_FALSE if visual styles could not be enabled
BOOL CGridListCtrlEx::EnsureColumnVisible ( int  nCol,
bool  bPartialOK 
)
virtual

Scrolls the view, so the column becomes visible.

http://www.codeguru.com/cpp/controls/listview/columns/article.php/c931/

Parameters
nColThe index of the column
bPartialOKIs partially visible good enough ?
Returns
Nonzero if successful; otherwise zero.
CGridColumnTrait * CGridListCtrlEx::GetCellColumnTrait ( int  nRow,
int  nCol 
)
virtual

Retrieves the column trait of a specified cell.

Makes it possible to override the column trait of a single cell

Parameters
nRowThe index of the row
nColThe index of the column
Returns
The column trait pointer of the cell
CFont * CGridListCtrlEx::GetCellFont ( )
virtual

Retrieves the font used to draw cells in the list control.

Returns
A pointer to the current font used by the list control.
int CGridListCtrlEx::GetCellImage ( int  nRow,
int  nCol 
) const

Retrieves the icon index of the specified cell.

Parameters
nRowThe index of the row
nColThe index of the column
Returns
Index of the cell's icon in the control's image list (I_IMAGECALLBACK means no image)
BOOL CGridListCtrlEx::GetCellRect ( int  nRow,
int  nCol,
int  nCode,
CRect &  rect 
)

Improved version of GetSubItemRect().

  • It doesn't return entire row-rect when using LVIR_BOUNDS for label-column (nCol==0)
  • It supports LVIR_LABEL for sub-items (nCol>0)
  • It supports LVIR_BOUNDS when column width is less than subitem image width
Parameters
nRowThe index of the row
nColThe index of the column
nCodeDetermines the portion of the bounding rectangle (of the list view subitem) to be retrieved.
rectReference to a CRect object that contains the coordinates of the cell's bounding rectangle.
Returns
Nonzero if successful; otherwise zero.
int CGridListCtrlEx::GetColumnCount ( ) const

Retrieves the number of columns from the header control.

Returns
Number of header control items if successful; otherwise – 1.
int CGridListCtrlEx::GetColumnData ( int  nCol) const

The column version of GetItemData(), one can specify an unique identifier when using InsertColumn()

Parameters
nColIndex of the column
Returns
Unique identifier of the column specified
CString CGridListCtrlEx::GetColumnHeading ( int  nCol) const

Retrieve column title of a column in the list control NOTE! It will only return the first 255 characters of the header.

Parameters
nColIndex of the column
Returns
Column header text of the specified column
int CGridListCtrlEx::GetColumnOrder ( int  nCol) const

Get column position in the CHeaderCtrl's display order array.

Parameters
nColIndex of the column
Returns
Column offset is in left-to-right order. For example, zero indicates the leftmost column.
CGridColumnTrait * CGridListCtrlEx::GetColumnTrait ( int  nCol)
virtual

Retrieves the column trait for the entire column.

Parameters
nColThe index of the column
Returns
The column trait pointer for the entire column
int CGridListCtrlEx::GetColumnTraitSize ( ) const
virtual

Retrieves the number of column traits registered.

Returns
The number or column traits
int CGridListCtrlEx::GetFirstVisibleColumn ( )
virtual

Retrieves the column index of the first visible column.

Returns
Column index of the first visible column (-1 if no visible columns)
int CGridListCtrlEx::GetFocusRow ( ) const

Retrieve row with the LVIS_FOCUSED state flag set.

Returns
The index of the row if successful, or -1 otherwise.
const CHeaderCtrl * CGridListCtrlEx::GetHeaderCtrl ( ) const

Retrieves the header control of a list control.

Returns
A pointer to the header control, used by the list control.
CGridRowTrait * CGridListCtrlEx::GetRowTrait ( int  nRow)
virtual

Retrieves the row trait for the specified row.

Override this to provide a custom row trait for a certain row

Parameters
nRowThe index of the row
Returns
Pointer to row trait
bool CGridListCtrlEx::HasColumnDefaultState ( CString &  strTitle)
virtual

Has the ability to reset the column configuration to its default configuration.

Parameters
strTitleTitle to show in the context menu when right-clicking the column
Returns
Default column configuration is available (true / false)
bool CGridListCtrlEx::HasColumnEditor ( int  nCol,
CString &  strTitle 
)
virtual

Is there a column configuration editor available for this column ?

Parameters
nColThe index of the column
strTitleTitle to show in the context menu when right-clicking the column
Returns
Column editor available (true / false)
bool CGridListCtrlEx::HasColumnPicker ( CString &  strTitle)
virtual

Is there a column picker available that can add / remove columns.

Parameters
strTitleTitle to show in the context menu when right-clicking the column
Returns
Column picker available (true / false)
CString CGridListCtrlEx::HasColumnProfiles ( CSimpleArray< CString > &  profiles,
CString &  strTitle 
)
virtual

Can switch between multiple column configurations.

Parameters
profilesList of available column profiles
strTitleTitle to show in the context menu when right-clicking the column
Returns
Name of the current column profile
int CGridListCtrlEx::InsertColumnTrait ( int  nCol,
const CString &  strColumnHeading,
int  nFormat = LVCFMT_LEFT,
int  nWidth = -1,
int  nSubItem = -1,
CGridColumnTrait pTrait = NULL 
)
virtual

Inserts a new column in the list control, and gives the option to customize the column using a trait.

Parameters
nColIndex of the new column
strColumnHeadingTitle of the new column
nFormatText alignment of the new column
nWidthWidth of the new column
nSubItemUnique identifier used to recognize the column independent of index
pTraitColumn trait interface for the new column
Returns
The index of the new column if successful or -1 otherwise.
void CGridListCtrlEx::InsertColumnTrait ( int  nCol,
CGridColumnTrait pTrait 
)
protectedvirtual

Internal maintenance function for the column trait container.

Parameters
nColThe index of the new column to get a column trait
pTraitThe column trait of the new column
int CGridListCtrlEx::InsertHiddenLabelColumn ( )
virtual

Inserts the label column (first column) with invisible state The label column behaves differently from the rest of the columns, and to get the uniform look, then it should be hidden away.

  • It has a special margin, which no other column has
  • When dragged to another position than the first, then it looses it special margin
Returns
The index of the new column if successful or -1 otherwise.
int CGridListCtrlEx::InternalColumnPicker ( CMenu &  menu,
UINT  offset 
)
protected

Internal method to add all available columns to the context menu.

Parameters
menuThe popup context menu
offsetStart offset to use when adding new menu items to the context menu
Returns
Number of menu items added to the context menu
int CGridListCtrlEx::InternalColumnProfileSwitcher ( CMenu &  menu,
UINT  offset,
CSimpleArray< CString > &  profiles 
)
protected

Internal method to add all available column profiles to the context menu.

Parameters
menuThe popup context menu
offsetStart offset to use when adding new menu items to the context menu
profilesList of column profiles that one can change between
Returns
Number of menu items added to the context menu
bool CGridListCtrlEx::IsCellCallback ( int  nRow,
int  nCol 
) const

Checks if the current cell is using callback to retrieve its text value.

Parameters
nRowThe index of the row
nColThe index of the column
Returns
Returns true if the cell is using call back to retrieve its text value
bool CGridListCtrlEx::IsCellEditorOpen ( ) const

Checks if the cell value editor is open for a cell.

Returns
Is currently editing a cell value (true / false)
bool CGridListCtrlEx::IsColumnAlwaysHidden ( int  nCol)
virtual

Checks if a column is fixed to be always hidden.

Parameters
nColThe index of the column
Returns
Is the column always visible (true / false)
bool CGridListCtrlEx::IsColumnAlwaysVisible ( int  nCol)
virtual

Checks if a column is fixed to be always visible.

Parameters
nColThe index of the column
Returns
Is the column always visible (true / false)
bool CGridListCtrlEx::IsColumnResizable ( int  nCol)
virtual

Checks if a column is allowed to be resized.

Parameters
nColThe index of the column
Returns
Can the column be resized or not (true / false)
bool CGridListCtrlEx::IsColumnVisible ( int  nCol)
virtual

Retrieves the column visible state from the column trait.

Parameters
nColThe index of the column
Returns
Is the column visible or not (true / false)
bool CGridListCtrlEx::IsRowSelected ( int  nRow) const

Checks if the LVIS_SELECTED state flag set for the specified row.

Parameters
nRowThe index of the row
Returns
True if the row is selected
void CGridListCtrlEx::LoadColumnState ( int  nConfigCol,
int  nOwnerCol,
CViewConfigSection config 
)
virtual

Loads the column state of a single column.

Parameters
nConfigColThe column index in the persisting interface
nOwnerColThe column index in the owner list control
configThe interface for persisting the configuration
void CGridListCtrlEx::LoadState ( CViewConfigSection config)
virtual

Loads and applies the column configuration for the list control.

Parameters
configThe interface for persisting the configuration
void CGridListCtrlEx::MoveFocusCell ( bool  bMoveRight)
protectedvirtual

Shifts the cell focus left or right in the same row.

Parameters
bMoveRightSpecifies whether the cell focus should be left or right
bool CGridListCtrlEx::MoveSelectedRows ( int  nDropRow)
protectedvirtual

Inserts the selected rows before the specified row.

Parameters
nDropRowInsert the selected rows before this row
Returns
Was rows rearranged ? (true / false)

Reimplemented in CGridListCtrlGroups.

BOOL CGridListCtrlEx::OnBeginDrag ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_BEGINDRAG message handler called when performing left-click drag.

Used to perform drag drop from the list control. Override this method to disable drag drop of rows.

Parameters
pNMHDRPointer to an NMLISTVIEW structure specifying the column
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnBeginLabelEdit ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_BEGINLABELEDIT message handler called when start editing a cell.

Blocks cell edit events from the parent CListCtrl for the label column.

Parameters
pNMHDRPointer to an LV_DISPINFO structure
pResultSet to TRUE prevents the user from editing the label, else FALSE
Returns
Is final message handler (Return FALSE to continue routing the message)
void CGridListCtrlEx::OnChar ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
)
protectedvirtual

WM_CHAR message handler for performing keyboard search with subitems.

Parameters
nCharSpecifies the virtual key code of the given key.
nRepCntRepeat count (the number of times the keystroke is repeated as a result of the user holding down the key).
nFlagsSpecifies the scan code, key-transition code, previous key state, and context code
int CGridListCtrlEx::OnClickEditStart ( int  nRow,
int  nCol,
CPoint  pt,
bool  bDblClick 
)
protectedvirtual

Override this method to control whether cell edit should be started when clicked with the mouse.

Parameters
nRowThe index of the row
nColThe index of the column
ptThe position clicked, in client coordinates.
bDblClickWhether the position was double clicked
Returns
How should the cell editor be started (0 = No editor, 1 = Start Editor, 2 = Start Editor and block click-event)
void CGridListCtrlEx::OnContextMenu ( CWnd *  pWnd,
CPoint  point 
)
protectedvirtual

WM_CONTEXTMENU message handler to show popup menu when mouse right click is used (or SHIFT+F10 on the keyboard)

Parameters
pWndHandle to the window in which the user right clicked the mouse
pointPosition of the cursor, in screen coordinates, at the time of the mouse click.

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::OnContextMenuCell ( CWnd *  pWnd,
CPoint  point,
int  nRow,
int  nCol 
)
protectedvirtual

Override this method to change the context menu when activating context menu for a single cell.

Parameters
pWndHandle to the window in which the user right clicked the mouse
pointPosition of the cursor, in screen coordinates, at the time of the mouse click.
nRowThe index of the row
nColThe index of the column

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::OnContextMenuGrid ( CWnd *  pWnd,
CPoint  point 
)
protectedvirtual

Override this method to change the context menu when activating context menu in client area with no rows.

Parameters
pWndHandle to the window in which the user right clicked the mouse
pointPosition of the cursor, in screen coordinates, at the time of the mouse click.

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::OnContextMenuHeader ( CWnd *  pWnd,
CPoint  point,
int  nCol 
)
protectedvirtual

Override this method to change the context menu when activating context menu for the column headers.

Parameters
pWndHandle to the window in which the user right clicked the mouse
pointPosition of the cursor, in screen coordinates, at the time of the mouse click.
nColThe index of the column

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::OnContextMenuKeyboard ( CWnd *  pWnd,
CPoint  point 
)
protectedvirtual

Override this method to change the context menu when using the keyboard shortcut SHIFT+F10.

Parameters
pWndHandle to the window in which the user right clicked the mouse
pointPosition of the cursor, in screen coordinates, at the time of the mouse click.
LRESULT CGridListCtrlEx::OnCopy ( WPARAM  wParam,
LPARAM  lParam 
)
protectedvirtual

WM_COPY message handler.

Not sent by default, but just incase

Parameters
wParamNot used
lParamNot used
Returns
Not used
int CGridListCtrlEx::OnCreate ( LPCREATESTRUCT  lpCreateStruct)
protectedvirtual

WM_CREATE message handler.

Called when inside a CView.

Parameters
lpCreateStructPointer to a CREATESTRUCT structure that contains information about the list control object being created.
void CGridListCtrlEx::OnCustomDraw ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

Performs custom drawing of the CListCtrl.

Parameters
pNMHDRPointer to NMLVCUSTOMDRAW structure
pResultModification to the drawing stage (CDRF_NEWFONT, etc.)
void CGridListCtrlEx::OnCustomDrawCell ( int  nRow,
int  nCol,
NMLVCUSTOMDRAW *  pLVCD,
LRESULT *  pResult 
)
protectedvirtual

Performs custom drawing of the CListCtrl using CGridColumnTrait.

Parameters
nRowThe index of the row
nColThe index of the column
pLVCDPointer to NMLVCUSTOMDRAW structure
pResultModification to the drawing stage (CDRF_NEWFONT, etc.)
void CGridListCtrlEx::OnCustomDrawRow ( int  nRow,
NMLVCUSTOMDRAW *  pLVCD,
LRESULT *  pResult 
)
protectedvirtual

Performs custom drawing of the CListCtrl using CGridRowTrait.

Parameters
nRowThe index of the row
pLVCDPointer to NMLVCUSTOMDRAW structure
pResultModification to the drawing stage (CDRF_NEWFONT, etc.)
LRESULT CGridListCtrlEx::OnDeleteColumn ( WPARAM  wParam,
LPARAM  lParam 
)
protectedvirtual

LVM_DELETECOLUMN message handler to ensure the column trait container is updated when columns are removed.

Parameters
wParamThe index of the column just deleted
lParamNot used
Returns
Whether the column was succesfully deleted
bool CGridListCtrlEx::OnDisplayCellColor ( NMLVCUSTOMDRAW *  pLVCD)
virtual

Override this method to change the colors used for drawing a cell.

Parameters
pLVCDPointer to NMLVCUSTOMDRAW structure
Returns
Color is overrided
bool CGridListCtrlEx::OnDisplayCellColor ( int  nRow,
int  nCol,
COLORREF &  textColor,
COLORREF &  backColor 
)
virtual

Override this method to change the colors used for drawing a cell.

Parameters
nRowThe index of the row
nColThe index of the column
textColorThe text color used when drawing the cell
backColorThe background color when drawing the cell
Returns
Color is overrided
bool CGridListCtrlEx::OnDisplayCellFont ( NMLVCUSTOMDRAW *  pLVCD,
LOGFONT &  font 
)
virtual

Override this method to change the font used for drawing a cell.

Parameters
pLVCDPointer to NMLVCUSTOMDRAW structure
fontThe font description to use for drawing the cell
Returns
Font is overrided
bool CGridListCtrlEx::OnDisplayCellFont ( int  nRow,
int  nCol,
LOGFONT &  font 
)
virtual

Override this method to change the font used for drawing a cell.

Parameters
nRowThe index of the row
nColThe index of the column
fontThe font description to use for drawing the cell
Returns
Font is overrided
bool CGridListCtrlEx::OnDisplayCellImage ( int  nRow,
int  nCol,
int &  nImageId 
)
virtual

Override this method to provide icon index when drawing cells Only called when using I_IMAGECALLBACK with SetCellImage()

Parameters
nRowThe index of the row
nColThe index of the column
nImageIdThe icon index in the list control image list
Returns
True if there is an icon image to display
void CGridListCtrlEx::OnDisplayCellItem ( LVITEM &  lvi)
virtual

Override this method to provide text string and image index when drawing cells.

  • Called when using LPSTR_TEXTCALLBACK with CListCtrl::SetItemText()
  • Called when using I_IMAGECALLBACK with SetCellImage()
Parameters
lviThe item that requires cell text and image index
bool CGridListCtrlEx::OnDisplayCellText ( int  nRow,
int  nCol,
CString &  strText 
)
virtual

Override this method to provide text string when drawing cells Only called when using LPSTR_TEXTCALLBACK with CListCtrl::SetItemText()

Parameters
nRowThe index of the row
nColThe index of the column
strTextText string to display in the cell
Returns
True if there is text string to display
bool CGridListCtrlEx::OnDisplayCellTooltip ( const CPoint &  point) const
virtual

Override this method if wanting to specify whether a tooltip is available.

Called constantly while the mouse is moving over the list-control.

Parameters
pointCurrent mouse position relative to the upper-left corner of the window
Returns
Start tooltip timer for displaying tooltip (true / false)
bool CGridListCtrlEx::OnDisplayCellTooltip ( int  nRow,
int  nCol,
CString &  strResult 
)
virtual

Override this method to display a custom tooltip text when holding the mouse over a cell.

Called after the tooltip timer has fired.

Parameters
nRowThe index of the row
nColThe index of the column
strResultThe text value to display in the tooltip
Returns
Is tooltip available for current cell (true / false)
bool CGridListCtrlEx::OnDisplayColumnTooltip ( int  nCol,
CString &  strResult 
) const
virtual

Override this method to display a custom tooltip text when holding the mouse over a column header.

Called constantly while the mouse is moving over the header-control.

Parameters
nColThe index of the column
strResultThe text value to display in the tooltip
Returns
Is tooltip available for current column (true / false)
void CGridListCtrlEx::OnDisplayDragOverRow ( int  nRow)
virtual

Override this method to react to mouse over event during drag drop.

Parameters
nRowThe index of the row
bool CGridListCtrlEx::OnDisplayRowColor ( int  nRow,
COLORREF &  textColor,
COLORREF &  backColor 
)
virtual

Override this method to change the color used for drawing a row.

Parameters
nRowThe index of the row
textColorThe text color used when drawing the row
backColorThe background color when drawing the row
Returns
Color is overrided
bool CGridListCtrlEx::OnDisplayRowFont ( int  nRow,
LOGFONT &  font 
)
virtual

Override this method to change the font used for drawing a row.

Parameters
nRowThe index of the row
fontThe font description to use for drawing the row
Returns
Font is overrided
bool CGridListCtrlEx::OnDisplayToClipboard ( CString &  strResult,
bool  includeHeader = true 
)
virtual

Override this method to control what is placed in the global clipboard.

Parameters
strResultText to place in the clipboard
includeHeaderInclude column headers when copying to clipboard
Returns
Text is available for the clipboard
bool CGridListCtrlEx::OnDisplayToClipboard ( int  nRow,
CString &  strResult 
)
virtual

Override this method to control what to place in the clipboard for a single row.

Parameters
nRowThe index of the row
strResultText to place in the clipboard
Returns
Text is available for the clipboard
bool CGridListCtrlEx::OnDisplayToClipboard ( int  nRow,
int  nCol,
CString &  strResult 
)
virtual

Override this method to control what to place in the clipboard for a single cell.

Parameters
nRowThe index of the row
nColThe index of the column
strResultText to place in the clipboard
Returns
Text is available for the clipboard
bool CGridListCtrlEx::OnDisplayToDragDrop ( CString &  strResult)
virtual

Override this method to control what data is selected for drag drop operation.

Parameters
strResultText to place in the drag drop cache
Returns
Text is available for the drag drop operation
DROPEFFECT CGridListCtrlEx::OnDragEnter ( COleDataObject *  pDataObject,
DWORD  dwKeyState,
CPoint  point 
)
protectedvirtual

Called by the framework when the cursor is first dragged into the window.

Parameters
pDataObjectPoints to the data object containing the data that can be dropped
dwKeyStateContains the state of the modifier keys (MK_SHIFT, MK_CONTROL, etc.)
pointContains the current location of the cursor in client coordinates.
Returns
The effect that would result if a drop were attempted at the location specified by point.
SCODE CGridListCtrlEx::OnDragGiveFeedback ( DROPEFFECT  dropEffect)
protectedvirtual

Called by the framework during drag-drop operation, and allows one to give visual feedback to the end user during a drag-and-drop operation.

Parameters
dropEffectThe DROPEFFECT value returned by the most recent call to IDropTarget::DragEnter, IDropTarget::DragOver, or IDropTarget::DragLeave.
Returns
S_OK if having performed ::SetCursor()
DROPEFFECT CGridListCtrlEx::OnDragOver ( COleDataObject *  pDataObject,
DWORD  dwKeyState,
CPoint  point 
)
protectedvirtual

Called by the framework when the cursor is dragged over the window.

Parameters
pDataObjectPoints to the data object containing the data that can be dropped
dwKeyStateContains the state of the modifier keys (MK_SHIFT, MK_CONTROL, etc.)
pointContains the current location of the cursor in client coordinates.
Returns
The effect that would result if a drop were attempted at the location specified by point.
BOOL CGridListCtrlEx::OnDrop ( COleDataObject *  pDataObject,
DROPEFFECT  dropEffect,
CPoint  point 
)
protectedvirtual

Called by the framework when a drop operation is to occur.

Parameters
pDataObjectPoints to the data object containing the data that can be dropped
dropEffectThe effect that the user chose for the drop operation (DROPEFFECT_COPY, DROPEFFECT_MOVE, DROPEFFECT_LINK)
pointContains the current location of the cursor in client coordinates.
Returns
Nonzero if the drop is successful; otherwise 0
BOOL CGridListCtrlEx::OnDropExternal ( COleDataObject *  pDataObject,
DROPEFFECT  dropEffect,
CPoint  point 
)
protectedvirtual

Called by the framework when a drop operation is to occur, where the origin is an external source.

Parameters
pDataObjectPoints to the data object containing the data that can be dropped
dropEffectThe effect that the user chose for the drop operation (DROPEFFECT_COPY, DROPEFFECT_MOVE, DROPEFFECT_LINK)
pointContains the current location of the cursor in client coordinates.
Returns
Nonzero if the drop is successful; otherwise 0
BOOL CGridListCtrlEx::OnDropSelf ( COleDataObject *  pDataObject,
DROPEFFECT  dropEffect,
CPoint  point 
)
protectedvirtual

Called by the framework when a drop operation is to occur, where the origin is the CGridListCtrlEx itself.

Parameters
pDataObjectPoints to the data object containing the data that can be dropped
dropEffectThe effect that the user chose for the drop operation (DROPEFFECT_COPY, DROPEFFECT_MOVE, DROPEFFECT_LINK)
pointContains the current location of the cursor in client coordinates.
Returns
Nonzero if the drop is successful; otherwise 0

Reimplemented in CGridListCtrlGroups.

CWnd * CGridListCtrlEx::OnEditBegin ( int  nRow,
int  nCol 
)
protectedvirtual

Override this method to control whether cell editing is allowed for a cell.

Called when start editing a cell value

Parameters
nRowThe index of the row
nColThe index of the column
Returns
Pointer to the cell editor (If NULL then block cell editing)
CWnd * CGridListCtrlEx::OnEditBegin ( int  nRow,
int  nCol,
CPoint  pt 
)
protectedvirtual

Override this method to control whether cell editing is allowed for a cell.

Called when start editing a cell value

Parameters
nRowThe index of the row
nColThe index of the column
ptThe position clicked, in client coordinates.
Returns
Pointer to the cell editor (If NULL then block cell editing)
bool CGridListCtrlEx::OnEditComplete ( int  nRow,
int  nCol,
CWnd *  pEditor,
LV_DISPINFO *  pLVDI 
)
protectedvirtual

Override this method to validate the new value after a cell edit.

Called when completed editing of a cell value

Parameters
nRowThe index of the row
nColThe index of the column
pEditorPointer to the cell editor created by the column trait
pLVDISpecifies the properties of the new cell value
Returns
Is the new cell value accepted
BOOL CGridListCtrlEx::OnEndLabelEdit ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_ENDLABELEDIT message handler called when completed a cell edit.

Makes it possible to validate input, and reject invalid values.

Parameters
pNMHDRPointer to an LV_DISPINFO structure
pResultSet to TRUE accepts the cell edit, else FALSE
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnGetDispInfo ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_GETDISPINFO message handler, which is called when details are needed for an item that specifies callback.

  • Cell-Text, when item is using LPSTR_TEXTCALLBACK
  • Cell-Image, when item is using I_IMAGECALLBACK
Parameters
pNMHDRPointer to an NMLVDISPINFO structure
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)

Reimplemented in CGridListCtrlGroups.

BOOL CGridListCtrlEx::OnHeaderBeginDrag ( UINT  ,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

HDN_BEGINDRAG message handler called when about to move a column to a new position.

Used to ensure that any cell value editing is completed.

Parameters
pNMHDRPointer to an NMHEADER structure with information about the column just resized
pResultSet to FALSE to allow header control to automatically manage column order. Set to TRUE if manually wanting to manage column order.
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnHeaderBeginResize ( UINT  ,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

HDN_BEGINTRACK message handler called when resizing columns.

Used to prevent resizing of hidden columns.

Parameters
pNMHDRPointer to an NMHEADER structure with information about the column being resized
pResultSet to FALSE to allow tracking of the divider, or TRUE to prevent tracking
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnHeaderClick ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_COLUMNCLICK message handler called when clicking a column header.

Used to update the row sorting according to the clicked column.

Parameters
pNMHDRPointer to an NMLISTVIEW structure specifying the column
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnHeaderDividerDblClick ( UINT  ,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

HDN_DIVIDERDBLCLICK message handler called when double clicking the divider in the columns of the CHeaderCtrl.

Used to prevent resizing of hidden columns.

Parameters
pNMHDRPointer to an NMHEADER structure with information about the divider was double-clicked
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnHeaderEndDrag ( UINT  ,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

HDN_ENDDRAG message handler called after a column have been dragged, but before the column order has been updated.

Used to ensure that visible columns are not dragged in between invisible columns.

Parameters
pNMHDRPointer to an NMHEADER structure with information about the column just resized
pResultIf the owner is performing external (manual) drag-and-drop management, it must be set to FALSE
Returns
Is final message handler (Return FALSE to continue routing the message)

Reimplemented in CGridListCtrlGroups.

BOOL CGridListCtrlEx::OnHeaderEndResize ( UINT  ,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

HDN_ENDTRACK message handler called after column resize.

Used to persist the new column state.

Parameters
pNMHDRPointer to an NMHEADER structure with information about the column just resized
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnHeaderItemChanging ( UINT  ,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

HDN_ITEMCHANGING message handler called during column resize.

Used to enforce column max and min width.

Parameters
pNMHDRPointer to an NMHEADER structure with information about the column just resized
pResultReturns FALSE to allow the changes, or TRUE to prevent them.
Returns
Is final message handler (Return FALSE to continue routing the message)
void CGridListCtrlEx::OnHScroll ( UINT  nSBCode,
UINT  nPos,
CScrollBar *  pScrollBar 
)
protectedvirtual

WM_HSCROLL message handler called when scrolling in the list control.

Used to ensure that any cell value editing is completed.

Parameters
nSBCodeSpecifies a scroll-bar code that indicates the user's scrolling request
nPosSpecifies the scroll-box position if the scroll-bar code is SB_THUMBPOSITION or SB_THUMBTRACK (Can be negative)
pScrollBarIf the scroll message came from a scroll-bar control, contains a pointer to the control
LRESULT CGridListCtrlEx::OnInsertColumn ( WPARAM  wParam,
LPARAM  lParam 
)
protectedvirtual

LVM_INSERTCOLUMN message handler to ensure the column trait container is updated when columns are inserted.

Parameters
wParamThe index of the column just inserted
lParamNot used
Returns
Whether the column was succesfully inserted
BOOL CGridListCtrlEx::OnItemChanged ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_ITEMCHANGED message handler called when a row changes state When using LVS_OWNERDATA style, this only gets called for single item state change.

Parameters
pNMHDRPointer to LPNMLISTVIEW structure
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnItemClick ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

NM_CLICK message handler called when left-clicking in a cell.

Just to show how to catch the single click event.

Parameters
pNMHDRPointer to NMITEMACTIVATE structure
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
BOOL CGridListCtrlEx::OnItemDblClick ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

NM_DBLCLK message handler called when double-clicking in a cell.

Just to show how to catch the double click event.

Parameters
pNMHDRPointer to NMITEMACTIVATE structure
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
int CGridListCtrlEx::OnKeyboardSearch ( int  nCol,
int  nStartRow,
const CString &  strSearch 
)
virtual

Override this method to optimize the keyboard search for LVS_OWNERDATA (virtual list)

Parameters
nColColumn where the search is performed
nStartRowRow index at which the search will start
strSearchString to search for
Returns
Row index matching the specified search string
void CGridListCtrlEx::OnKeyDown ( UINT  nChar,
UINT  nRepCnt,
UINT  nFlags 
)
protectedvirtual

WM_KEYDOWN message handler for performing keyboard navigation.

Parameters
nCharSpecifies the virtual key code of the given key.
nRepCntRepeat count (the number of times the keystroke is repeated as a result of the user holding down the key).
nFlagsSpecifies the scan code, key-transition code, previous key state, and context code
void CGridListCtrlEx::OnKillFocus ( CWnd *  pNewWnd)
protectedvirtual

WM_KILLFOCUS message handler called when list control is loosing focus to other control.

Used to persist the new column state. Fix redraw issue.

Parameters
pNewWndPointer to the window that receives the input focus (may be NULL or may be temporary).
void CGridListCtrlEx::OnLButtonDblClk ( UINT  nFlags,
CPoint  point 
)
protectedvirtual

The WM_LBUTTONDBLCLK message is posted when the user double-clicks the left mouse button while the cursor is in the client area of a window Used to flip the checkbox image even when double-clicking.

If wanting to handle the double-click event, then one should use NM_DBLCLK

Parameters
nFlagsIndicates whether various virtual keys are down (MK_CONTROL, MK_SHIFT, etc.)
pointMouse cursor position relative to the upper-left corner of the client area.

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::OnLButtonDown ( UINT  nFlags,
CPoint  point 
)
protectedvirtual

WM_LBUTTONDOWN message handler called when the user presses the left mouse button while the cursor is in the client area of a window.

Used to activate the cell editor of the cell clicked using the mouse.

Parameters
nFlagsIndicates whether various virtual keys are down (MK_CONTROL, MK_SHIFT, etc.)
pointMouse cursor position relative to the upper-left corner of the client area.
bool CGridListCtrlEx::OnOwnerDataDisplayCheckbox ( int  nRow)
virtual

Override this method to display checkbox state for LVS_OWNERDATA (virtual list).

Parameters
nRowThe row index being displayed
Returns
Is row checked ?
BOOL CGridListCtrlEx::OnOwnerDataFindItem ( NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

LVN_ODFINDITEM message handler for performing keyboard search when LVS_OWNERDATA (virtual list)

Parameters
pNMHDRPointer to NMLVFINDITEM structure
pResultSet to the row-index matching the keyboard search (-1 for no match)
Returns
Is final message handler (Return FALSE to continue routing the message)
void CGridListCtrlEx::OnOwnerDataToggleCheckBox ( int  nRow,
bool  bChecked 
)
virtual

Override this method to react to check box being toggled for LVS_OWNERDATA (virtual list).

Remember to force a redraw to ensure the new checkbox state is displayed.

Parameters
nRowThe row index where the checkbox should be toggled
bCheckedWhether the checkbox has been checked on unchecked
void CGridListCtrlEx::OnPaint ( )
protectedvirtual

WM_PAINT message handler called when needing to redraw list control.

Used to display text when the list control is empty

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::OnRButtonDown ( UINT  nFlags,
CPoint  point 
)
protectedvirtual

WM_RBUTTONDOWN message handler called when the user presses the right mouse button while the cursor is in the client area of a window.

Used to change focus to the cell clicked using the mouse.

Parameters
nFlagsIndicates whether various virtual keys are down (MK_CONTROL, MK_SHIFT, etc.)
pointMouse cursor position relative to the upper-left corner of the client area.
LRESULT CGridListCtrlEx::OnSetColumnWidth ( WPARAM  wParam,
LPARAM  lParam 
)
protectedvirtual

LVM_SETCOLUMNWIDTH message handler called when wanting to resize a column.

Used to prevent resize of hidden columns.

Parameters
wParamThe index of the column
lParamNew width of the column (High word)
Returns
Nonzero indicates success. Zero indicates otherwise.
void CGridListCtrlEx::OnSetFocus ( CWnd *  pOldWnd)
protectedvirtual

WM_SETFOCUS message handler called when list control is receiving focus from other control.

Fix redraw issue.

Parameters
pOldWndPointer to the window that looses focus (may be NULL or may be temporary)
LRESULT CGridListCtrlEx::OnSetFont ( WPARAM  wParam,
LPARAM  lParam 
)
protectedvirtual

WM_SETFONT message handler.

For re-applying margin if font changes

Parameters
wParamHandle to the font (HFONT), where NULL means default font
lParamThe low-order word of lParam specifies whether to redraw
Returns
Not used
int CGridListCtrlEx::OnToolHitTest ( CPoint  point,
TOOLINFO *  pTI 
) const
protectedvirtual

Called by the MFC framework during mouse over to detemine whether a point is in the bounding rectangle of the specified tool.

It requests a TTN_NEEDTEXT notification when the tooltip text is needed instead of building and allocating the tooltip text at mouse over.

If needing to display more than 80 characters, then the easy solution is to override this method and allocate and build the tooltip right away.

int MyListCtrl::OnToolHitTest(CPoint point, TOOLINFO * pTI) const
{
int rc = CGridListCtrlEx::OnToolHitTest(point, pTI);
if (rc==-1)
return -1;
pTI->lpszText = new TCHAR[256]; // Will automatically be deallocated by MFC
return rc;
}
Parameters
pointCurrent mouse position relative to the upper-left corner of the window
pTIA pointer to a TOOLINFO structure
Returns
Window control ID of the tooltip control (-1 if no tooltip control was found)
BOOL CGridListCtrlEx::OnToolNeedText ( UINT  id,
NMHDR *  pNMHDR,
LRESULT *  pResult 
)
protectedvirtual

TTN_NEEDTEXT message handler called when the tooltip timer fires.

It uses the default tooltip buffer, that limits the tooltip to 80 characters.

If needing to display more than 80 characters, then the easy solution is to override CGridListCtrlEx::OnToolHitTest().

Parameters
idNot used
pNMHDRPointer to an TOOLTIPTEXT structure
pResultNot used
Returns
Is final message handler (Return FALSE to continue routing the message)
void CGridListCtrlEx::OnVScroll ( UINT  nSBCode,
UINT  nPos,
CScrollBar *  pScrollBar 
)
protectedvirtual

WM_VSCROLL message handler called when scrolling in the list control.

Used to ensure that any cell value editing is completed.

Parameters
nSBCodeSpecifies a scroll-bar code that indicates the user's scrolling request
nPosSpecifies the scroll-box position if the scroll-bar code is SB_THUMBPOSITION or SB_THUMBTRACK (Can be negative)
pScrollBarIf the scroll message came from a scroll-bar control, contains a pointer to the control
void CGridListCtrlEx::OpenColumnEditor ( int  nCol)
virtual

Open the column configuration editor for the column (If one available)

Parameters
nColThe index of the column
void CGridListCtrlEx::PreSubclassWindow ( )
protectedvirtual

Normally used for subclassing controls, but here used to configure initial style when list control is created.

BOOL CGridListCtrlEx::RegisterDropTarget ( )
protectedvirtual

Registers the CListCtrl as a valid OLE drag drop target.

Returns
Nonzero if successful; otherwise zero.
void CGridListCtrlEx::SaveColumnState ( int  nConfigCol,
int  nOwnerCol,
CViewConfigSection config 
)
virtual

Saves the column state of a single column.

Parameters
nConfigColThe column index in the persisting interface
nOwnerColThe column index in the owner list control
configThe interface for persisting the configuration
void CGridListCtrlEx::SaveState ( CViewConfigSection config)
virtual

Saves the column configuration of the list control.

Parameters
configThe interface for persisting the configuration
BOOL CGridListCtrlEx::SelectRow ( int  nRow,
bool  bSelect 
)

Sets the LVIS_SELECTED state flag for the specified row.

Parameters
nRowThe index of the row. -1 means all rows
bSelectWhether row should be selected or not
Returns
Nonzero if successful; otherwise zero.
BOOL CGridListCtrlEx::SetCellImage ( int  nRow,
int  nCol,
int  nImageId 
)

Sets the icon of the specified cell.

Parameters
nRowThe index of the row
nColThe index of the column
nImageIdThe icon index in the list control image list
Returns
Nonzero if successful; otherwise zero.
void CGridListCtrlEx::SetCellMargin ( double  margin)
virtual

Takes the current font and increases the font with the given margin multiplier.

Increases the row-height but keeps the cell font intact. Gives more room for the grid-cell editors and their border.

Parameters
marginMultiplier for how much to increase the font size
BOOL CGridListCtrlEx::SetColumnWidthAuto ( int  nCol = -1,
bool  bIncludeHeader = false 
)
virtual

Resizes the width of a column according the contents of the cells below.

Parameters
nColThe index of the column
bIncludeHeaderInclude the column header text the column width calculation
Returns
Nonzero if successful; otherwise zero.
void CGridListCtrlEx::SetDefaultRowTrait ( CGridRowTrait pRowTrait)
virtual

Sets the default row trait used by default for drawing rows.

Parameters
pRowTraitPointer to row trait
void CGridListCtrlEx::SetEmptyMarkupText ( const CString &  strText)

Update the markup text displayed when the list control is empty.

Parameters
strTextText to display when list control is empty
void CGridListCtrlEx::SetFocusCell ( int  nCol,
bool  bRedraw = false 
)
virtual

Changes the focus cell.

Override this method and set m_FocusCell = -1 if wanting to disable subitem focus

Parameters
nColThe index of the column
bRedrawShould the focus row be redrawn ? (true / false)
void CGridListCtrlEx::SetFocusRow ( int  nRow)

Sets LVIS_FOCUSED state flag for the specified row.

Parameters
nRowThe index of the row
void CGridListCtrlEx::SetSortArrow ( int  nCol,
bool  bAscending 
)
virtual

Puts a sort-icon in the column header of the specified column.

Parameters
nColThe index of the column
bAscendingShould the arrow be up or down
void CGridListCtrlEx::SetupColumnConfig ( CViewConfigSectionProfiles pColumnConfig,
bool  bConfigOwner = true 
)
virtual

Sets the interface for handling state persistence for the list control.

Parameters
pColumnConfigThe new column state interface handler
bConfigOwnerDestructor should free the column state object (true / false)
BOOL CGridListCtrlEx::ShowColumn ( int  nCol,
bool  bShow 
)
virtual

Changes the visible state of column.

Hides a column by resizing the column width to zero and moving it to the outer left in the column order. Shows a column by returning it to its original position.

Parameters
nColThe index of the column
bShowSpecifies whether the column should be shown or hidden
Returns
Nonzero if successful; otherwise zero.
bool CGridListCtrlEx::SortColumn ( int  nCol,
bool  bAscending 
)
protectedvirtual

Changes the row sorting in regard to the specified column.

Parameters
nColThe index of the column
bAscendingPerform sorting in ascending or descending order
Returns
True / false depending on whether sort is possible

Reimplemented in CGridListCtrlGroups.

void CGridListCtrlEx::SwichColumnProfile ( const CString &  strProfile)
virtual

Switch to different column configurations profile.

Parameters
strProfileList of available column profiles