Click here to Skip to main content
15,917,565 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Can't display column if the width is over 32767 in CListCtrl Pin
neil.kuo28-Nov-05 20:10
neil.kuo28-Nov-05 20:10 
GeneralRe: Can't display column if the width is over 32767 in CListCtrl Pin
Gavin Taylor28-Nov-05 20:22
professionalGavin Taylor28-Nov-05 20:22 
QuestionDrag & Drop Pin
Aqueel28-Nov-05 17:29
Aqueel28-Nov-05 17:29 
AnswerRe: Drag & Drop Pin
Rajesh R Subramanian28-Nov-05 20:08
professionalRajesh R Subramanian28-Nov-05 20:08 
QuestionGraphics Pin
sthalasayanam28-Nov-05 16:18
sthalasayanam28-Nov-05 16:18 
AnswerRe: Graphics Pin
Christian Graus28-Nov-05 17:02
protectorChristian Graus28-Nov-05 17:02 
QuestionHow to load some icons from a file into a listcontrol? Pin
zhonglin.liang28-Nov-05 15:59
zhonglin.liang28-Nov-05 15:59 
AnswerRe: How to load some icons from a file into a listcontrol? Pin
Gavin Taylor28-Nov-05 18:57
professionalGavin Taylor28-Nov-05 18:57 
If we're talking about the common control version of List Control (CListCtrl in MFC) it's pretty easy.

The list control just uses an imagelist object to retrieve it's images from, all you need to do is create an CImageList object and bind it to the list control, then all you've got to do is specify the index for the image you want a listitem to have.

You'll need to add something like CImageList m_imageList; into your class definition for the parent window, then in your initialisation routine (OnInitDialog or whatever) you'll need something like:

CListCtrl pListCtrl = NULL;<br />
CWinApp * pApp = NULL;<br />
<br />
pApp = AfxGetApp( );<br />
if( pApp == NULL ) { _ASSERT( FALSE ); return FALSE; }<br />
<br />
pListCtrl = ( CListCtrl * ) GetDlgItem( IDL_LIST );<br />
if( pListCtrl == NULL ) { _ASSERT( FALSE ); return FALSE; }<br />
<br />
if( m_imageList.Create(32, 32, ILC_COLOR8, 0, 4) )<br />
   pList->SetImageList( & m_pImageList, LVSIL_NORMAL);<br />


finally, when adding your items into the list control, you'll need something like:
<br />
HICON hIcon = NULL;<br />
int idxIcon = 0;<br />
<br />
hIcon = pApp->LoadIcon( MAKEINTRESOURCE( IDI_INDEXFORICON ) );<br />
idxIcon = m_imageList.Add( hIcon );<br />
pList->InsertItem( 0, TEXT( "items description" ), idxIcon );<br />


I think the code is correct (the theory is at least) as i dont have a copy of Visual Studio to hand to try it and notepad ain't quite the same Smile | :)


Gavin Taylor
w: http://www.gavintaylor.co.uk

GeneralRe: How to load some icons from a file into a listcontrol? Pin
zhonglin.liang28-Nov-05 19:30
zhonglin.liang28-Nov-05 19:30 
GeneralRe: How to load some icons from a file into a listcontrol? Pin
Gavin Taylor28-Nov-05 19:46
professionalGavin Taylor28-Nov-05 19:46 
GeneralRe: How to load some icons from a file into a listcontrol? Pin
zhonglin.liang28-Nov-05 20:18
zhonglin.liang28-Nov-05 20:18 
GeneralRe: How to load some icons from a file into a listcontrol? Pin
Gavin Taylor28-Nov-05 20:24
professionalGavin Taylor28-Nov-05 20:24 
GeneralRe: How to load some icons from a file into a listcontrol? Pin
zhonglin.liang28-Nov-05 21:05
zhonglin.liang28-Nov-05 21:05 
GeneralRe: How to load some icons from a file into a listcontrol? Pin
Gavin Taylor28-Nov-05 22:00
professionalGavin Taylor28-Nov-05 22:00 
QuestionMFC Program looking for a good tool for a log box. Pin
King Link28-Nov-05 15:15
King Link28-Nov-05 15:15 
AnswerRe: MFC Program looking for a good tool for a log box. Pin
Christian Graus28-Nov-05 15:34
protectorChristian Graus28-Nov-05 15:34 
GeneralRe: MFC Program looking for a good tool for a log box. Pin
S Douglas28-Nov-05 19:06
professionalS Douglas28-Nov-05 19:06 
QuestionMultiple language support using static lib Pin
Harshabhi28-Nov-05 14:15
Harshabhi28-Nov-05 14:15 
AnswerRe: Multiple language support using static lib Pin
Gavin Taylor28-Nov-05 19:15
professionalGavin Taylor28-Nov-05 19:15 
Questionno operator found which takes a right-hand operand of type 'char' Pin
Lord Kixdemp28-Nov-05 14:02
Lord Kixdemp28-Nov-05 14:02 
AnswerRe: no operator found which takes a right-hand operand of type 'char' Pin
PJ Arends28-Nov-05 14:28
professionalPJ Arends28-Nov-05 14:28 
GeneralRe: no operator found which takes a right-hand operand of type 'char' Pin
Lord Kixdemp28-Nov-05 14:41
Lord Kixdemp28-Nov-05 14:41 
QuestionConverting PDF's to TIFF's Pin
bitznarf28-Nov-05 12:02
bitznarf28-Nov-05 12:02 
Questionproject graph analys Pin
senatort77728-Nov-05 11:00
senatort77728-Nov-05 11:00 
AnswerRe: project graph analys Pin
kakan28-Nov-05 19:08
professionalkakan28-Nov-05 19:08 

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.