16,472
社区成员
发帖
与我相关
我的任务
分享
BEGIN_MESSAGE_MAP(CTestctrlView, CView)
//{{AFX_MSG_MAP(CTestctrlView)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_COMMAND(UM_CREATELISTVIEW, CTestctrlView::OnCreateListView)
END_MESSAGE_MAP()
LRESULT CTestctrlView::OnCreateListView(WPARAM wParam, LPARAM lParam)
{
CRect rect;
this->GetClientRect(rect);
if(listCtrl.Create(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_EX_GRIDLINES,rect,this,0))
{
listCtrl.InsertColumn(0,_T("column 1"));
listCtrl.InsertColumn(1,_T("column 2"));
listCtrl.InsertColumn(2,_T("column 3"));
listCtrl.InsertItem(0,"aaa");
}
return 0;
}
#define UM_CREATELISTVIEW WM_USER+0x11
void CTestctrlView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
// 发送自定义消息
PostMessage(UM_CREATELISTVIEW, 0, 0);
}
// 自定义消息响应函数
LRESULT CTestctrlView::OnCreateListView(WPARAM wParam, LPARAM lParam)
{
CRect rect;
GetClientRect(rect);
if(listCtrl.Create(WS_CHILD|WS_VISIBLE|LVS_REPORT|LVS_EX_GRIDLINES,rect,this,0))
{
listCtrl.InsertColumn(0,_T("column 1"));
listCtrl.InsertColumn(1,_T("column 2"));
listCtrl.InsertColumn(2,_T("column 3"));
listCtrl.InsertItem(0,"aaa");
}
return 0;
}