Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: background image for toolbar base on dialog Pin
yiyinkuang18-May-09 23:28
yiyinkuang18-May-09 23:28 
GeneralRe: background image for toolbar base on dialog Pin
_AnsHUMAN_ 19-May-09 0:33
_AnsHUMAN_ 19-May-09 0:33 
GeneralRe: background image for toolbar base on dialog Pin
yiyinkuang19-May-09 15:22
yiyinkuang19-May-09 15:22 
Questioncontrolling system volume by vc++ Pin
B060611518-May-09 22:11
B060611518-May-09 22:11 
AnswerRe: controlling system volume by vc++ Pin
Chandrasekharan P18-May-09 22:36
Chandrasekharan P18-May-09 22:36 
QuestionRe: controlling system volume by vc++ Pin
David Crow19-May-09 5:01
David Crow19-May-09 5:01 
AnswerRe: controlling system volume by vc++ Pin
B060611519-May-09 23:46
B060611519-May-09 23:46 
QuestionCreating a column with bitmaps on CListCtrl residing on a dialog Pin
JJeffrey18-May-09 21:37
JJeffrey18-May-09 21:37 
Sorry to trouble you guys, but I think I'm missing something in my understanding of the List Control boxes.

I'm creating a CListCtrl box with 3 columns. The first 2 are text and the third will show bitmaps. My code goes like this:

void PopulateList ()
{
	LVCOLUMN lvColumn1,lvColumn2,lvColumn3;					
	COLORREF rgbMask = RGB(0,0,0);	//(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue);
        // I believe I need to create a CImageList for the bitmap column, right?
	CImageList	ThumbList;
	ThumbList.Create(MAXWIDTH, MAXHEIGHT, ILC_COLOR, 1, 1);


	//Create Column 1
	lvColumn1.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvColumn1.fmt = Alignment;
	lvColumn1.cx = 120;
	lvColumn1.pszText = ColumnHeading[0];
	nCol = m_MainList.InsertColumn(0, &lvColumn1);

	int NextIndex = nCol;

	//Populate Column 1
	while (!EOF)
        {
          //Read the Data from File and store in "OutputTitle"
          .
          .
          LVITEM lvItem;
	  lvItem.mask = LVIF_TEXT;
	  lvItem.iItem = NextIndex;
	  lvItem.iSubItem = 0;
	  lvItem.pszText = OutputTitle;
	  NextIndex = m_MainList.InsertItem(&lvItem);
          .
        }
	ListView_SortItemsEx( m_MainList.m_hWnd, CompareProc, (LPARAM)&m_MainList );

	//Create Column 2
	lvColumn2.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvColumn2.fmt = Alignment;
	lvColumn2.cx = 120;
	lvColumn2.pszText = ColumnHeading[1];
	nCol = m_MainList.InsertColumn(1, &lvColumn2);

	//Populate Column 2
	int NumOfEntries = m_MainList.GetItemCount();
	
	for(int i=0; i>NumOfEntries; i++)
	{
           //Get data based on First Column entries
           .
           .
           .
	   m_MainList.SetItemText(i,1, <Data>);
	}

	//Create Column 3
	lvColumn3.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	lvColumn3.fmt = Alignment;
	lvColumn3.cx = 240;
	lvColumn3.pszText = ColumnHeading[2];
	nCol = m_MainList.InsertColumn(2, &lvColumn3);
	

	NextIndex = nCol;

	//Populate Column 3
	BYTE PreviewInfo[MAXHEIGHT][MAXWIDTH][3]={0};
	int ImageIndex = 0;
	
	for(int i=0; i<NumOfEntries; i++)
	{
		BOOL ValidPicture = ReadDataFromDataFile(.....);

		if(ValidPicture)
		{
			HBITMAP Picture = <Data Read>
			CBitmap	*ThumbNail = new CBitmap;
			ThumbNail->Attach(Picture );
			ImageIndex = ThumbList.Add(ThumbNail,rgbMask);
			m_MainList.SetImageList(&ThumbList, LVSIL_SMALL);

			LVITEM lvItem;
			lvItem.mask = LVIF_IMAGE;
			lvItem.iItem = i;              // I tried
			lvItem.iSubItem = 0;
			lvItem.iImage = ImageIndex;
			NextIndex = m_MainList.InsertItem(&lvItem);	
			delete ThumbNail;		
		}
		else NextIndex++;
	}
	

}


m_MainList is the handle to the CListCtrl on the dialog


If I don't code in the Column 3 code, I get my first 2 columns ok. Once I do put in the Column 3 code, Column 1 data all disappears and Column 3 also has no data.
I believe the problem is in my declaration of the CImageList and how I am putting it into the Column, but I don't know what is wrong and also why Column 1 is being affected.

Can someone point me in the right direction here?
AnswerRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
Stuart Dootson18-May-09 22:49
professionalStuart Dootson18-May-09 22:49 
GeneralRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
JJeffrey18-May-09 23:21
JJeffrey18-May-09 23:21 
GeneralRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
Stuart Dootson19-May-09 0:34
professionalStuart Dootson19-May-09 0:34 
GeneralRe: Creating a column with bitmaps on CListCtrl residing on a dialog Pin
JJeffrey19-May-09 23:26
JJeffrey19-May-09 23:26 
QuestionPure win32 cross-process child windows Pin
megaadam18-May-09 21:36
professionalmegaadam18-May-09 21:36 
Answer[Message Deleted] Pin
Perisic, Aleksandar18-May-09 23:59
Perisic, Aleksandar18-May-09 23:59 
General[Message Deleted] Pin
megaadam19-May-09 1:01
professionalmegaadam19-May-09 1:01 
General[Message Deleted] Pin
Perisic, Aleksandar19-May-09 1:42
Perisic, Aleksandar19-May-09 1:42 
QuestionClosing an MDI child window having a worker thread in execution Pin
CString(0xcccccccc)18-May-09 21:29
CString(0xcccccccc)18-May-09 21:29 
AnswerRe: Closing an MDI child window having a worker thread in execution Pin
Stuart Dootson18-May-09 22:57
professionalStuart Dootson18-May-09 22:57 
QuestionCheck file is open or not Pin
Davitor18-May-09 20:50
Davitor18-May-09 20:50 
AnswerRe: Check file is open or not Pin
Naveen18-May-09 22:06
Naveen18-May-09 22:06 
AnswerRe: Check file is open or not Pin
Stuart Dootson18-May-09 22:44
professionalStuart Dootson18-May-09 22:44 
AnswerRe: Check file is open or not Pin
Divyang Mithaiwala19-May-09 1:00
Divyang Mithaiwala19-May-09 1:00 
GeneralRe: Check file is open or not Pin
_Flaviu4-Oct-11 23:39
_Flaviu4-Oct-11 23:39 
Questionusing container class for c++ class objects Pin
hawk23reddy18-May-09 20:27
hawk23reddy18-May-09 20:27 
AnswerRe: using container class for c++ class objects Pin
CPallini18-May-09 21:26
mveCPallini18-May-09 21:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.