KaoQin.exe 中的 0x0041700c 处未处理的异常: 0xC0000005: 读取位置 0xcccccccc 时发生访问冲突
我想初始化listbox的标题但是怎么都出来,,现在提示那个异常错误,,求大侠帮帮忙// WH.cpp : 实现文件
//
#include "stdafx.h"
#include "KaoQin.h"
#include "WH.h"
// WH 对话框
IMPLEMENT_DYNAMIC(WH, CDialog)
WH::WH(CWnd* pParent /*=NULL*/)
: CDialog(WH::IDD, pParent)
{
}
WH::~WH()
{
}
void WH::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_List1);
}
BEGIN_MESSAGE_MAP(WH, CDialog)
ON_BN_CLICKED(IDOK, &WH::OnBnClickedOk)
END_MESSAGE_MAP()
// WH 消息处理程序
BOOL WH::OnInitDialog()
{
CDialog::OnInitDialog();
const char *list[]={
"卡号","学号","姓名","性别","班级"};
int i = 0;
while(*list[i]!=0x00)
{
m_List1.InsertColumn(i,list[i++],LVCFMT_LEFT,100);
}
CListCtrl *p=(CListCtrl*)GetDlgItem(IDC_LIST1);
DWORD d=GetWindowLong(p->m_hWnd,GWL_STYLE);
SetWindowLong(p->m_hWnd,GWL_STYLE,d|LVS_REPORT);
DWORD styles = p->GetExtendedStyle();
p->SetExtendedStyle(styles | LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
// TODO: 在此添加额外的初始化
/*
m_List1.SetExtendedStyle(
LVS_EX_FLATSB
|LVS_EX_FULLROWSELECT
|LVS_EX_HEADERDRAGDROP
|LVS_EX_ONECLICKACTIVATE
);
m_List1.InsertColumn(0,"卡号",LVCFMT_LEFT,10,0);
m_List1.InsertColumn(1,"学号",LVCFMT_LEFT,10,1);
m_List1.InsertColumn(2,"姓名",LVCFMT_LEFT,10,2);
m_List1.InsertColumn(3,"性别",LVCFMT_LEFT,10,3);
m_List1.InsertColumn(4,"班级",LVCFMT_LEFT,10,4);
*/
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void WH::OnBnClickedOk()
{
// TODO: 在此添加控件通知处理程序代码
OnOK();
}