SoloCodigo

Programación General => C/C++ => C++ Builder => Mensaje iniciado por: betitono1 en Martes 27 de Enero de 2004, 15:34

Título: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: betitono1 en Martes 27 de Enero de 2004, 15:34
Hola que tal como puedo agregar imagenes a un ListBox, ComboBox o StringGrid, me podian decir como hacerlo o en donde puedo econtrar informacion de esto.


Saludos
Título: Re: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: betitono1 en Miércoles 28 de Enero de 2004, 15:58
he encontrado un ejemplo en esta pagina

http://www.sources.ru/builder/gui/bitmap_i..._combobox.shtml (http://www.sources.ru/builder/gui/bitmap_in_list_combobox.shtml)

lo ejecuto y no me marca error pero no me muestra la imagen. Tendra que ver el tamaño del bmp?
Título: Re: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: _Viktor en Miércoles 28 de Enero de 2004, 17:05
Hola, te aseguraste de que el ComBoBox tenga su propiedad Style en "csOwnerDrawVariable" ?

Ya que el codigo esta bien y hacen el siguiente comentario:
Citar
Измените свойства Style в ComboBox и ListBox на csOwnerDrawVariable и lbOwnerDrawVariable

Es eso ?
Título: Re: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: betitono1 en Viernes 30 de Enero de 2004, 07:30
y para el stringgrid como le hago
Título: Re: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: _Viktor en Viernes 30 de Enero de 2004, 12:27
Ehhh... De nada...

... Aqui esta el codigo para poner imagenes bmp en un StringGrid:

Código: Text
  1. //--------------------------------------------------------------------------------
  2. void __fastcall TForm1::LeerImagenes()
  3. {
  4. TPicture *picThis = new TPicture;
  5. String strTemp="c:\\foto.bmp";
  6. picThis->LoadFromFile(strTemp);
  7. StringGrid1->Objects[0][0]=(TObject*) picThis->Graphic;
  8. }
  9. //--------------------------------------------------------------------------------
  10. void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
  11.       int ARow, TRect &Rect, TGridDrawState State)
  12. {
  13.   if(StringGrid1->Objects[ACol][ARow]!=0){
  14.       StringGrid1->Canvas->Draw(Rect.Left+0,
  15.       Rect.Top+0,(Graphics::TGraphic*)
  16.       StringGrid1->Objects[ACol][ARow]);
  17.   }
  18. }
  19. //--------------------------------------------------------------------------------
  20.  

Y este corresponde si insertas imagenes jpeg en el StringGrid

Código: Text
  1. //--------------------------------------------------------------------------------
  2. void __fastcall TForm1::Button1Click(TObject *Sender)
  3. {
  4. TJPEGImage *foto = new TJPEGImage;
  5. String strTemp="D:\\avathar2.jpg";
  6. foto->LoadFromFile(strTemp);
  7. StringGrid1->Objects[0][0]= foto;
  8.  
  9. }
  10. //--------------------------------------------------------------------------------
  11. void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
  12.       int ARow, TRect &Rect, TGridDrawState State)
  13. {
  14.   if(StringGrid1->Objects[ACol][ARow]!=0)
  15.   {
  16.       StringGrid1->Canvas->Draw(Rect.Left+0,Rect.Top+0,(TJPEGImage*)
  17.       StringGrid1->Objects[ACol][ARow]);
  18.   }
  19. }
  20. //--------------------------------------------------------------------------------
  21.  

Espero te sirva.
Saludos!
Título: Re: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: betitono1 en Viernes 30 de Enero de 2004, 18:41
Gracias me ha funcionado a la primera
Título: Re: Agregar Imagenes A Listbox, Combobox O Stringgrid
Publicado por: freddito91 en Jueves 10 de Marzo de 2011, 00:54
hola como es la forma para introducir la imagen en la stringgrid desde un archivo buscando la imagen con un directlistbox..