利用构造函数给定义的控件对象被始化:
其中class CMyList : public CListCtrl我想在CMyList类的构造函数中加一些代码,使一个CMyList对象一创建,就:
InsertColumn(0,"编号")
试验失败.后来我又修改了这个:
BOOL CMyList::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
{
// TODO: 在此添加专用代码和/或调用基类
this->InsertColumn(0,"编号");
this->SetColumnWidth(0,50);
return CListCtrl::Create(dwStyle, rect, pParentWnd, nID);
}
还是失败!再后来:LRESULT CMyList::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: 在此添加专用代码和/或调用基类
if(message==WM_CREATE)
{
this->InsertColumn(0,"编号");
this->SetColumnWidth(0,50);
this->InsertColumn(1,"编号");
this->SetColumnWidth(1,50);
} return CListCtrl::WindowProc(message, wParam, lParam);
}
仍然是失败.我觉得应该可以改的啊,是我的理解有问题还是改不了?