应该是, 这是这个类的头文件说明:// MFC Grid Control header file // // Written by Chris Maunder ([email protected]) // Copyright (c) 1998. // // The code contained in this file is based on the original // WorldCom Grid control written by Joe Willcoxson, // E-mail: [email protected] // URL: http://users.aol.com/chinajoe但是这个类的GFV_ITEM结构中 没有GVIF_BKCLR声明和crBkClr成员???怎么回事?如下: typedef struct _GV_ITEM { int row,col; // Row and Column of item UINT mask; // Mask for use in getting/setting cell data UINT state; // cell state (focus/hilighted etc) UINT nFormat; // Format of cell CString szText; // Text in cell int iImage; // index of the list view item抯 icon LPARAM lParam; // 32-bit value to associate with item } GV_ITEM;
#if !defined(AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_) #define AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_#if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000class CGridCtrl;// Cell states #define GVIS_FOCUSED 0x0001 #define GVIS_SELECTED 0x0002 #define GVIS_DROPHILITED 0x0004 #define GVIS_READONLY 0x0008 #define GVIS_FIXED 0x0010 #define GVIS_FIXEDROW 0x0020 #define GVIS_FIXEDCOL 0x0040 #define GVIS_MODIFIED 0x0080// Cell data mask #define GVIF_TEXT LVIF_TEXT #define GVIF_IMAGE LVIF_IMAGE #define GVIF_PARAM LVIF_PARAM #define GVIF_STATE LVIF_STATE #define GVIF_BKCLR (GVIF_STATE<<1) #define GVIF_FGCLR (GVIF_STATE<<2) #define GVIF_FORMAT (GVIF_STATE<<3) #define GVIF_FONT (GVIF_STATE<<4) #define GVIF_MARGIN (GVIF_STATE<<5) #define GVIF_ALL (GVIF_TEXT|GVIF_IMAGE|GVIF_PARAM|GVIF_STATE|GVIF_BKCLR|GVIF_FGCLR| \ GVIF_FORMAT|GVIF_FONT|GVIF_MARGIN)// Used for Get/SetItem calls. typedef struct _GV_ITEM { int row,col; // Row and Column of item UINT mask; // Mask for use in getting/setting cell data UINT nState; // cell state (focus/hilighted etc) DWORD nFormat; // Format of cell int iImage; // index of the list view item痴 icon COLORREF crBkClr; // Background colour (or CLR_DEFAULT) COLORREF crFgClr; // Forground colour (or CLR_DEFAULT) LPARAM lParam; // 32-bit value to associate with item LOGFONT lfFont; // Cell font UINT nMargin; // Internal cell margin CString strText; // Text in cell } GV_ITEM; ........ 定义在GridCellBase.h中
因为这个结构的声明GV_ITEM在CGridCtrl类中就有。相关的只有下面的这些类(结构)#include "CellRange.h" //#include "GridDropTarget.h" #include <afxtempl.h> // Use this as the classname when inserting this control as a custom control // in the MSVC++ dialog editor #define GRIDCTRL_CLASSNAME _T("MFCGridCtrl")#define IsSHIFTpressed() ( (GetKeyState(VK_SHIFT) & (1 << (sizeof(SHORT)*8-1))) != 0 ) #define IsCTRLpressed() ( (GetKeyState(VK_CONTROL) & (1 << (sizeof(SHORT)*8-1))) != 0 )// Used for Get/SetItem calls. typedef struct _GV_ITEM { int row,col; // Row and Column of item UINT mask; // Mask for use in getting/setting cell data UINT state; // cell state (focus/hilighted etc) UINT nFormat; // Format of cell CString szText; // Text in cell int iImage; // index of the list view item抯 icon LPARAM lParam; // 32-bit value to associate with item } GV_ITEM; // Grid line selection #define GVL_NONE 0 #define GVL_HORZ 1 #define GVL_VERT 2 #define GVL_BOTH 3// Cell data mask #define GVIF_TEXT LVIF_TEXT #define GVIF_IMAGE LVIF_IMAGE #define GVIF_PARAM LVIF_PARAM #define GVIF_STATE LVIF_STATE #define GVIF_FORMAT (GVIF_STATE<<1)// Cell states #define GVIS_FOCUSED LVIS_FOCUSED #define GVIS_SELECTED LVIS_SELECTED #define GVIS_DROPHILITED LVIS_DROPHILITED// Cell Searching options #define GVNI_FOCUSED LVNI_FOCUSED #define GVNI_SELECTED LVNI_SELECTED #define GVNI_DROPHILITED LVNI_DROPHILITED#define GVNI_ABOVE LVNI_ABOVE #define GVNI_BELOW LVNI_BELOW #define GVNI_TOLEFT LVNI_TOLEFT #define GVNI_TORIGHT LVNI_TORIGHT// Hit test values (not yet implemented) #define GVHT_DATA 0x0000 #define GVHT_TOPLEFT 0x0001 #define GVHT_COLHDR 0x0002 #define GVHT_ROWHDR 0x0004 #define GVHT_COLSIZER 0x0008 #define GVHT_ROWSIZER 0x0010 #define GVHT_LEFT 0x0020 #define GVHT_RIGHT 0x0040 #define GVHT_ABOVE 0x0080 #define GVHT_BELOW 0x0100// Edit Types #define GVET_NOEDIT 0x0000 // Edit Not Allowed #define GVET_EDITBOX 0x0001 // InPlace EditBox #define GVET_LISTBOX 0x0002 // InPlace ListBox #define GVET_COMBOBOX 0x0004 // InPlace ComboBox #define GVET_CHECKBOX 0x0008 // InPlace CheckBox // Each cell contains one of these. Fields "row" and "column" are not stored since we // will usually have acces to them in other ways, and they are an extra 8 bytes per // cell that is probably unnecessary. class CGridCell : public CObject { public: CGridCell():state(0),nFormat(0),szText(),iImage(-1),lParam(0) {}; UINT state; // Cell state (selected/focus etc) UINT nFormat; // Cell format CString szText; // Cell text (or binary data if you wish...) int iImage; // Index of the list view item抯 icon LPARAM lParam; // 32-bit value to associate with item };
Item.row = nRow;//行
Item.col = nCol;//列
Item.mask |= GVIF_BKCLR;//背景色 GVIF_FGCLR(前景色)
Item.crBkClr = GetSysColor( COLOR_3DFACE );//自已定
m_Grid.SetItem( &Item );
这是这个类的头文件说明:// MFC Grid Control header file
//
// Written by Chris Maunder ([email protected])
// Copyright (c) 1998.
//
// The code contained in this file is based on the original
// WorldCom Grid control written by Joe Willcoxson,
// E-mail: [email protected]
// URL: http://users.aol.com/chinajoe但是这个类的GFV_ITEM结构中 没有GVIF_BKCLR声明和crBkClr成员???怎么回事?如下:
typedef struct _GV_ITEM
{
int row,col; // Row and Column of item
UINT mask; // Mask for use in getting/setting cell data
UINT state; // cell state (focus/hilighted etc)
UINT nFormat; // Format of cell
CString szText; // Text in cell
int iImage; // index of the list view item抯 icon
LPARAM lParam; // 32-bit value to associate with item
} GV_ITEM;
#define AFX_GRIDCELLBASE_H__519FA702_722C_11D1_ABBA_00A0243D1382__INCLUDED_#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000class CGridCtrl;// Cell states
#define GVIS_FOCUSED 0x0001
#define GVIS_SELECTED 0x0002
#define GVIS_DROPHILITED 0x0004
#define GVIS_READONLY 0x0008
#define GVIS_FIXED 0x0010
#define GVIS_FIXEDROW 0x0020
#define GVIS_FIXEDCOL 0x0040
#define GVIS_MODIFIED 0x0080// Cell data mask
#define GVIF_TEXT LVIF_TEXT
#define GVIF_IMAGE LVIF_IMAGE
#define GVIF_PARAM LVIF_PARAM
#define GVIF_STATE LVIF_STATE
#define GVIF_BKCLR (GVIF_STATE<<1)
#define GVIF_FGCLR (GVIF_STATE<<2)
#define GVIF_FORMAT (GVIF_STATE<<3)
#define GVIF_FONT (GVIF_STATE<<4)
#define GVIF_MARGIN (GVIF_STATE<<5)
#define GVIF_ALL (GVIF_TEXT|GVIF_IMAGE|GVIF_PARAM|GVIF_STATE|GVIF_BKCLR|GVIF_FGCLR| \
GVIF_FORMAT|GVIF_FONT|GVIF_MARGIN)// Used for Get/SetItem calls.
typedef struct _GV_ITEM {
int row,col; // Row and Column of item
UINT mask; // Mask for use in getting/setting cell data
UINT nState; // cell state (focus/hilighted etc)
DWORD nFormat; // Format of cell
int iImage; // index of the list view item痴 icon
COLORREF crBkClr; // Background colour (or CLR_DEFAULT)
COLORREF crFgClr; // Forground colour (or CLR_DEFAULT)
LPARAM lParam; // 32-bit value to associate with item
LOGFONT lfFont; // Cell font
UINT nMargin; // Internal cell margin
CString strText; // Text in cell
} GV_ITEM;
........
定义在GridCellBase.h中
//#include "GridDropTarget.h"
#include <afxtempl.h>
// Use this as the classname when inserting this control as a custom control
// in the MSVC++ dialog editor
#define GRIDCTRL_CLASSNAME _T("MFCGridCtrl")#define IsSHIFTpressed() ( (GetKeyState(VK_SHIFT) & (1 << (sizeof(SHORT)*8-1))) != 0 )
#define IsCTRLpressed() ( (GetKeyState(VK_CONTROL) & (1 << (sizeof(SHORT)*8-1))) != 0 )// Used for Get/SetItem calls.
typedef struct _GV_ITEM
{
int row,col; // Row and Column of item
UINT mask; // Mask for use in getting/setting cell data
UINT state; // cell state (focus/hilighted etc)
UINT nFormat; // Format of cell
CString szText; // Text in cell
int iImage; // index of the list view item抯 icon
LPARAM lParam; // 32-bit value to associate with item
} GV_ITEM; // Grid line selection
#define GVL_NONE 0
#define GVL_HORZ 1
#define GVL_VERT 2
#define GVL_BOTH 3// Cell data mask
#define GVIF_TEXT LVIF_TEXT
#define GVIF_IMAGE LVIF_IMAGE
#define GVIF_PARAM LVIF_PARAM
#define GVIF_STATE LVIF_STATE
#define GVIF_FORMAT (GVIF_STATE<<1)// Cell states
#define GVIS_FOCUSED LVIS_FOCUSED
#define GVIS_SELECTED LVIS_SELECTED
#define GVIS_DROPHILITED LVIS_DROPHILITED// Cell Searching options
#define GVNI_FOCUSED LVNI_FOCUSED
#define GVNI_SELECTED LVNI_SELECTED
#define GVNI_DROPHILITED LVNI_DROPHILITED#define GVNI_ABOVE LVNI_ABOVE
#define GVNI_BELOW LVNI_BELOW
#define GVNI_TOLEFT LVNI_TOLEFT
#define GVNI_TORIGHT LVNI_TORIGHT// Hit test values (not yet implemented)
#define GVHT_DATA 0x0000
#define GVHT_TOPLEFT 0x0001
#define GVHT_COLHDR 0x0002
#define GVHT_ROWHDR 0x0004
#define GVHT_COLSIZER 0x0008
#define GVHT_ROWSIZER 0x0010
#define GVHT_LEFT 0x0020
#define GVHT_RIGHT 0x0040
#define GVHT_ABOVE 0x0080
#define GVHT_BELOW 0x0100// Edit Types
#define GVET_NOEDIT 0x0000 // Edit Not Allowed
#define GVET_EDITBOX 0x0001 // InPlace EditBox
#define GVET_LISTBOX 0x0002 // InPlace ListBox
#define GVET_COMBOBOX 0x0004 // InPlace ComboBox
#define GVET_CHECKBOX 0x0008 // InPlace CheckBox
// Each cell contains one of these. Fields "row" and "column" are not stored since we
// will usually have acces to them in other ways, and they are an extra 8 bytes per
// cell that is probably unnecessary.
class CGridCell : public CObject
{
public:
CGridCell():state(0),nFormat(0),szText(),iImage(-1),lParam(0) {}; UINT state; // Cell state (selected/focus etc)
UINT nFormat; // Cell format
CString szText; // Cell text (or binary data if you wish...)
int iImage; // Index of the list view item抯 icon
LPARAM lParam; // 32-bit value to associate with item
};