Ver Mensaje Individual
  #7  
Antiguo 06-06-2014
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
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 Angel.Matilla.

Código:
int GColNo; // también podría ser privada al TForm... (int FColNo;)

int __stdcall CustomSortFn(long Item1, long Item2, long ParamSort)
{
  TListItem *it1 = reinterpret_cast<TListItem *>(Item1);
  TListItem *it2 = reinterpret_cast<TListItem *>(Item2);
  if (GColNo)
    return CompareText(it1->SubItems->Strings[GColNo-1],
                       it2->SubItems->Strings[GColNo-1]) * ParamSort;
  else
    return CompareText(it1->Caption, it2->Caption) * ParamSort;
}

void __fastcall TForm1::ListView1ColumnClick(TObject *Sender,
      TListColumn *Column)
{
 static int order = 1;

 GColNo = Column->Index;
 order = (order == 1 ? -1 : 1) ;
 ListView1->CustomSort(CustomSortFn, order);
}
Saludos
__________________
Daniel Didriksen

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