GridCtrl.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. /////////////////////////////////////////////////////////////////////////////
  2. // GridCtrl.h : header file
  3. //
  4. // MFC Grid Control - main header
  5. //
  6. // Written by Chris Maunder <cmaunder@mail.com>
  7. // Copyright (c) 1998-2001. All Rights Reserved.
  8. //
  9. // This code may be used in compiled form in any way you desire. This
  10. // file may be redistributed unmodified by any means PROVIDING it is
  11. // not sold for profit without the authors written consent, and
  12. // providing that this notice and the authors name and all copyright
  13. // notices remains intact.
  14. //
  15. // An email letting me know how you are using it would be nice as well.
  16. //
  17. // This file is provided "as is" with no expressed or implied warranty.
  18. // The author accepts no liability for any damage/loss of business that
  19. // this product may cause.
  20. //
  21. // For use with CGridCtrl v2.20+
  22. //
  23. //////////////////////////////////////////////////////////////////////
  24. #if !defined(AFX_GRIDCTRL_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_)
  25. #define AFX_GRIDCTRL_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_
  26. #if _MSC_VER >= 1000
  27. #pragma once
  28. #endif // _MSC_VER >= 1000
  29. #include "CellRange.h"
  30. #include "GridCell.h"
  31. #include <list>
  32. using namespace std;
  33. ///////////////////////////////////////////////////////////////////////////////////
  34. // Defines - these determine the features (and the final size) of the final code
  35. ///////////////////////////////////////////////////////////////////////////////////
  36. //#define GRIDCONTROL_NO_TITLETIPS // Do not use titletips for cells with large data
  37. //#define GRIDCONTROL_NO_DRAGDROP // Do not use OLE drag and drop
  38. //#define GRIDCONTROL_NO_CLIPBOARD // Do not use clipboard routines
  39. #ifdef _WIN32_WCE
  40. # define GRIDCONTROL_NO_TITLETIPS // Do not use titletips for cells with large data
  41. # define GRIDCONTROL_NO_DRAGDROP // Do not use OLE drag and drop
  42. # define GRIDCONTROL_NO_CLIPBOARD // Do not use clipboard routines
  43. # define GRIDCONTROL_NO_PRINTING // Do not use printing routines
  44. # ifdef WCE_NO_PRINTING
  45. # define _WIN32_WCE_NO_PRINTING
  46. # endif
  47. # ifdef WCE_NO_CURSOR
  48. # define _WIN32_WCE_NO_CURSOR
  49. # endif
  50. #endif // _WIN32_WCE
  51. // Use this as the classname when inserting this control as a custom control
  52. // in the MSVC++ dialog editor
  53. #define GRIDCTRL_CLASSNAME _T("MFCGridCtrl") // Window class name
  54. #define IDC_INPLACE_CONTROL 8 // ID of inplace edit controls
  55. ///////////////////////////////////////////////////////////////////////////////////
  56. // Conditional includes
  57. ///////////////////////////////////////////////////////////////////////////////////
  58. #ifndef GRIDCONTROL_NO_TITLETIPS
  59. # include "TitleTip.h"
  60. #endif
  61. #ifndef GRIDCONTROL_NO_DRAGDROP
  62. # include "GridDropTarget.h"
  63. # undef GRIDCONTROL_NO_CLIPBOARD // Force clipboard functions on
  64. #endif
  65. #ifndef GRIDCONTROL_NO_CLIPBOARD
  66. # include <afxole.h>
  67. #endif
  68. ///////////////////////////////////////////////////////////////////////////////////
  69. // Helper functions
  70. ///////////////////////////////////////////////////////////////////////////////////
  71. // Handy functions
  72. #define IsSHIFTpressed() ( (GetKeyState(VK_SHIFT) & (1 << (sizeof(SHORT)*8-1))) != 0 )
  73. #define IsCTRLpressed() ( (GetKeyState(VK_CONTROL) & (1 << (sizeof(SHORT)*8-1))) != 0 )
  74. // Backwards compatibility for pre 2.20 grid versions
  75. #define DDX_GridControl(pDX, nIDC, rControl) DDX_Control(pDX, nIDC, rControl)
  76. ///////////////////////////////////////////////////////////////////////////////////
  77. // Structures
  78. ///////////////////////////////////////////////////////////////////////////////////
  79. // This structure sent to Grid's parent in a WM_NOTIFY message
  80. typedef struct tagNM_GRIDVIEW {
  81. NMHDR hdr;
  82. int iRow;
  83. int iColumn;
  84. } NM_GRIDVIEW;
  85. // This is sent to the Grid from child in-place edit controls
  86. typedef struct tagGV_DISPINFO {
  87. NMHDR hdr;
  88. GV_ITEM item;
  89. } GV_DISPINFO;
  90. // This is sent to the Grid from child in-place edit controls
  91. typedef struct tagGV_CACHEHINT {
  92. NMHDR hdr;
  93. CCellRange range;
  94. } GV_CACHEHINT;
  95. // storage typedef for each row in the grid
  96. typedef CTypedPtrArray<CObArray, CGridCellBase*> GRID_ROW;
  97. // For virtual mode callback
  98. typedef BOOL(CALLBACK* GRIDCALLBACK)(GV_DISPINFO *, LPARAM);
  99. ///////////////////////////////////////////////////////////////////////////////////
  100. // Defines
  101. ///////////////////////////////////////////////////////////////////////////////////
  102. // Grid line/scrollbar selection
  103. #define GVL_NONE 0L // Neither
  104. #define GVL_HORZ 1L // Horizontal line or scrollbar
  105. #define GVL_VERT 2L // Vertical line or scrollbar
  106. #define GVL_BOTH 3L // Both
  107. // Autosizing option
  108. #define GVS_DEFAULT 0
  109. #define GVS_HEADER 1 // Size using column fixed cells data only
  110. #define GVS_DATA 2 // Size using column non-fixed cells data only
  111. #define GVS_BOTH 3 // Size using column fixed and non-fixed
  112. // Cell Searching options
  113. #define GVNI_FOCUSED 0x0001
  114. #define GVNI_SELECTED 0x0002
  115. #define GVNI_DROPHILITED 0x0004
  116. #define GVNI_READONLY 0x0008
  117. #define GVNI_FIXED 0x0010
  118. #define GVNI_MODIFIED 0x0020
  119. #define GVNI_ABOVE LVNI_ABOVE
  120. #define GVNI_BELOW LVNI_BELOW
  121. #define GVNI_TOLEFT LVNI_TOLEFT
  122. #define GVNI_TORIGHT LVNI_TORIGHT
  123. #define GVNI_ALL (LVNI_BELOW|LVNI_TORIGHT|LVNI_TOLEFT)
  124. #define GVNI_AREA (LVNI_BELOW|LVNI_TORIGHT)
  125. // Hit test values (not yet implemented)
  126. #define GVHT_DATA 0x0000
  127. #define GVHT_TOPLEFT 0x0001
  128. #define GVHT_COLHDR 0x0002
  129. #define GVHT_ROWHDR 0x0004
  130. #define GVHT_COLSIZER 0x0008
  131. #define GVHT_ROWSIZER 0x0010
  132. #define GVHT_LEFT 0x0020
  133. #define GVHT_RIGHT 0x0040
  134. #define GVHT_ABOVE 0x0080
  135. #define GVHT_BELOW 0x0100
  136. // Messages sent to the grid's parent (More will be added in future)
  137. #define GVN_BEGINDRAG LVN_BEGINDRAG // LVN_FIRST-9
  138. #define GVN_BEGINLABELEDIT LVN_BEGINLABELEDIT // LVN_FIRST-5
  139. #define GVN_BEGINRDRAG LVN_BEGINRDRAG
  140. #define GVN_COLUMNCLICK LVN_COLUMNCLICK
  141. #define GVN_DELETEITEM LVN_DELETEITEM
  142. #define GVN_ENDLABELEDIT LVN_ENDLABELEDIT // LVN_FIRST-6
  143. #define GVN_SELCHANGING LVN_ITEMCHANGING
  144. #define GVN_SELCHANGED LVN_ITEMCHANGED
  145. #define GVN_GETDISPINFO LVN_GETDISPINFO
  146. #define GVN_ODCACHEHINT LVN_ODCACHEHINT
  147. #ifdef STONU_DLL_EXPORTS
  148. #define STONU_DLL_API __declspec(dllexport)
  149. #else
  150. #define STONU_DLL_API __declspec(dllimport)
  151. #endif
  152. #define WM_DCLICK WM_USER + 100
  153. #define WM_CLICK WM_USER + 101
  154. class CGridCtrl;
  155. /////////////////////////////////////////////////////////////////////////////
  156. // CGridCtrl window
  157. class STONU_DLL_API CGridCtrl : public CWnd
  158. {
  159. DECLARE_DYNCREATE(CGridCtrl)
  160. friend class CGridCell;
  161. friend class CGridCellBase;
  162. // Construction
  163. public:
  164. CGridCtrl(int nRows = 0, int nCols = 0, int nFixedRows = 0, int nFixedCols = 0);
  165. BOOL Create(const RECT& rect, CWnd* parent, UINT nID,
  166. DWORD dwStyle = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE);
  167. public://chn add
  168. CUIntArray m_nArrayListChoose;
  169. int GetSelCount();
  170. int GetSelData(int iIndex);
  171. ///////////////////////////////////////////////////////////////////////////////////
  172. // Attributes
  173. ///////////////////////////////////////////////////////////////////////////////////
  174. public:
  175. int GetRowCount() const { return m_nRows; }
  176. int GetColumnCount() const { return m_nCols; }
  177. int GetFixedRowCount() const { return m_nFixedRows; }
  178. int GetFixedColumnCount() const { return m_nFixedCols; }
  179. BOOL SetRowCount(int nRows = 10);
  180. BOOL SetColumnCount(int nCols = 10);
  181. BOOL SetFixedRowCount(int nFixedRows = 1);
  182. BOOL SetFixedColumnCount(int nFixedCols = 1);
  183. int GetRowHeight(int nRow) const;
  184. BOOL SetRowHeight(int row, int height);
  185. int GetColumnWidth(int nCol) const;
  186. BOOL SetColumnWidth(int col, int width);
  187. BOOL GetCellOrigin(int nRow, int nCol, LPPOINT p);
  188. BOOL GetCellOrigin(const CCellID& cell, LPPOINT p);
  189. BOOL GetCellRect(int nRow, int nCol, LPRECT pRect);
  190. BOOL GetCellRect(const CCellID& cell, LPRECT pRect);
  191. BOOL GetTextRect(const CCellID& cell, LPRECT pRect);
  192. BOOL GetTextRect(int nRow, int nCol, LPRECT pRect);
  193. CCellID GetCellFromPt(CPoint point, BOOL bAllowFixedCellCheck = TRUE);
  194. int GetFixedRowHeight() const;
  195. int GetFixedColumnWidth() const;
  196. long GetVirtualWidth() const;
  197. long GetVirtualHeight() const;
  198. CSize GetTextExtent(int nRow, int nCol, LPCTSTR str);
  199. // EFW - Get extent of current text in cell
  200. inline CSize GetCellTextExtent(int nRow, int nCol) { return GetTextExtent(nRow, nCol, GetItemText(nRow, nCol)); }
  201. void SetGridBkColor(COLORREF clr) { m_crGridBkColour = clr; }
  202. COLORREF GetGridBkColor() const { return m_crGridBkColour; }
  203. void SetGridLineColor(COLORREF clr) { m_crGridLineColour = clr; }
  204. COLORREF GetGridLineColor() const { return m_crGridLineColour; }
  205. void SetTitleTipBackClr(COLORREF clr = CLR_DEFAULT) { m_crTTipBackClr = clr; }
  206. COLORREF GetTitleTipBackClr() { return m_crTTipBackClr; }
  207. void SetTitleTipTextClr(COLORREF clr = CLR_DEFAULT) { m_crTTipTextClr = clr; }
  208. COLORREF GetTitleTipTextClr() { return m_crTTipTextClr; }
  209. // ***************************************************************************** //
  210. // These have been deprecated. Use GetDefaultCell and then set the colors
  211. void SetTextColor(COLORREF clr) { m_cellDefault.SetTextClr(clr); }
  212. COLORREF GetTextColor() { return m_cellDefault.GetTextClr(); }
  213. void SetTextBkColor(COLORREF clr) { m_cellDefault.SetBackClr(clr); }
  214. COLORREF GetTextBkColor() { return m_cellDefault.GetBackClr(); }
  215. void SetFixedTextColor(COLORREF clr) {
  216. m_cellFixedRowDef.SetTextClr(clr);
  217. m_cellFixedColDef.SetTextClr(clr);
  218. m_cellFixedRowColDef.SetTextClr(clr);
  219. }
  220. COLORREF GetFixedTextColor() const { return m_cellFixedRowDef.GetTextClr(); }
  221. void SetFixedBkColor(COLORREF clr) {
  222. m_cellFixedRowDef.SetBackClr(clr);
  223. m_cellFixedColDef.SetBackClr(clr);
  224. m_cellFixedRowColDef.SetBackClr(clr);
  225. }
  226. COLORREF GetFixedBkColor() const { return m_cellFixedRowDef.GetBackClr(); }
  227. void SetGridColor(COLORREF clr) { SetGridLineColor(clr); }
  228. COLORREF GetGridColor() { return GetGridLineColor(); }
  229. void SetBkColor(COLORREF clr) { SetGridBkColor(clr); }
  230. COLORREF GetBkColor() { return GetGridBkColor(); }
  231. void SetDefCellMargin(int nMargin) {
  232. m_cellDefault.SetMargin(nMargin);
  233. m_cellFixedRowDef.SetMargin(nMargin);
  234. m_cellFixedColDef.SetMargin(nMargin);
  235. m_cellFixedRowColDef.SetMargin(nMargin);
  236. }
  237. int GetDefCellMargin() const { return m_cellDefault.GetMargin(); }
  238. int GetDefCellHeight() const { return m_cellDefault.GetHeight(); }
  239. void SetDefCellHeight(int nHeight) {
  240. m_cellDefault.SetHeight(nHeight);
  241. m_cellFixedRowDef.SetHeight(nHeight);
  242. m_cellFixedColDef.SetHeight(nHeight);
  243. m_cellFixedRowColDef.SetHeight(nHeight);
  244. }
  245. int GetDefCellWidth() const { return m_cellDefault.GetWidth(); }
  246. void SetDefCellWidth(int nWidth) {
  247. m_cellDefault.SetWidth(nWidth);
  248. m_cellFixedRowDef.SetWidth(nWidth);
  249. m_cellFixedColDef.SetWidth(nWidth);
  250. m_cellFixedRowColDef.SetWidth(nWidth);
  251. }
  252. // ***************************************************************************** //
  253. int GetSelectedCount() const { return (int)m_SelectedCellMap.GetCount(); }
  254. CCellID SetFocusCell(CCellID cell);
  255. CCellID SetFocusCell(int nRow, int nCol);
  256. CCellID GetFocusCell() const { return m_idCurrentCell; }
  257. void SetVirtualMode(BOOL bVirtual);
  258. BOOL GetVirtualMode() const { return m_bVirtualMode; }
  259. void SetCallbackFunc(GRIDCALLBACK pCallback,
  260. LPARAM lParam) {
  261. m_pfnCallback = pCallback; m_lParam = lParam;
  262. }
  263. GRIDCALLBACK GetCallbackFunc() { return m_pfnCallback; }
  264. void SetImageList(CImageList* pList) { m_pImageList = pList; }
  265. CImageList* GetImageList() const { return m_pImageList; }
  266. void SetGridLines(int nWhichLines = GVL_BOTH);
  267. int GetGridLines() const { return m_nGridLines; }
  268. void SetEditable(BOOL bEditable = TRUE) { m_bEditable = bEditable; }
  269. BOOL IsEditable() const { return m_bEditable; }
  270. void SetListMode(BOOL bEnableListMode = TRUE);
  271. BOOL GetListMode() const { return m_bListMode; }
  272. void SetSingleRowSelection(BOOL bSing = TRUE) { m_bSingleRowSelection = bSing; }
  273. BOOL GetSingleRowSelection() { return m_bSingleRowSelection & m_bListMode; }
  274. void SetSingleColSelection(BOOL bSing = TRUE) { m_bSingleColSelection = bSing; }
  275. BOOL GetSingleColSelection() { return m_bSingleColSelection; }
  276. void EnableSelection(BOOL bEnable = TRUE) { ResetSelectedRange(); m_bEnableSelection = bEnable; ResetSelectedRange(); }
  277. BOOL IsSelectable() const { return m_bEnableSelection; }
  278. void SetFixedColumnSelection(BOOL bSelect) { m_bFixedColumnSelection = bSelect; }
  279. BOOL GetFixedColumnSelection() { return m_bFixedColumnSelection; }
  280. void SetFixedRowSelection(BOOL bSelect) { m_bFixedRowSelection = bSelect; }
  281. BOOL GetFixedRowSelection() { return m_bFixedRowSelection; }
  282. void EnableDragAndDrop(BOOL bAllow = TRUE) { m_bAllowDragAndDrop = bAllow; }
  283. BOOL GetDragAndDrop() const { return m_bAllowDragAndDrop; }
  284. void SetRowResize(BOOL bResize = TRUE) { m_bAllowRowResize = bResize; }
  285. BOOL GetRowResize() const { return m_bAllowRowResize; }
  286. void SetColumnResize(BOOL bResize = TRUE) { m_bAllowColumnResize = bResize; }
  287. BOOL GetColumnResize() const { return m_bAllowColumnResize; }
  288. void SetHeaderSort(BOOL bSortOnClick = TRUE) { m_bSortOnClick = bSortOnClick; }
  289. BOOL GetHeaderSort() const { return m_bSortOnClick; }
  290. void SetHandleTabKey(BOOL bHandleTab = TRUE) { m_bHandleTabKey = bHandleTab; }
  291. BOOL GetHandleTabKey() const { return m_bHandleTabKey; }
  292. void SetDoubleBuffering(BOOL bBuffer = TRUE) { m_bDoubleBuffer = bBuffer; }
  293. BOOL GetDoubleBuffering() const { return m_bDoubleBuffer; }
  294. void EnableTitleTips(BOOL bEnable = TRUE) { m_bTitleTips = bEnable; }
  295. BOOL GetTitleTips() { return m_bTitleTips; }
  296. void SetSortColumn(int nCol);
  297. int GetSortColumn() const { return m_nSortColumn; }
  298. void SetSortAscending(BOOL bAscending) { m_bAscending = bAscending; }
  299. BOOL GetSortAscending() const { return m_bAscending; }
  300. void SetTrackFocusCell(BOOL bTrack) { m_bTrackFocusCell = bTrack; }
  301. BOOL GetTrackFocusCell() { return m_bTrackFocusCell; }
  302. void SetFrameFocusCell(BOOL bFrame) { m_bFrameFocus = bFrame; }
  303. BOOL GetFrameFocusCell() { return m_bFrameFocus; }
  304. void SetAutoSizeStyle(int nStyle = GVS_BOTH) { m_nAutoSizeColumnStyle = nStyle; }
  305. int GetAutoSizeStyle() { return m_nAutoSizeColumnStyle; }
  306. void EnableHiddenColUnhide(BOOL bEnable = TRUE){ m_bHiddenColUnhide = bEnable; }
  307. BOOL GetHiddenColUnhide() { return m_bHiddenColUnhide; }
  308. void EnableHiddenRowUnhide(BOOL bEnable = TRUE){ m_bHiddenRowUnhide = bEnable; }
  309. BOOL GetHiddenRowUnhide() { return m_bHiddenRowUnhide; }
  310. void EnableColumnHide(BOOL bEnable = TRUE) { m_bAllowColHide = bEnable; }
  311. BOOL GetColumnHide() { return m_bAllowColHide; }
  312. void EnableRowHide(BOOL bEnable = TRUE) { m_bAllowRowHide = bEnable; }
  313. BOOL GetRowHide() { return m_bAllowRowHide; }
  314. ///////////////////////////////////////////////////////////////////////////////////
  315. // default Grid cells. Use these for setting default values such as colors and fonts
  316. ///////////////////////////////////////////////////////////////////////////////////
  317. public:
  318. CGridCellBase* GetDefaultCell(BOOL bFixedRow, BOOL bFixedCol) const;
  319. ///////////////////////////////////////////////////////////////////////////////////
  320. // Grid cell Attributes
  321. ///////////////////////////////////////////////////////////////////////////////////
  322. public:
  323. CGridCellBase* GetCell(int nRow, int nCol) const; // Get the actual cell!
  324. void SetModified(BOOL bModified = TRUE, int nRow = -1, int nCol = -1);
  325. BOOL GetModified(int nRow = -1, int nCol = -1);
  326. BOOL IsCellFixed(int nRow, int nCol);
  327. BOOL SetItem(const GV_ITEM* pItem);
  328. BOOL GetItem(GV_ITEM* pItem);
  329. BOOL SetItemText(int nRow, int nCol, LPCTSTR str);
  330. // The following was virtual. If you want to override, use
  331. // CGridCellBase-derived class's GetText() to accomplish same thing
  332. CString GetItemText(int nRow, int nCol) const;
  333. // EFW - 06/13/99 - Added to support printf-style formatting codes.
  334. // Also supports use with a string resource ID
  335. #if !defined(_WIN32_WCE) || (_WIN32_WCE >= 210)
  336. BOOL SetItemTextFmt(int nRow, int nCol, LPCTSTR szFmt, ...);
  337. BOOL SetItemTextFmtID(int nRow, int nCol, UINT nID, ...);
  338. #endif
  339. BOOL SetItemData(int nRow, int nCol, LPARAM lParam);
  340. LPARAM GetItemData(int nRow, int nCol) const;
  341. BOOL SetItemImage(int nRow, int nCol, int iImage);
  342. int GetItemImage(int nRow, int nCol) const;
  343. BOOL SetItemState(int nRow, int nCol, UINT state);
  344. UINT GetItemState(int nRow, int nCol) const;
  345. BOOL SetItemFormat(int nRow, int nCol, UINT nFormat);
  346. UINT GetItemFormat(int nRow, int nCol) const;
  347. BOOL SetItemBkColour(int nRow, int nCol, COLORREF cr = CLR_DEFAULT);
  348. COLORREF GetItemBkColour(int nRow, int nCol) const;
  349. BOOL SetItemFgColour(int nRow, int nCol, COLORREF cr = CLR_DEFAULT);
  350. COLORREF GetItemFgColour(int nRow, int nCol) const;
  351. BOOL SetItemFont(int nRow, int nCol, const LOGFONT* lf);
  352. const LOGFONT* GetItemFont(int nRow, int nCol);
  353. BOOL IsItemEditing(int nRow, int nCol);
  354. BOOL SetCellType(int nRow, int nCol, CRuntimeClass* pRuntimeClass);
  355. BOOL SetDefaultCellType(CRuntimeClass* pRuntimeClass);
  356. ///////////////////////////////////////////////////////////////////////////////////
  357. // Operations
  358. ///////////////////////////////////////////////////////////////////////////////////
  359. public:
  360. int InsertColumn(LPCTSTR strHeading, UINT nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE,
  361. int nColumn = -1);
  362. int InsertRow(LPCTSTR strHeading, int nRow = -1);
  363. BOOL DeleteColumn(int nColumn);
  364. BOOL DeleteRow(int nRow);
  365. BOOL DeleteNonFixedRows();
  366. BOOL DeleteAllItems();
  367. void ClearCells(CCellRange Selection);
  368. BOOL AutoSizeRow(int nRow, BOOL bResetScroll = TRUE);
  369. BOOL AutoSizeColumn(int nCol, UINT nAutoSizeStyle = GVS_DEFAULT, BOOL bResetScroll = TRUE);
  370. void AutoSizeRows();
  371. void AutoSizeColumns(UINT nAutoSizeStyle = GVS_DEFAULT);
  372. void AutoSize(UINT nAutoSizeStyle = GVS_DEFAULT);
  373. void ExpandColumnsToFit(BOOL bExpandFixed = TRUE);
  374. void ExpandLastColumn();
  375. void ExpandRowsToFit(BOOL bExpandFixed = TRUE);
  376. void ExpandToFit(BOOL bExpandFixed = TRUE);
  377. void Refresh();
  378. void AutoFill(); // Fill grid with blank cells
  379. void EnsureVisible(CCellID &cell) { EnsureVisible(cell.row, cell.col); }
  380. void EnsureVisible(int nRow, int nCol);
  381. BOOL IsCellVisible(int nRow, int nCol);
  382. BOOL IsCellVisible(CCellID cell);
  383. BOOL IsCellEditable(int nRow, int nCol) const;
  384. BOOL IsCellEditable(CCellID &cell) const;
  385. BOOL IsCellSelected(int nRow, int nCol) const;
  386. BOOL IsCellSelected(CCellID &cell) const;
  387. // SetRedraw stops/starts redraws on things like changing the # rows/columns
  388. // and autosizing, but not for user-intervention such as resizes
  389. void SetRedraw(BOOL bAllowDraw, BOOL bResetScrollBars = FALSE);
  390. BOOL RedrawCell(int nRow, int nCol, CDC* pDC = NULL);
  391. BOOL RedrawCell(const CCellID& cell, CDC* pDC = NULL);
  392. BOOL RedrawRow(int row);
  393. BOOL RedrawColumn(int col);
  394. #ifndef _WIN32_WCE
  395. BOOL Save(LPCTSTR filename, TCHAR chSeparator = _T(','));
  396. BOOL Load(LPCTSTR filename, TCHAR chSeparator = _T(','));
  397. #endif
  398. ///////////////////////////////////////////////////////////////////////////////////
  399. // Cell Ranges
  400. ///////////////////////////////////////////////////////////////////////////////////
  401. public:
  402. CCellRange GetCellRange() const;
  403. CCellRange GetSelectedCellRange() const;
  404. void SetSelectedRange(const CCellRange& Range, BOOL bForceRepaint = FALSE, BOOL bSelectCells = TRUE);
  405. void SetSelectedRange(int nMinRow, int nMinCol, int nMaxRow, int nMaxCol,
  406. BOOL bForceRepaint = FALSE, BOOL bSelectCells = TRUE);
  407. BOOL IsValid(int nRow, int nCol) const;
  408. BOOL IsValid(const CCellID& cell) const;
  409. BOOL IsValid(const CCellRange& range) const;
  410. ///////////////////////////////////////////////////////////////////////////////////
  411. // Clipboard, drag and drop, and cut n' paste operations
  412. ///////////////////////////////////////////////////////////////////////////////////
  413. #ifndef GRIDCONTROL_NO_CLIPBOARD
  414. virtual void CutSelectedText();
  415. virtual COleDataSource* CopyTextFromGrid();
  416. virtual BOOL PasteTextToGrid(CCellID cell, COleDataObject* pDataObject);
  417. #endif
  418. #ifndef GRIDCONTROL_NO_DRAGDROP
  419. public:
  420. virtual void OnBeginDrag();
  421. virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  422. virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point);
  423. virtual void OnDragLeave();
  424. virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
  425. #endif
  426. #ifndef GRIDCONTROL_NO_CLIPBOARD
  427. virtual void OnEditCut();
  428. virtual void OnEditCopy();
  429. virtual void OnEditPaste();
  430. #endif
  431. virtual void OnEditSelectAll();
  432. ///////////////////////////////////////////////////////////////////////////////////
  433. // Misc.
  434. ///////////////////////////////////////////////////////////////////////////////////
  435. public:
  436. CCellID GetNextItem(CCellID& cell, int nFlags) const;
  437. BOOL SortItems(int nCol, BOOL bAscending, LPARAM data = 0);
  438. BOOL SortTextItems(int nCol, BOOL bAscending, LPARAM data = 0);
  439. BOOL SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data = 0);
  440. void SetCompareFunction(PFNLVCOMPARE pfnCompare);
  441. // in-built sort functions
  442. static int CALLBACK pfnCellTextCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  443. static int CALLBACK pfnCellNumericCompare(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  444. ///////////////////////////////////////////////////////////////////////////////////
  445. // Printing
  446. ///////////////////////////////////////////////////////////////////////////////////
  447. #if !defined(_WIN32_WCE_NO_PRINTING) && !defined(GRIDCONTROL_NO_PRINTING)
  448. public:
  449. void Print(CPrintDialog* pPrntDialog = NULL);
  450. // EFW - New printing support functions
  451. void EnableWysiwygPrinting(BOOL bEnable = TRUE) { m_bWysiwygPrinting = bEnable; }
  452. BOOL GetWysiwygPrinting() { return m_bWysiwygPrinting; }
  453. void SetShadedPrintOut(BOOL bEnable = TRUE) { m_bShadedPrintOut = bEnable; }
  454. BOOL GetShadedPrintOut(void) { return m_bShadedPrintOut; }
  455. // Use -1 to have it keep the existing value
  456. void SetPrintMarginInfo(int nHeaderHeight, int nFooterHeight,
  457. int nLeftMargin, int nRightMargin, int nTopMargin,
  458. int nBottomMargin, int nGap);
  459. void GetPrintMarginInfo(int &nHeaderHeight, int &nFooterHeight,
  460. int &nLeftMargin, int &nRightMargin, int &nTopMargin,
  461. int &nBottomMargin, int &nGap);
  462. ///////////////////////////////////////////////////////////////////////////////////
  463. // Printing overrides for derived classes
  464. ///////////////////////////////////////////////////////////////////////////////////
  465. public:
  466. virtual void OnBeginPrinting(CDC *pDC, CPrintInfo *pInfo);
  467. virtual void OnPrint(CDC *pDC, CPrintInfo *pInfo);
  468. virtual void OnEndPrinting(CDC *pDC, CPrintInfo *pInfo);
  469. #endif // #if !defined(_WIN32_WCE_NO_PRINTING) && !defined(GRIDCONTROL_NO_PRINTING)
  470. // Implementation
  471. public:
  472. virtual ~CGridCtrl();
  473. BOOL RegisterWindowClass(HINSTANCE hInstance = NULL);
  474. protected:
  475. BOOL Initialise();
  476. void SetupDefaultCells();
  477. LRESULT SendMessageToParent(int nRow, int nCol, int nMessage) const;
  478. LRESULT SendDisplayRequestToParent(GV_DISPINFO* pDisplayInfo) const;
  479. LRESULT SendCacheHintToParent(const CCellRange& range) const;
  480. BOOL InvalidateCellRect(const int row, const int col);
  481. BOOL InvalidateCellRect(const CCellID& cell);
  482. BOOL InvalidateCellRect(const CCellRange& cellRange);
  483. void EraseBkgnd(CDC* pDC);
  484. BOOL GetCellRangeRect(const CCellRange& cellRange, LPRECT lpRect);
  485. BOOL SetCell(int nRow, int nCol, CGridCellBase* pCell);
  486. int SetMouseMode(int nMode) { int nOldMode = m_MouseMode; m_MouseMode = nMode; return nOldMode; }
  487. int GetMouseMode() const { return m_MouseMode; }
  488. BOOL MouseOverRowResizeArea(CPoint& point);
  489. BOOL MouseOverColumnResizeArea(CPoint& point);
  490. CCellID GetTopleftNonFixedCell(BOOL bForceRecalculation = FALSE);
  491. CCellRange GetUnobstructedNonFixedCellRange(BOOL bForceRecalculation = FALSE);
  492. CCellRange GetVisibleNonFixedCellRange(LPRECT pRect = NULL, BOOL bForceRecalculation = FALSE);
  493. BOOL IsVisibleVScroll() { return ((m_nBarState & GVL_VERT) > 0); }
  494. BOOL IsVisibleHScroll() { return ((m_nBarState & GVL_HORZ) > 0); }
  495. void ResetSelectedRange();
  496. void ResetScrollBars();
  497. void EnableScrollBars(int nBar, BOOL bEnable = TRUE);
  498. int GetScrollPos32(int nBar, BOOL bGetTrackPos = FALSE);
  499. BOOL SetScrollPos32(int nBar, int nPos, BOOL bRedraw = TRUE);
  500. BOOL SortTextItems(int nCol, BOOL bAscending, int low, int high);
  501. BOOL SortItems(PFNLVCOMPARE pfnCompare, int nCol, BOOL bAscending, LPARAM data,
  502. int low, int high);
  503. CPoint GetPointClicked(int nRow, int nCol, const CPoint& point);
  504. void ValidateAndModifyCellContents(int nRow, int nCol, LPCTSTR strText);
  505. // Overrrides
  506. // ClassWizard generated virtual function overrides
  507. //{{AFX_VIRTUAL(CGridCtrl)
  508. protected:
  509. virtual void PreSubclassWindow();
  510. //}}AFX_VIRTUAL
  511. protected:
  512. #if !defined(_WIN32_WCE_NO_PRINTING) && !defined(GRIDCONTROL_NO_PRINTING)
  513. // Printing
  514. virtual void PrintFixedRowCells(int nStartColumn, int nStopColumn, int& row, CRect& rect,
  515. CDC *pDC, BOOL& bFirst);
  516. virtual void PrintColumnHeadings(CDC *pDC, CPrintInfo *pInfo);
  517. virtual void PrintHeader(CDC *pDC, CPrintInfo *pInfo);
  518. virtual void PrintFooter(CDC *pDC, CPrintInfo *pInfo);
  519. virtual void PrintRowButtons(CDC *pDC, CPrintInfo* /*pInfo*/);
  520. #endif
  521. #ifndef GRIDCONTROL_NO_DRAGDROP
  522. // Drag n' drop
  523. virtual CImageList* CreateDragImage(CPoint *pHotSpot); // no longer necessary
  524. #endif
  525. // Mouse Clicks
  526. virtual void OnFixedColumnClick(CCellID& cell);
  527. virtual void OnFixedRowClick(CCellID& cell);
  528. // Editing
  529. virtual void OnEditCell(int nRow, int nCol, CPoint point, UINT nChar);
  530. virtual void OnEndEditCell(int nRow, int nCol, CString str);
  531. virtual BOOL ValidateEdit(int nRow, int nCol, LPCTSTR str);
  532. virtual void EndEditing();
  533. // Drawing
  534. virtual void OnDraw(CDC* pDC);
  535. // CGridCellBase Creation and Cleanup
  536. virtual CGridCellBase* CreateCell(int nRow, int nCol);
  537. virtual void DestroyCell(int nRow, int nCol);
  538. // Attributes
  539. protected:
  540. // General attributes
  541. COLORREF m_crFixedTextColour, m_crFixedBkColour;
  542. COLORREF m_crGridBkColour, m_crGridLineColour;
  543. COLORREF m_crWindowText, m_crWindowColour, m_cr3DFace, // System colours
  544. m_crShadow;
  545. COLORREF m_crTTipBackClr, m_crTTipTextClr; // Titletip colours - FNA
  546. BOOL m_bVirtualMode;
  547. LPARAM m_lParam; // lParam for callback
  548. GRIDCALLBACK m_pfnCallback; // The callback function
  549. int m_nGridLines;
  550. BOOL m_bEditable;
  551. BOOL m_bModified;
  552. BOOL m_bAllowDragAndDrop;
  553. BOOL m_bListMode;
  554. BOOL m_bSingleRowSelection;
  555. BOOL m_bSingleColSelection;
  556. BOOL m_bAllowDraw;
  557. BOOL m_bEnableSelection;
  558. BOOL m_bFixedRowSelection, m_bFixedColumnSelection;
  559. BOOL m_bSortOnClick;
  560. BOOL m_bHandleTabKey;
  561. BOOL m_bDoubleBuffer;
  562. BOOL m_bTitleTips;
  563. int m_nBarState;
  564. BOOL m_bWysiwygPrinting;
  565. BOOL m_bHiddenColUnhide, m_bHiddenRowUnhide;
  566. BOOL m_bAllowColHide, m_bAllowRowHide;
  567. BOOL m_bAutoSizeSkipColHdr;
  568. BOOL m_bTrackFocusCell;
  569. BOOL m_bFrameFocus;
  570. UINT m_nAutoSizeColumnStyle;
  571. // Cell size details
  572. int m_nRows, m_nFixedRows, m_nCols, m_nFixedCols;
  573. CUIntArray m_arRowHeights, m_arColWidths;
  574. int m_nVScrollMax, m_nHScrollMax;
  575. // Fonts and images
  576. CRuntimeClass* m_pRtcDefault; // determines kind of Grid Cell created by default
  577. CGridDefaultCell m_cellDefault; // "default" cell. Contains default colours, font etc.
  578. CGridDefaultCell m_cellFixedColDef, m_cellFixedRowDef, m_cellFixedRowColDef;
  579. CFont m_PrinterFont; // for the printer
  580. CImageList* m_pImageList;
  581. // Cell data
  582. CTypedPtrArray<CObArray, GRID_ROW*> m_RowData;
  583. // Mouse operations such as cell selection
  584. int m_MouseMode;
  585. BOOL m_bLMouseButtonDown, m_bRMouseButtonDown;
  586. CPoint m_LeftClickDownPoint, m_LastMousePoint;
  587. CCellID m_LeftClickDownCell, m_SelectionStartCell;
  588. CCellID m_idCurrentCell, m_idTopLeftCell;
  589. int m_nTimerID;
  590. int m_nTimerInterval;
  591. int m_nResizeCaptureRange;
  592. BOOL m_bAllowRowResize, m_bAllowColumnResize;
  593. int m_nRowsPerWheelNotch;
  594. CMap<DWORD, DWORD, CCellID, CCellID&> m_SelectedCellMap, m_PrevSelectedCellMap;
  595. #ifndef GRIDCONTROL_NO_TITLETIPS
  596. CTitleTip m_TitleTip; // Title tips for cells
  597. #endif
  598. // Drag and drop
  599. CCellID m_LastDragOverCell;
  600. #ifndef GRIDCONTROL_NO_DRAGDROP
  601. CGridDropTarget m_DropTarget; // OLE Drop target for the grid
  602. #endif
  603. // Printing information
  604. CSize m_CharSize;
  605. int m_nPageHeight;
  606. CSize m_LogicalPageSize, // Page size in gridctrl units.
  607. m_PaperSize; // Page size in device units.
  608. // additional properties to support Wysiwyg printing
  609. int m_nPageWidth;
  610. int m_nPrintColumn;
  611. int m_nCurrPrintRow;
  612. int m_nNumPages;
  613. int m_nPageMultiplier;
  614. // sorting
  615. int m_bAscending;
  616. int m_nSortColumn;
  617. PFNLVCOMPARE m_pfnCompare;
  618. // EFW - Added to support shaded/unshaded printout. If true, colored
  619. // cells will print as-is. If false, all text prints as black on white.
  620. BOOL m_bShadedPrintOut;
  621. // EFW - Added support for user-definable margins. Top and bottom are in
  622. // lines. Left, right, and gap are in characters (avg width is used).
  623. int m_nHeaderHeight, m_nFooterHeight, m_nLeftMargin,
  624. m_nRightMargin, m_nTopMargin, m_nBottomMargin, m_nGap;
  625. protected:
  626. void SelectAllCells();
  627. void SelectColumns(CCellID currentCell, BOOL bForceRedraw = FALSE, BOOL bSelectCells = TRUE);
  628. void SelectRows(CCellID currentCell, BOOL bForceRedraw = FALSE, BOOL bSelectCells = TRUE);
  629. void SelectCells(CCellID currentCell, BOOL bForceRedraw = FALSE, BOOL bSelectCells = TRUE);
  630. void OnSelecting(const CCellID& currentCell);
  631. // Generated message map functions
  632. //{{AFX_MSG(CGridCtrl)
  633. afx_msg void OnPaint();
  634. afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  635. afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
  636. afx_msg void OnSize(UINT nType, int cx, int cy);
  637. afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
  638. afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
  639. afx_msg void OnMouseMove(UINT nFlags, CPoint point);
  640. afx_msg void OnTimer(UINT nIDEvent);
  641. afx_msg UINT OnGetDlgCode();
  642. afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  643. afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  644. afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  645. afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
  646. afx_msg BOOL OnEraseBkgnd(CDC* pDC);
  647. afx_msg void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  648. afx_msg void OnUpdateEditSelectAll(CCmdUI* pCmdUI);
  649. //}}AFX_MSG
  650. #ifndef _WIN32_WCE_NO_CURSOR
  651. afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
  652. #endif
  653. #ifndef _WIN32_WCE
  654. afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
  655. afx_msg void OnRButtonUp(UINT nFlags, CPoint point); // EFW - Added
  656. afx_msg void OnSysColorChange();
  657. #endif
  658. #ifndef _WIN32_WCE_NO_CURSOR
  659. afx_msg void OnCaptureChanged(CWnd *pWnd);
  660. #endif
  661. #ifndef GRIDCONTROL_NO_CLIPBOARD
  662. afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
  663. afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
  664. afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
  665. #endif
  666. #if (_MFC_VER >= 0x0421) || (_WIN32_WCE >= 210)
  667. afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
  668. #endif
  669. #if !defined(_WIN32_WCE) && (_MFC_VER >= 0x0421)
  670. afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
  671. #endif
  672. afx_msg LRESULT OnSetFont(WPARAM hFont, LPARAM lParam);
  673. afx_msg LRESULT OnGetFont(WPARAM hFont, LPARAM lParam);
  674. afx_msg LRESULT OnImeChar(WPARAM wCharCode, LPARAM lParam);
  675. afx_msg void OnEndInPlaceEdit(NMHDR* pNMHDR, LRESULT* pResult);
  676. DECLARE_MESSAGE_MAP()
  677. enum eMouseModes {
  678. MOUSE_NOTHING, MOUSE_SELECT_ALL, MOUSE_SELECT_COL, MOUSE_SELECT_ROW,
  679. MOUSE_SELECT_CELLS, MOUSE_SCROLLING_CELLS,
  680. MOUSE_OVER_ROW_DIVIDE, MOUSE_SIZING_ROW,
  681. MOUSE_OVER_COL_DIVIDE, MOUSE_SIZING_COL,
  682. MOUSE_PREPARE_EDIT,
  683. #ifndef GRIDCONTROL_NO_DRAGDROP
  684. MOUSE_PREPARE_DRAG, MOUSE_DRAGGING
  685. #endif
  686. };
  687. };
  688. // Returns the default cell implementation for the given grid region
  689. inline CGridCellBase* CGridCtrl::GetDefaultCell(BOOL bFixedRow, BOOL bFixedCol) const
  690. {
  691. if (bFixedRow && bFixedCol) return (CGridCellBase*)&m_cellFixedRowColDef;
  692. if (bFixedRow) return (CGridCellBase*)&m_cellFixedRowDef;
  693. if (bFixedCol) return (CGridCellBase*)&m_cellFixedColDef;
  694. return (CGridCellBase*)&m_cellDefault;
  695. }
  696. inline CGridCellBase* CGridCtrl::GetCell(int nRow, int nCol) const
  697. {
  698. if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols)
  699. return NULL;
  700. if (GetVirtualMode())
  701. {
  702. CGridCellBase* pCell = GetDefaultCell(nRow < m_nFixedRows, nCol < m_nFixedCols);
  703. static GV_DISPINFO gvdi;
  704. gvdi.item.row = nRow;
  705. gvdi.item.col = nCol;
  706. gvdi.item.mask = 0xFFFFFFFF;
  707. gvdi.item.nState = 0;
  708. gvdi.item.nFormat = pCell->GetFormat();
  709. gvdi.item.iImage = pCell->GetImage();
  710. gvdi.item.crBkClr = pCell->GetBackClr();
  711. gvdi.item.crFgClr = pCell->GetTextClr();
  712. gvdi.item.lParam = pCell->GetData();
  713. memcpy(&gvdi.item.lfFont, pCell->GetFont(), sizeof(LOGFONT));
  714. gvdi.item.nMargin = pCell->GetMargin();
  715. gvdi.item.strText.Empty();
  716. // Fix the state bits
  717. if (IsCellSelected(nRow, nCol)) gvdi.item.nState |= GVIS_SELECTED;
  718. if (nRow < GetFixedRowCount()) gvdi.item.nState |= (GVIS_FIXED | GVIS_FIXEDROW);
  719. if (nCol < GetFixedColumnCount()) gvdi.item.nState |= (GVIS_FIXED | GVIS_FIXEDCOL);
  720. if (GetFocusCell() == CCellID(nRow, nCol)) gvdi.item.nState |= GVIS_FOCUSED;
  721. if (m_pfnCallback)
  722. m_pfnCallback(&gvdi, m_lParam);
  723. else
  724. SendDisplayRequestToParent(&gvdi);
  725. static CGridCell cell;
  726. cell.SetState(gvdi.item.nState);
  727. cell.SetFormat(gvdi.item.nFormat);
  728. cell.SetImage(gvdi.item.iImage);
  729. cell.SetBackClr(gvdi.item.crBkClr);
  730. cell.SetTextClr(gvdi.item.crFgClr);
  731. cell.SetData(gvdi.item.lParam);
  732. cell.SetFont(&(gvdi.item.lfFont));
  733. cell.SetMargin(gvdi.item.nMargin);
  734. cell.SetText(gvdi.item.strText);
  735. cell.SetGrid((CGridCtrl*)this);
  736. return (CGridCellBase*)&cell;
  737. }
  738. GRID_ROW* pRow = m_RowData[nRow];
  739. if (!pRow) return NULL;
  740. return pRow->GetAt(nCol);
  741. }
  742. inline BOOL CGridCtrl::SetCell(int nRow, int nCol, CGridCellBase* pCell)
  743. {
  744. if (GetVirtualMode())
  745. return FALSE;
  746. if (nRow < 0 || nRow >= m_nRows || nCol < 0 || nCol >= m_nCols)
  747. return FALSE;
  748. GRID_ROW* pRow = m_RowData[nRow];
  749. if (!pRow) return FALSE;
  750. pCell->SetCoords(nRow, nCol);
  751. pRow->SetAt(nCol, pCell);
  752. return TRUE;
  753. }
  754. /////////////////////////////////////////////////////////////////////////////
  755. //{{AFX_INSERT_LOCATION}}
  756. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  757. #endif // !defined(AFX_GRIDCTRL_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_)