Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
946 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  Afficher des icones dans une ListCtrl

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Afficher des icones dans une ListCtrl

n°347660
harrysauce
Miaaaooou!
Posté le 30-03-2003 à 19:11:49  profilanswer
 

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...

mood
Publicité
Posté le 30-03-2003 à 19:11:49  profilanswer
 

n°347669
VisualC++
J'va y penser ...
Posté le 30-03-2003 à 19:27:23  profilanswer
 

Quel formt ta list ? icon smallicon list ou report ?

n°347670
Harkonnen
Modérateur
Un modo pour les bannir tous
Posté le 30-03-2003 à 19:29:23  profilanswer
 

As tu placé tes icones dans une CImageList ?


---------------
J'ai un string dans l'array (Paris Hilton)
n°347671
VisualC++
J'va y penser ...
Posté le 30-03-2003 à 19:30:27  profilanswer
 

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.

n°347752
harrysauce
Miaaaooou!
Posté le 30-03-2003 à 21:44:20  profilanswer
 

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" );

n°347770
VisualC++
J'va y penser ...
Posté le 30-03-2003 à 22:05:48  profilanswer
 

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


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  Afficher des icones dans une ListCtrl

 

Sujets relatifs
pas d'image mais si contextuel(afficher image) -> S'affiche[PHP] afficher le contenu d'un menu déroulant
[HTML/JS/PHP] Afficher un calque quand on clique sur un boutonafficher une chaine par itération
Afficher tu texte formaté en html en c#[C]Afficher un pixel d'une certaine couleur dans une fenêtre DOS ?
afficher une icone en bas à droite de l'écran...Comment afficher ?
OnMouseOver -> afficher une autre image ? [RESOLU]Comment afficher le temps de generation de la page ?
Plus de sujets relatifs à : Afficher des icones dans une ListCtrl


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR