Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 27-08-2008
ANALBA ANALBA is offline
Miembro
 
Registrado: jul 2008
Posts: 10
Poder: 0
ANALBA Va por buen camino
Listview color fondo

Tengo un listview que cargo manualmente y en el evento CustomDrawSubItem pongo el siguiente codigo:

Código:
 
 if (Item.Selected) then
    Begin
    Sender.Canvas.Brush.Color := clblue;
    end;
He probado poner esto tambien:

Código:
 
 if (Item.Selected) then
    Begin
    SetBkColor(Sender.Canvas.Handle, clblue);
    end;
Obteniendo el mismo resultado, en los dos casos pone el fondo azul en el texto de cada subitem, pero no pone toda la linea azul, como cuando seleccionas una en automatico, alguien sabe que me falta o que estoy haciendo mal.

Gracias y un saludo
Responder Con Cita
  #2  
Antiguo 27-08-2008
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Poder: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
Creo que debería ser así:

Código Delphi [-]
if (Item.Selected) then
    Begin
    Item.Canvas.Brush.Color := clblue;
    end;

Según el Help de Delphi:

Cita:
TCustomListView.OnCustomDrawSubItem
Occurs when a subitem must be rendered in an owner-draw list view.

type TLVCustomDrawSubItemEvent = procedure(Sender: TCustomListView; Item: TListItem; SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean) of object;
property OnCustomDrawSubItem: TLVCustomDrawSubItemEvent

Description

Write code in an OnCustomDrawSubItem handler to draw to the subitems that appear in additional columns to the right of each item when ViewStyle is vsReport. Use the list view’s Canvas property as a drawing surface. Unlike the OnDrawItem event, the list view receives this event even if the OwnerDraw property is False.

The Sender Parameter specifies the list view that owns the subitems. The Item parameter is the current Item being drawn. The SubItem parameter is the index of the subitem of that list item in its SubItems property. The State property indicates various attributes that can affect the way the subitem is drawn. Set DefaultDraw to False to prevent the list view from adding the subitem’s text after the event handler exits.

Note: OnCustomDrawSubItem occurs immediately prior to the rendering of each subitem. To augment the default drawing process at other stages (such as after the subitem is drawn), use the OnAdvancedCustomDrawSubItem event instead.
Responder Con Cita
  #3  
Antiguo 27-08-2008
ANALBA ANALBA is offline
Miembro
 
Registrado: jul 2008
Posts: 10
Poder: 0
ANALBA Va por buen camino
Gracias por tu respuesta pero lo he probado tal cual me dices y el Item no tiene la propiedad Canvas lo has puesto tu de alguna otra manera.

Un saludo
Responder Con Cita
  #4  
Antiguo 27-08-2008
Avatar de duilioisola
[duilioisola] duilioisola is offline
Miembro Premium
 
Registrado: ago 2007
Ubicación: Barcelona, España
Posts: 1.734
Poder: 20
duilioisola Es un diamante en brutoduilioisola Es un diamante en brutoduilioisola Es un diamante en bruto
No, lo puse rápidamente, sin comporbarlo.

Mirando el Help de Delphi sobre TListItem encontré esta propiedad que supongo te puede servir:

Cita:
TListItem.DisplayRect
Returns the bounding rectangle of the list item.

type TDisplayCode = (drBounds, drIcon, drLabel, drSelectBounds);
function DisplayRect(Code: TDisplayCode): TRect;

Description

Use DisplayRect to get the coordinates of the list item in the client coordinates of the containing listview. The Code parameter specifies what part of the item the bounding rectangle surrounds. These are the possible values for the Code parameter.

Value Meaning

drBounds Returns the bounding rectangle of the entire list item, including the icon and label.
drIcon Returns the bounding rectangle of the icon or small icon
drLabel Returns the bounding rectangle of the item text
drSelectBounds Returns the union of the icon and label rectangles, but excludes columns in report view
Podrías escribir un rectánculo de color sobre el canvas de "Sender"
Responder Con Cita
Respuesta



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
Fondo color label LizdR Varios 3 19-03-2008 16:58:02
Color de fondo de un ShowMessage() Perio Varios 4 05-02-2008 16:08:35
Color de fondo de pantalla madiazg API de Windows 12 27-10-2007 07:40:10
Color de fondo de Bitmap arantzal Varios 1 15-01-2007 11:32:42
Color de fondo de un TImage Drake OOP 1 03-08-2006 19:36:36


La franja horaria es GMT +2. Ahora son las 09:17:00.


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