Problem with inserting images as items in CListCtrl
I want to insert images in ListCtrl throgh resource editor.
In OnCREATE of CDialog Derived class ......
Here is the code .Tell me where I am going wrong
CImageList *m_pImageList;
m_pImageList = new CImageList();
m_myListCtrl.InsertColumn(0,TEXT("aaaa"));
m_myListCtrl.InsertColumn(1,TEXT("bbbb"));
m_myCtrl.InsertColumn(2,TEXT("cccc"));
m_myListCtrl.SetColumnWidth(0, 100);
m_myListCtrl.SetColumnWidth(1, 100);
m_myListCtrl.SetColumnWidth(2, 100);
ASSERT(m_pImageList != NULL); // serious allocation failure checking
m_pImageList->Create(32, 32, TRUE, 4, 4);
m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_ICON1));
m_pImageList->Add(AfxGetApp()->LoadIcon(IDI_ICON2));
m_myListCtrl.SetImageList(m_pImageList, LVSIL_SMALL);
I get assertion problem at creation of m_pmyLISTctRL;
I am not able to figure it out
afxcmn.inl line no194
{ ASSERT(::IsWindow(m_hWnd)); return (int) ::SendMessage(m_hWnd,
LVM_INSERTCOLUMN, nCol, (LPARAM)pColumn); }
Re: Problem with inserting images as items in CListCtrl
I added this code in oninitdialog then it started working ,but images
are missing ,
can some one help me here.
thanks
Re: Problem with inserting images as items in CListCtrl
OnCreate is not going to be called for a dialog. Use OnInitDialog
instead. You can create/initialize the imagelist in Dialog's
constructor if you want.
---
Ajay
Re: Problem with inserting images as items in CListCtrl
I added the code inOnInitDilaog so no assertion but images are
invisible.
:-(
Re: Problem with inserting images as items in CListCtrl
I created the list control with view set to small icon .
Is that I am missing basics ?
Re: Problem with inserting images as items in CListCtrl
Yes - you need to:
1. create & populate a CIMageList object
2. call CListCtrl::setImageList(...) with the initialized object
3. use image index when calling CListCtrl::InsertItem
<bhargavi_ks2001@yahoo.com> wrote in message
news:1148497152.520689.59110@g10g2000cwb.googlegroups.com...[color=blue]
>I created the list control with view set to small icon .
> Is that I am missing basics ?
>[/color]