Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > C++ Builder
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 19-01-2018
Avatar de Angel.Matilla
Angel.Matilla Angel.Matilla is offline
Miembro
 
Registrado: ene 2007
Posts: 1.350
Poder: 19
Angel.Matilla Va por buen camino
Listview con flechas

Estaba usando un código que escafandra puso en otro foro para pintar flechas de ordenamiento en un TListView; el código es este:
Código:
int LastSortedColumn;
bool Ascending;

void SetSortIcon(TListView *ListView, int ColumnIndex, BOOL Orden)
{
     HANDLE hHeader;
     HD_ITEM HD;

     hHeader = (HANDLE)SendMessage(ListView->Handle, LVM_GETHEADER, 0, 0);
     for (int i = 0; i < ListView->Columns->Count; i++)
     {
          HD.mask = HDI_FORMAT;
          SendMessage(hHeader, HDM_GETITEM, i, DWORD(&HD));
          if (i == ColumnIndex)
          {
               if (Orden)
                    HD.fmt = (HD.fmt & ~HDF_SORTUP) | HDF_SORTDOWN;
               else
                    HD.fmt = (HD.fmt & ~HDF_SORTDOWN) | HDF_SORTUP;
          }
          else
               HD.fmt &= ~(HDF_SORTUP | HDF_SORTDOWN);

          SendMessage(hHeader, HDM_SETITEM, i, DWORD(&HD));
     }
}
//---------------------------------------------------------------------------

int  __stdcall SortByColumn(long Item1, long Item2, long Data)
{
     int w;
     TListItem* item1 = reinterpret_cast<TListItem*>(Item1);
     TListItem* item2 = reinterpret_cast<TListItem*>(Item2);

     switch (item1->ListView->Column[Data]->Tag)
     {
          case 0:   // Texto
               if (Data == 0)
                    w = AnsiCompareText(item1->Caption, item2->Caption);
               else
                    w = AnsiCompareText(item1->SubItems->Strings[Data - 1], item2->SubItems->Strings[Data - 1]);
               break;
          case 1:   // Numérico
               if (Data == 0)
                    w = item1->Caption.ToIntDef(0) - item2->Caption.ToIntDef(0);
               else
                    w = item1->SubItems->Strings[Data - 1].ToIntDef(0) - item2->SubItems->Strings[Data - 1].ToIntDef(0);
               break;
          case 2:   // Fecha
               if (Data == 0)
                    w = StrToDateDef(item1->Caption, dFechaNula) - StrToDateDef(item2->Caption, dFechaNula);
               else
                    w = StrToDateDef(item1->SubItems->Strings[Data - 1], dFechaNula) - StrToDateDef(item2->SubItems->Strings[Data - 1], dFechaNula);
               break;
     }
     return Ascending ? w : -w;
}
//---------------------------------------------------------------------------

void __fastcall TfPersona::LisRecColumnClick(TObject *Sender, TListColumn *Column)
{
     if (Column->Index == LastSortedColumn)
          Ascending = !Ascending;
     else
     {
          Ascending = true;
          LastSortedColumn = Column->Index;
     }

     SetSortIcon(LisRec, Column->Index, Ascending);
     static_cast<TListView *>(Sender)->CustomSort(SortByColumn, Column->Index);
}
//---------------------------------------------------------------------------
Funciona a la perfección, pero el aspecto del ListView no me convence porque la flecha se coloca en la parte superior de la columna y es poco visible.

¿Cómo habría que modificar el código para que se pintara, como suele ser habitual, en el lado derecho de la columna?
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Flechas tipo livebindings muli OOP 1 16-01-2015 10:09:18
Evitar desplazarse en un DBGRID con Flechas KAYO Varios 1 13-10-2008 21:01:54
¿Como uso las flechas cursor? D-MO Varios 4 29-08-2005 19:10:34
Como Capturar Las Flechas Arriba/abajo Presionadas MITOPE Varios 3 17-05-2004 20:51:55
Imagenes (flechas) superhopi Gráficos 1 13-06-2003 13:39:28


La franja horaria es GMT +2. Ahora son las 03:06:57.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi