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 Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #7  
Antiguo 15-02-2017
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Poder: 15
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Usando las ideas de roman y ecfisa

No he cambiado ninguna propiedad en tiempo de diseño, todo lo hago en ejecucion

Código Delphi [-]
procedure TForm2.FormCreate(Sender: TObject);
begin
  ComboBox1.Style := TComboBoxStyle.csOwnerDrawFixed;
  ComboBox1.OnDrawItem := ComboBox1DrawItem;
  ComboBox1.Font.Size := 14;
  ComboBox1.Canvas.Font.Size := 14;
  ComboBox1.ItemHeight := ComboBox1.Canvas.TextHeight('|') + 2;
  // cargo el combo con la lista de fuentes del sistema para ver como queda
  ComboBox1.Items := Screen.Fonts;
  ComboBox1.ItemIndex := 0;
end;

procedure TForm2.ComboBox1DrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
  Target: TComboBox absolute Control;
begin
  Target.Canvas.FillRect(Rect);
  if (Index >= 0) and (Index < Target.Items.Count) then
  begin
    if ([odComboBoxEdit, odSelected] * State = [odComboBoxEdit, odSelected]) then
      Target.Canvas.Font.Color := clHighlightText;

    Target.Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Target.Items[Index]);
  end;
end;

// lo que sigue es el codigo de los botones
procedure TForm2.btnIncreaseClick(Sender: TObject);
begin
  ComboBox1.Font.Size := ComboBox1.Font.Size + 1;
  ComboBox1.Canvas.Font.Size := ComboBox1.Canvas.Font.Size + 1;
  ComboBox1.Height := ComboBox1.Height - 1;
  ComboBox1.ItemHeight := ComboBox1.Canvas.TextHeight('|') + 2;
end;

procedure TForm2.btnReduceClick(Sender: TObject);
begin
  ComboBox1.Font.Size := ComboBox1.Font.Size - 1;
  ComboBox1.Canvas.Font.Size := ComboBox1.Canvas.Font.Size - 1;
  ComboBox1.Height := ComboBox1.Height + 1;
  ComboBox1.ItemHeight := ComboBox1.Canvas.TextHeight('|') + 2;
end;



Edito: Probando me estoy dando cuenta de que el evento OnDrawItem no es estrictamente necesario:

Cita:
If an OnDrawItem event handler is not provided, the combo box fills the Rect parameter with the current brush and writes the text value of the item specified by the Index parameter.

Última edición por AgustinOrtu fecha: 15-02-2017 a las 23:29:36.
Responder Con Cita
 



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
Aspecto de un trackbar davidj Varios 2 21-10-2007 16:34:21
boton con aspecto de link halizia HTML, Javascript y otros 28 25-04-2007 19:51:10
Aspecto XP trabuc Varios 2 01-12-2004 15:02:51
Aspecto del formulario sur-se OOP 0 27-09-2004 11:39:46
Formulario con aspecto XP fjolivares Varios 5 09-01-2004 14:55:09


La franja horaria es GMT +2. Ahora son las 12:43:54.


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