Sample of use grid in dialog
windows.
There are two ways of creation of a grid window in dialog
window.
1. To create the user control (Custom Control). To enter into a field "Class"
a name of your class (a parental class should be CALXGridCtrl). But before initialization of dialog windows this class should be registered.
For example:
CRegGridDLG::CRegGridDLG(CWnd* pParent /*=NULL*/)
: CDialog(CRegGridDLG::IDD, pParent)
{
if (!CRegGridCtrl::RegisterClass())
{
TRACE0("Failed to register grid
control\n");
return;
}
//{{AFX_DATA_INIT(CRegGridDLG)
// NOTE: the ClassWizard will add member
initialization here
//}}AFX_DATA_INIT
}
CRegGridDLG::~CRegGridDLG()
{
CRegGridCtrl::UnregisterClass();
}
( in a heading file should be declared macros DECLARE_REGISTER,
and in cpp macros IMPLEMENT_REGISTER)
2. It is possible also used function Create (), which
itself will register your class.
int CCrGridDLG::OnCreate(LPCREATESTRUCT
lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) ==
-1)
return -1;
if (!m_GridCtrl.Create( WS_EX_STATICEDGE,
WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | AGS_FLAT,
CRect(7,7,410,220),
this,
0))
{
TRACE0("Failed to create list
box\n");
return -1;
}
return 0;
}
|