Afficher des icones dans une ListCtrl

Afficher des icones dans une ListCtrl - C++ - Programmation

Marsh Posté le 30-03-2003 à 19:11:49    

Code :
  1. //On initialise la liste
  2. m_liste.DeleteAllItems();
  3. m_liste.InsertColumn(0, "Col 1", LVCFMT_LEFT, 100, 0);
  4. m_liste.InsertColumn(1, "Col 2", LVCFMT_LEFT, 100, 0);
  5. m_liste.InsertColumn(2, "Col 3", LVCFMT_LEFT, 100, 0);
  6. m_liste.InsertItem(0,"Contenu col 1-1", IDI_ROUGE);
  7. m_liste.InsertItem(1,"Contenu col 1-2" );
  8. m_liste.InsertItem(2,"Contenu col 1-3" );


 
IDI_ROUGE est une icone, et la je comprend pas parce que ca l'affiche pas...

Reply

Marsh Posté le 30-03-2003 à 19:11:49   

Reply

Marsh Posté le 30-03-2003 à 19:27:23    

Quel formt ta list ? icon smallicon list ou report ?

Reply

Marsh Posté le 30-03-2003 à 19:29:23    

As tu placé tes icones dans une CImageList ?


---------------
J'ai un string dans l'array (Paris Hilton)
Reply

Marsh Posté le 30-03-2003 à 19:30:27    

Enfin a priori tu utilises  

Code :
  1. int InsertItem( int nItem, LPCTSTR lpszItem, int nImage )


 
mais nImage c pas une ressource que ca prend mais l index de l iamge qui est stocke ds l'ImageList associé au CListCtrl.

Reply

Marsh Posté le 30-03-2003 à 21:44:20    

Code :
  1. CImageList im;
  2. im.Create(IDI_ROUGE, 32, 1, 0);


 
ici je sais pas comment associer la liste d'image à la ClistCtrl
 

Code :
  1. m_liste.DeleteAllItems();
  2. m_liste.InsertColumn(0, "Col 1", LVCFMT_LEFT, 100, 0);
  3. m_liste.InsertColumn(1, "Col 2", LVCFMT_LEFT, 100, 0);
  4. m_liste.InsertColumn(2, "Col 3", LVCFMT_LEFT, 100, 0);
  5. m_liste.InsertItem(0,"Contenu col 1-1", [ET ICI FO METTRE KOA???]);
  6. m_liste.InsertItem(1,"Contenu col 1-2" );
  7. m_liste.InsertItem(2,"Contenu col 1-3" );

Reply

Marsh Posté le 30-03-2003 à 22:05:48    

Faudrait quand mm rechercher un poil ds la doc de temps en temps :)
 


An "item" in a list control (CListCtrl) consists of an icon, a label, and possibly other information (in "subitems" ).
 
The icons for list control items are contained in image lists. One image list contains full-sized icons used in icon view. A second, optional, image list contains smaller versions of the same icons for use in other views of the control. A third optional list contains "state" images, such as check boxes, for display in front of the small icons in certain views. A fourth optional list contains images that are displayed in individual header items of the list control.
 
Note   If a list view control is created with the LVS_SHAREIMAGELISTS style, you are responsible for destroying the image lists when they are no longer in use. Specify this style if you assign the same image lists to multiple list view controls; otherwise, more than one control might try to destroy the same image list.
 
For more information about list items, see List View Image Lists and Items and Subitems in the Platform SDK. Also see class CImageList in the Class Library Reference and Using CImageList in this article.
 
To create a list control, you need to supply image lists to be used when you insert new items into the list. The following example demonstrates this procedure, where m_pImagelist is a pointer of type CImageList and m_listctrl is a CListCtrl data member.
 
// create, initialize, and hook up image list
m_pImageList = new CImageList();
ASSERT(m_pImageList != NULL);    // serious allocation failure checking
m_pImageList->Create(32, 32, TRUE,   4, 4);
m_pImageList->Add(pApp->LoadIcon(IDI_ICONLIST1));
m_pImageList->Add(pApp->LoadIcon(IDI_ICONLIST2));
m_listctrl.SetImageList(m_pImageList, LVSIL_NORMAL);
 
However, if you don't plan to display icons in your list view or list control, you don't need image lists. See the DAOVIEW sample application for an illustration of a list view with no icons.
 
See Also   Windows Common Controls and MFC Classes

Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed