📄 gridctrl.shtml
字号:
GVL_VERT - Vertical lines only
GVL_BOTH - Both vertical and horizontal lines
</FONT></PRE>
<a name="CellMask">Cell data mask</a>
<PRE><FONT COLOR="#990000">GVIF_TEXT - Cell text will be accessed
GVIF_IMAGE - Cell image number will be accessed
GVIF_PARAM - Cell user data (lParam) will be accessed
GVIF_STATE - Cell state will be accessed
GVIF_BKCLR - Cell background colour will be accessed
GVIF_FGCLR - Cell foreground colour will be accessed
GVIF_FORMAT - Cell format field will be accessed
GVIF_FONT - Cell logical font will be accessed
</FONT></PRE>
<a name="CellState">Cell states</a>
<PRE><FONT COLOR="#990000">GVIS_FOCUSED - Cell has focus
GVIS_SELECTED - Cell is selected
GVIS_DROPHILITED - Cell is drop highlighted
GVIS_READONLY - Cell is read-only and cannot be edited
GVIS_FIXED - Cell is fixed (not used)
GVIS_MODIFIED - Cell has been modified
</FONT></PRE>
<a name="CellSearch">Cell Searching options</a>
<PRE><FONT COLOR="#990000">GVNI_FOCUSED - Search for focus cell
GVNI_SELECTED - Search for selected cells
GVNI_DROPHILITED - Search for drop highlighted cells
GVNI_READONLY - Search for read-only cells
GVNI_FIXED - Search for fixed cells (not used)
GVNI_MODIFIED - Search for modified cells
GVNI_ABOVE - Search above initial cell
GVNI_BELOW - Search below initial cell
GVNI_TOLEFT - Search to the left of the initial cell
GVNI_TORIGHT - Search to the right of the initial cell
GVNI_ALL - Search all cells in the grid starting from the given cell
GVNI_AREA - Search all cells below and to the right of the given cell
</FONT></PRE>
<a name="Messages">Notification messages</a>
<PRE><FONT COLOR="#990000">GVN_BEGINDRAG - Sent when dragging starts
GVN_BEGINLABELEDIT - Sent when inplace editing starts
GVN_ENDLABELEDIT - Sent when inplace editing stops
</FONT></PRE>
<p>These messages are exactly the same as their LVN_... counterparts, except
they use an NM_GRIDVIEW structure:
<PRE><FONT COLOR="#990000">typedef struct tagNM_GRIDVIEW {
NMHDR hdr;
int iRow;
int iColumn;
} NM_GRIDVIEW;
</FONT></PRE>
<h3><a name="Overrides">Protected overridable functions</a></h3>
<p> These functions have been made virtual to aid extensiblity.
<p><b>Printing</b> - called in OnPrint.
<PRE><FONT COLOR="#990000">virtual void PrintColumnHeadings(CDC *pDC, CPrintInfo *pInfo);
virtual void PrintHeader(CDC *pDC, CPrintInfo *pInfo);
virtual void PrintFooter(CDC *pDC, CPrintInfo *pInfo);
</FONT></PRE>
<p><b>Drag n' drop</b>
<PRE><FONT COLOR="#990000">
virtual CImageList* CreateDragImage(CPoint *pHotSpot) - No longer necessary but I
thought the code was cool so
kept it :).
</FONT></PRE>
<p><b>Mouse Clicks</b>
<PRE><FONT COLOR="#990000">virtual void OnFixedColumnClick(CCellID& cell);
virtual void OnFixedRowClick(CCellID& cell);
</FONT></PRE>
<p><b>Editing</b>
<PRE><FONT COLOR="#990000">virtual void OnEditCell(int nRow, int nCol, UINT nChar) - Starting edit
virtual void OnEndEditCell(int nRow, int nCol, CString str) - ending edit
virtual void CreateInPlaceEditControl(CRect& rect, DWORD dwStyle, int nRow, int nCol,
LPCTSTR szText, int nChar) - Create the inplace edit control
</FONT></PRE>
<p><b>Drawing</b>
<PRE><FONT COLOR="#990000">virtual CSize GetCellExtent(int nRow, int nCol, CDC* pDC) - Returns Size of cell
according to cell
contents.
virtual void OnDraw(CDC& origDC); - Draws everything
virtual BOOL DrawFixedCell(CDC* pDC, int nRow, int nCol, - Draws Fixed cells
CRect rect, BOOL bEraseBk=FALSE)
virtual BOOL DrawCell(CDC* pDC, int nRow, int nCol, - Draws normal cells
CRect rect, BOOL bEraseBk=FALSE)
</FONT></PRE>
<p><b>Construction and Cleanup</b>
<PRE><FONT COLOR="#990000">virtual CGridCell* CreateCell(int nRow, int nCol) - Creates a new cell and
initialises it.
virtual void EmptyCell(CGridCell* cell, int nRow, int nCol) - Performs any cleanup
necessary before removing
cells
</FONT></PRE>
<h3><a name="Clipboard">Clipboard</a></h3>
<p>A number of Clipboard functions have been included.<br>
<TABLE CELLSPACING=0 WIDTH="90%">
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">virtual void OnEditCut()</FONT></PRE>
</TD><TD WIDTH="50%">Copies contents of selected cells to clipboard and deletes the
contents of the selected cells. (Ctrl-X)</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">virtual void OnEditCopy()</FONT></PRE>
</TD><TD WIDTH="50%">Copies contents of selected cells to clipboard. (Ctrl-C)</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">virtual void OnEditPaste()</FONT></PRE>
</TD><TD WIDTH="50%">Pastes the contents of the clipboard to the grid. (Ctrl-V)</td>
</TR>
<TR VALIGN=TOP><TD WIDTH="50%">
<PRE><FONT COLOR="#990000">virtual void OnEditSelectAll()</FONT></PRE>
</TD><TD WIDTH="50%">Not actually a clipboard function, but handy nevertheless.
This routine selects all cells in the grid. (Ctrl-A)</td>
</TR>
</table>
<h3><a name="Acknowledgements">Acknowledgements</a></h3>
<p>This would not have been possible without the following authors
making their code freely available:
<ul>
<li><a href="mailto:chinajoe@aol.com">Joe Willcoxson</a>: Joe's original code spurred this project on, and
provided the basic structure of this grid control.</li>
<li><a href="keithr@europa.com">Keith Rule</a>: Keith provided a neat CMemDC
class to make flicker free display simple, and provided sample OLE copy/paste/drag/drop
code.</li>
<li><a href="rreddy@braintech.com">Ravi Reddy</a>: I used a derivation of Ravi's listview
printing code.</li>
<li><a href="zafir@dsp.com">Zafir Anjum</a>: Provided the starting point for my CInPlaceEdit,
the sorting routines and the TitleTip code, and is the site maintainer for The MFC Programmers Sourcebook,
at <A HREF="http://www.codeguru.com">www.codeguru.com</a>. Zafir has done a great
job of allowing devlopers to swap code and learn from each other.
<li>All those who contribute to the <a href="http://www.codeguru.com">MFC Programmers Sourcebook</a>:
Without you all I would not have been able to write this.</li>
<li>All those who sent in bug reports, suggestions, improvements and encouragement. Thank you!</li>
</ul>
<h3><a name="History">History</a></h3>
<p>Version
<TABLE CELLSPACING=0 WIDTH="90%">
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.00 20 Feb 1998</td>
<TD WIDTH="70%">First release version.</td>
</TR>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.01 24 Feb 1998</td>
<TD WIDTH="70%">Memory leak fix (Jens Bohlmann <bohly@jelo.de>)<br>
Mistype in CMemDC.h - Claus Arend-Schneider<br>
Bug in GetSelectedCount - Lyn Newton<br></td>
</TR>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.02 4 Mar 1998</td>
<TD WIDTH="70%">Scrolling a little neater (less dead area)<br>
Cell selection via OnTimer correctly updates Focus cell</td>
</TR>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.03 31 Mar 1998</td>
<TD WIDTH="70%">OnEditCopy, OnEditCut and OnEditPaste clipboard functions added.<br>
Ctrl-X,Ctrl-C and Ctrl-V now initiate clipboard cut, copy and paste.<br>
Support for OLE drag and drop.<br>
Support for Microsoft intellimouse.<br>
"DeleteContents" changed to "DeleteAllItems".<br>
ExpandRowsToFit and ExpandColumnsToFit added.<br>
Added SetHeaderSort and GetHeaderSort.<br>
ExpandRowsToFit and ExpandColumnsToFit added.<br>
Selected cell IDs now stored in a map instead of an array.<br>
Scrolling and scroll selection tweaked a little.<br>
Several minor bugs fixed.<br>
LVN_ENDLABELEDIT now handled using ON_NOTIFY_REFLECT_EX so the parent can
handle it too.<br>
GetItemText() now public.<br>
</td>
</TR>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.04 5 April 1998</td>
<TD WIDTH="70%">Added Ctrl-A = OnEditSelectAll. <br>
Fixed CGridDropTarget double register problem<br>
Minor bug in CopyTextFromGrid (assert on empty string) fixed.<br>
Cleaned up reponse to m_bEditable (OnDrop and Ctrl-X disabled).
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.05 10 May 1998</td>
<TD WIDTH="70%">Memory leak fixed. (Yuheng Zhao)<br>
Changed OLE initialisation (Carlo Comino)<br>
Added separate fore + background cell colours (John Crane).<br>
ExpandToFit etc cleaned up - now decreases and increases cell sizes to
fit client area.<br>
Added notification messages for the grid's parent<br>
Added GVIS_READONLY state<br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.06 20 May 1998</td>
<TD WIDTH="70%">Added TAB key handling (Use Get/SetHandleTabKey to toggle). (Daniela Rybarova)<br>
Intellimouse code correction for whole page scrolling (Paul Grant)<br>
Fixed 16 bit thumb track problems (now 32 bit) (Paul Grant)<br>
Fixed accelerator key problem in CInPlaceEdit (Matt Weagle)<br>
Fixed Stupid ClassWizard code parsing problem (Michael A. Barnhart)<br>
Double buffering now programmatically selectable (Use Get/SetDoubleBuffering)<br>
Workaround for win95 drag and drop registration problem<br>
Corrected UNICODE implementation of clipboard stuff<br>
Dragging and dropping from a selection onto itself no no longer causes the
cells to be emptied<br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.07 26 July 1998</td>
<TD WIDTH="70%">Added EnsureVisible (Roelf Werkman)<br>
Fixed delete key problem on read-only cells (Serge Weinstock)<br>
OnEndInPlaceEdit sends notification AFTER storing the modified text in the cell.<br>
Added CreateInPlaceEditControl to make it easier to change the way cells are edited. (suggested by Chris Clark)<br>
Added Set/GetGridColor.<br>
Tweaked CopyTextToClipboard a little.<br>
SetModified called when cutting text or hitting DEL. (Jonathan Watters)<br>
Focus cell made visible when editing begins.<br>
Blank lines now treated correctly when pasting data<br>
Removed ES_MULTILINE style from the default edit control<br>
Added virtual CreateCell(row, col) function for cell creation and initialisation.<br>
Fonts now specified on a per-cell basis using Get/SetItemFont<br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.08 6 Aug 1998</td>
<TD WIDTH="70%">Ctrl+arrows now allows cell navigation. <br>
Modified CreateInPlaceEditControl to accept ID of control.<br>
Added Titletips to grid cells. (Added EnableTitleTips / GetTitleTips)<br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.09 12 Sep 1998</td>
<TD WIDTH="70%">When printing, parent window title is printed in header - Gert Rijs<br>
GetNextItem search with GVNI_DROPHILITED now returns cells with
GVIS_DROPHILITED set, instead of GVIS_FOCUSED (Franco Bez)<br>
(Also fixed minor bug in GetNextItem) (Franco Bez)<br>
Cell selection using Shift+arrows works - Franco Bez<br>
SetModified called after edits ONLY if contents changed (Franco Bez)<br>
Cell colours now dithered in 256 colour screens.<br>
Support for MSVC 4.2 (Graham Cheetham)<br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.10 29 Nov 1998</td>
<TD WIDTH="70%">Titletips now disappear on a scroll event. Compiler errors
fixed. Grid lines drawing fixed (Graham Cheetham). <br>
Cell focus fix on Isert Row/Col (Jochen Kauffmann) <br>
Added DeleteNonFixedRows() (John Rackley) <br>
Message #define conflict fixed (Oskar Wieland) <br>
Titletips & cell insert/delete fix (Ramesh Dhar) <br>
Titletips repeat-creation bug fixed. <br>
GVN_SELCHANGED message now sends current cell ID <br>
Font resource leak in GetTextExtent fixed (Gavin Jerman) <br>
More TAB fixes (Andreas Ruh) <br>
ID_EDIT_* handlers added. <br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.11 2 Dec 1998</td>
<TD WIDTH="70%">GetNextItem bug fix (suggested by Francis Fu)<br>
InsertColumn (-1) fix (Roy Hopkins)<br>
Was too liberal with the "IsEditable"'s. oops. (Michel Hete)<br>
Made IsCellVisivle public, and added IsCellEditable.<br>
</td>
</tr>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.11a 4 Jan 1999</td>
<TD WIDTH="70%">Compiler errors in VC6 fixed.<br>
</td>
</tr>
<a name="New"></a>
<TR VALIGN=TOP>
<TD WIDTH="30%"> 1.12 10 Apr 1999</td>
<TD WIDTH="70%">Cleanup to allow GRIDCONTROL_NO_CLIPBOARD define<br>
CE #defines added. (Thanks to Frank Uzzolino for a start on this)<br>
TitleTip display fixed for cells with images, plus it now uses cell font<br>
Added GetTextRect and IsCellFixed<br>
Focus change problem when resizing columns fixed (Sergey Nikiforenko)<br>
Grid line drawing problem in fixed cells fixed (Sergey Nikiforenko)<br>
CreateCell format persistance bug fixed (Sergey Nikiforenko)<br>
DeleteColumn now returns TRUE (oops) (R. Elmer) <br>
Enter, Tab and Esc key problem (finally) fixed - Darren Webb and Koay Kah Hoe<br>
OnSize infinite loop fixed - Steve Kowald<br>
GVN_SELCHANGING and GVN_SELCHANGED values changed to avoid conflicts (Hiroaki Watanabe)<br>
Added single row selection mode (Yao Cai)<br>
Mollified image drawing clip problem slightly (still not happy with it)<br>
Reduced unnecessary redraws significantly<br>
GetNextItem additions and bug fix, and GVNI_AREA search option (Franco Bez)<br>
Added GVIS_MODIFIED style for cells, so individual cells can have their modification
status queried. (Franco Bez)<br>
</td>
</tr>
</table>
<P>Last updated: April 10, 1999.
<!--#include virtual="footer.shtml" -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -