代码功能描述: 运用tab控件切换页面,子页面里用listcontrol 显示数据。
问题: 子页面添加listcontrol后,编译运行可以; 给listcontrol添加变量m_list之后(为了编排list格式,写入数据等),编译通过,运行出错。
百度各种方法,并为找到具体方法。 调用堆栈查看错误,不太会,问题脑壳疼。
部分代码如下:
子窗口cpp:
void CSection1::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SC1_LIST, m_section1_list);
}
BOOL CSection1::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
BOOL CSection1::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
m_section1_list.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
m_section1_list.InsertColumn(1,_T("学号"),LVCFMT_CENTER,100);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
} m_section1_list.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
m_section1_list.InsertColumn(1,_T("学号"),LVCFMT_CENTER,100);
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
子窗口.h :
public:
virtual BOOL OnInitDialog();
CListCtrl m_section1_list;
/////////////////////////////////////////////
debug指向:
HWND CDataExchange::PrepareCtrl(int nIDC)
{
ASSERT(nIDC != 0);
ASSERT(nIDC != -1); // not allowed
HWND hWndCtrl;
COleControlSite* pSite = NULL;
m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl);
if (hWndCtrl == NULL)
{
// Could be a windowless OCX
pSite = m_pDlgWnd->GetOleControlSite(nIDC);
if (pSite == NULL)
{
TRACE(traceAppMsg, 0, "Error: no data exchange control with ID 0x%04X.\n", nIDC);
ASSERT(FALSE);// 调用堆栈光标显示 在这里
AfxThrowNotSupportedException();
}
}
m_idLastControl = nIDC;
m_bEditLastControl = FALSE; // not an edit item by default
return hWndCtrl;
}
void CSection1::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SC1_LIST, m_section1_list);
}///////调用堆栈 光标显示 在这里