添加【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;
效果圖如下: