利用构造函数给定义的控件对象被始化:
其中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);
}
仍然是失败.我觉得应该可以改的啊,是我的理解有问题还是改不了?
其中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);
}
仍然是失败.我觉得应该可以改的啊,是我的理解有问题还是改不了?
解决方案 »
- 幼稚点问题
- 在vc中如何调用excel数据画二维图形?excel中有两列数据,分别为横坐标,纵坐标的值
- 为什么GetWindowText和GetDlgItemText不起作用
- 请教dos下调用MFC程序如何实现dos下输出?
- SetupDiGetClassDevs()使用的问题,在线等
- 曾经看过一个VC写的软件,可以把冰河挂在其他的程序,只要这个程序一运行,冰河也就运行了.这个软件叫什么,那里可以下? 还有 ,谁知道那里有
- ******求VC++6.0辅助工具,100分送大家!!!!!!******
- vs2012 已停止工作
- Dll的调用为什么会出错?
- 如何判断停车位上是否有车
- 用如下代码为何不能显示图象,请大虾们指教。
- 高手帮忙呀,编译ndis程序出错
this->SetColumnWidth(0,50);
return CListCtrl::Create(dwStyle, rect, pParentWnd, nID); // 应该 先 调基类 的 Create 还没创建你就 insert 肯定不行也可以考虑 装饰,而不 继承