Google Answers Logo
View Question
 
Q: [Question] How can I Insert Image to CListCtrl at second column? ( No Answer,   1 Comment )
Question  
Subject: [Question] How can I Insert Image to CListCtrl at second column?
Category: Computers > Programming
Asked by: hareum-ga
List Price: $5.00
Posted: 07 Jun 2004 01:07 PDT
Expires: 08 Jun 2004 03:15 PDT
Question ID: 357482
Hello!
I have trouble in using CListCtrl. I can?t Insert the Image Item at
second or another column.
I set this ListCtrl 'Report' Type. At Report type, only first column
display the item. At second column, the image didn't displayed,
however I inser the image item.
I can?t know the reason. I?ll show you the source code.

BOOL CTmpTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	m_SkinList.InsertColumn(1, "???", LVCFMT_LEFT, 50);
	m_SkinList.InsertColumn(2, "?????", LVCFMT_LEFT, 100);
	ListView_SetExtendedListViewStyle(m_SkinList.m_hWnd,
LVS_EX_FULLROWSELECT | LVS_EX_HEADERDRAGDROP);

	m_oLargeImage.Create(32, 32, ILC_COLOR4,  3, 3);
	m_oSmallImage.Create(16, 16, ILC_COLOR4,  3, 3);
	CBitmap cBit;
	cBit.LoadBitmap(IDB_BITMAP1);
	m_oLargeImage.Add(&cBit, RGB(255,255,255));
	cBit.DeleteObject();
	cBit.LoadBitmap(IDB_BITMAP2);
	m_oSmallImage.Add(&cBit, RGB(255,255,255));
	cBit.DeleteObject();

	m_SkinList.SetImageList(&m_oLargeImage, LVSIL_NORMAL);
	m_SkinList.SetImageList(&m_oSmallImage, LVSIL_SMALL);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CTmpTestDlg::OnButton1() 
{
	int nCount=m_SkinList.GetItemCount();

	m_SkinList.SetRedraw(FALSE);

	CString* pstr = new CString;
	pstr->Format("1?");
	LPCTSTR psz = *pstr;	
	m_SkinList.InsertItem(LVIF_IMAGE, nCount, 0, 0, 0, 0, 0);	
	m_SkinList.SetItem(nCount, 1, LVIF_IMAGE|LVIF_PARAM|LVIF_TEXT, psz, 0, 
		0, 0, reinterpret_cast<LPARAM>(pstr));
	delete pstr;

	m_SkinList.SetRedraw(TRUE);		
}
Answer  
There is no answer at this time.

Comments  
Subject: Re: [Question] How can I Insert Image to CListCtrl at second column?
From: natem-ga on 07 Jun 2004 12:07 PDT
 
According to Microsoft's own Developer documentation only the first
column my have icons/images while the second to end columns my have
text, tooltips, and tags.

In order to simulate actual icons/images in other than the first
column you'll have to write a wrapper class that handles the drawing
of the control.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy