添加【Static text】控件
(1)#include "MyCug.h"
#include "ugctrl.h"
class MyCug : public CUGCtrl
{
public:
MyCug();
~MyCug();
DECLARE_MESSAGE_MAP()
virtual void OnSetup();
};
(2)#include "MyCug.cpp"
#include "stdafx.h"
#include "resource.h"
#include "MyCug.h"
BEGIN_MESSAGE_MAP(MyCug,CUGCtrl)
END_MESSAGE_MAP()
MyCug::MyCug()
}
MyCug::~MyCug()
UGXPThemes::CleanUp();
void MyCug::OnSetup()
int rows = 4;
int cols = 4;
CUGCell cell;
SetNumberRows(rows);
SetNumberCols(cols);
SetCurrentCellMode(2);
SetTH_Height(60);
GetCell(0, -1, &cell);
int nCol = 0;
int nHeader = -1;
cell.SetText(L"序号");
SetCell(nCol, nHeader, &cell);
nCol++;
cell.SetText(L"编码");
cell.SetText(L"名称");
cell.SetText(L"年龄");
AdjustComponentSizes();
在主对话框中:
MyCug m_ctrl;
BOOL CSimpleDemoDlg::OnInitDialog()
CDialogEx::OnInitDialog();
m_ctrl.AttachGrid(this, IDC_GRID);
return TRUE;
效果图如下: