![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|||||||
| Registrarse | FAQ | Miembros | Calendario | Guía de estilo | Buscar | Temas de Hoy | Marcar Foros Como Leídos |
![]() |
|
|
Herramientas | Buscar en Tema | Desplegado |
|
|
|
#1
|
||||
|
||||
|
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);
}
//---------------------------------------------------------------------------
![]() ¿Cómo habría que modificar el código para que se pintara, como suele ser habitual, en el lado derecho de la columna? |
|
#2
|
||||
|
||||
|
Qué raro. Tenía entendido que de esa "flecha" se encarga de dibujarla el gestor de ventanas. ¿No será por la configuración? Aunque no me suena que esté en ningún sitio...
__________________
Proyectos actuales --> Allegro 5 Pascal ¡y Delphi! - BAScript - Multi Language Scriptable Development Environment |
|
#3
|
||||
|
||||
|
Yo la configuración, ni de Windows ni de BCB, las he tocado.
|
|
#4
|
||||
|
||||
|
El código que comentas se basa en dejar que el gestor de ventanas de Windows pinte la flechita y la pinte en el centro de la columna arriba del texto. Esto es así en con los estilos XP MANIFEST.
Si quieres personalizar la flechita tienes que dibujarla tu mismo, este hilo comienza de esa manera. Saludos. |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
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 |
|