mfc的InsertItem为什么执行不了?
CListCtrl *pLC1;
CImageList* m_pImgList;
// CFormView2 消息处理程序
UINT loadbmpthd(LPVOID argv1) ////在mainfrm.cpp中启动该函数线程。
{
if(pLC1==NULL)
return 0;
CBitmap* pImage = NULL;
pImage = new CBitmap();
int i=0;
int bmap=IDB_BITMAP3;
HBITMAP bitm;
char str[200];
CFileFind finder;
CString sName;
CString sName1;
BOOL bk = finder.FindFile("c:\\adpicture\\*.bmp");
while(bk)
{
bk = finder.FindNextFile();
sName = finder.GetFileName();
//AfxMessageBox(sName);
sName1="c:\\adpicture\\"+sName;
bitm=(HBITMAP)LoadImage( NULL,sName1 , IMAGE_BITMAP, 176, 120,
LR_CREATEDIBSECTION | LR_DEFAULTSIZE | LR_LOADFROMFILE);
pImage->Attach(bitm);
//pImage->LoadBitmapA();
int imgP=m_pImgList->Add(pImage,RGB(125,125,0));
pLC1->InsertItem(imgP,sName);//为什么跑到这里程序崩溃?InsertItem为什么执行不了?
pImage->DeleteObject();
}
return 0;
}
void CFormView2::OnInitialUpdate(void)
{
pLC1 = (CListCtrl *)GetDlgItem(IDC_LIST2);
m_pImgList=new CImageList;
m_pImgList->Create (176,120,ILC_COLOR32,20,20);//前两个参数是设置图象大小的
m_pImgList->SetBkColor(RGB(125,125,0));
pLC1->SetImageList(m_pImgList,0);//LVS_SMALLICON LVSIL_NORMAL
}