Ver Mensaje Individual
  #7  
Antiguo 20-06-2020
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 38
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola.

Un ejemplo similar usando un TListBox sería:
Código PHP:
#include<ShellApi>

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  
ListBox1->Style << lbOwnerDrawFixed;
}

void __fastcall TForm1::ListBox1DrawItem(TWinControl *Control, int Index,
      
TRect &Rect, TOwnerDrawState State)
{
  const 
int SPACE_IMG = 5;
  
TListBox *LB = dynamic_cast<TListBox*>(Control);
  
TRect R = Rect;
  
AnsiString s = LB->Items->Strings[Index];
  
int textHeight = LB->Canvas->TextHeight(s);
  
int textLeft   = R.left + ImageList1->Width + SPACE_IMG;
  
int textTop    = R.top + R.Height() / 2 - textHeight / 2;

  
ImageList1->Draw(LB->Canvas, R.left, R.top, Index);
  
LB->Canvas->TextOutA(textLeft, textTop, s);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  if (
OpenDialog1->Execute())
  {
    
WORD inx = 0;
    
TIcon *icon = new TIcon;
    
icon->Handle = ExtractAssociatedIcon(HInstance,
      
OpenDialog1->FileName.c_str(), &inx);
    
ImageList1->AddIcon(icon);
    
ListBox1->Items->Add(OpenDialog1->FileName);
    
delete(icon);
  }
} 
Salida:


Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....

Última edición por ecfisa fecha: 20-06-2020 a las 16:49:52.
Responder Con Cita