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 11-10-2005
rruffino rruffino is offline
Miembro
 
Registrado: dic 2004
Ubicación: Berrotaran, Cordoba - Argentina
Posts: 215
Poder: 20
rruffino Va por buen camino
Question Ayuda con PageControl y TabSheet

Hola amigos del foro, los molesto porque tengo el siguiente inconveniente:
Mi aplicación tiene una pagecontrol con varias paletas (tabsheet). Lo que quiero hacer y no puedo, es que al hacer click en una de las paletas se me ponga en negrita o incluso cambiar el color de la fuente del Caption de dicha paleta, sin que me modifique nada más. La verdad he probado un par de cosas y no hallo resultados. Desde ya muchas gracias y espero de vuestra ayuda
Saludos, Román
Responder Con Cita
  #2  
Antiguo 11-10-2005
Avatar de dec
dec dec is offline
Moderador
 
Registrado: dic 2004
Ubicación: Alcobendas, Madrid, España
Posts: 13.107
Poder: 34
dec Tiene un aura espectaculardec Tiene un aura espectacular
Hola,

Conste que no es respuesta, pero, si usaras cierto "TPageControl" que puedes encontrar en la Jedi Library (en la pestaña JVCL Globus 2) hallarías que puedes hacer lo que precisas y mucho más. Si no quisieras utilizarlo tal vez podrías estudiarlo, por ver si puedes implementar el asunto en un "TPageControl" como el que trae Delphi.
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #3  
Antiguo 11-10-2005
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Poder: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Si pones la propiedad OwnerDraw del PageControl en true y pones el siguiente código en su evento OnDrawTab:

Código Delphi [-]
procedure TForm1.PageControl1DrawTab(
  Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
  R: TRect;
  Texto: String;

begin
  if Active then
  begin
    Control.Canvas.Font.Color := clRed;
    Control.Canvas.Font.Style := [fsBold];
  end;

  Texto := PageControl1.Pages[TabIndex].Caption;

  R := Rect;
  Control.Canvas.FillRect(R);

  if not Active then
    InflateRect(R, 0, -3);

  DrawText(
    Control.Canvas.Handle, PChar(Texto), -1, R,
    DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;

lograrás que la pestaña activa tenga su rótulo de color rojo en negritas. Pienso que algo así es lo que quieres.

// Saludos
Responder Con Cita
  #4  
Antiguo 11-10-2005
rruffino rruffino is offline
Miembro
 
Registrado: dic 2004
Ubicación: Berrotaran, Cordoba - Argentina
Posts: 215
Poder: 20
rruffino Va por buen camino
Talking Gracias!!!

Roman, era eso exactamente lo que buscaba, gracias!!!
Responder Con Cita
  #5  
Antiguo 11-10-2005
Migpal Migpal is offline
Miembro
 
Registrado: jul 2005
Ubicación: Colombia
Posts: 91
Poder: 19
Migpal Va por buen camino
UHmmm

Pense que era más dificil, Gracias ROMAN.
Responder Con Cita
  #6  
Antiguo 12-12-2006
Deiv Deiv is offline
Miembro
 
Registrado: jul 2005
Ubicación: La Paz - Bolivia
Posts: 364
Poder: 19
Deiv Va por buen camino
Thumbs up

Hola,
Cita:
Empezado por Roman
Si pones la propiedad OwnerDraw del PageControl en true y pones el siguiente código en su evento OnDrawTab:
Buscando en el Foro encontré este hilo, y hace tiempo me preguntaba con algo relacionado al tema:

¿Como cambiar el color predeterminado que tiene la propiedad HotTrack a un rojo por ejemplo?
Deiv

Última edición por Deiv fecha: 15-12-2006 a las 23:29:33.
Responder Con Cita
  #7  
Antiguo 17-12-2006
Deiv Deiv is offline
Miembro
 
Registrado: jul 2005
Ubicación: La Paz - Bolivia
Posts: 364
Poder: 19
Deiv Va por buen camino
Hola Yo de nuevo,
He buscado en la Red y he encontrado esta dirección:
http://delphi.about.com/cs/adptips20...ltip0800_2.htm
El código funciona bien para un CheckBox, Label, StaticText, pero no así en un TButton, TTabSheet, donde apunto mi pregunta, ¿Que implementación requiere dicho ejemplo para cambiar el color de la propiedad HotTrack en un TTabSheet?
Código Delphi [-]
procedure TForm1.WndProc(var Mesg : TMessage) ;
begin
{ Here we see which component gets changed. 
  This bit here tells us which
  component the mouse is over }
     if Mesg.LParam = Longint(Label1) then
        ChangeColor(Label1, Mesg.Msg) ;
     if Mesg.LParam = Longint(Label2) then
        ChangeColor(Label2, Mesg.Msg) ;
     if Mesg.LParam = Longint(Label3) then
        ChangeColor(Label3, Mesg.Msg) ;
     if Mesg.LParam = Longint(CheckBox1) then
        ChangeColor(CheckBox1, Mesg.Msg) ;
   inherited WndProc(Mesg) ;
end;
procedure TForm1.ChangeColor
   (Sender : TObject; Msg : Integer) ;
Begin
{ If a label is the one that the mouse
is over then we do this } 
  if Sender IS TLabel Then
   begin
     if (Msg = CM_MOUSELEAVE) then
      (Sender As TLabel).Font.Color:=clWindowText;
     if (Msg = CM_MOUSEENTER) then
      (Sender As TLabel).Font.Color:=clBlue;
   end;
{ If a CheckBox is the one ... } 
  if Sender IS TCheckBox Then
   begin
    if (Msg = CM_MOUSELEAVE) then
     (Sender As TCheckBox).Font.Color:=clWindowText ;
    if (Msg = CM_MOUSEENTER) then
     (Sender As TCheckBox).Font.Color:=clRed ;
   end;
end;
Responder Con Cita
  #8  
Antiguo 19-12-2006
Deiv Deiv is offline
Miembro
 
Registrado: jul 2005
Ubicación: La Paz - Bolivia
Posts: 364
Poder: 19
Deiv Va por buen camino
Exclamation

He encontrado este otro consejo:
Cita:
Empezado por Peter Below
If you want to change these you have to draw the tabs yourself. Set the page controls OwnerDraw property to true and handle the OnDrawTab event. To find out if the mouse over the tab you are drawing use GetCursorPos to get the current mouse position in screen coordinates, convert to the page controls client coordinates via its ScreenToClient method and do a PtinRect call with that position using the rect you get as parameter to the event handler.
Pero no se encararlo, ¿alguna idea?
Responder Con Cita
  #9  
Antiguo 10-06-2011
Avatar de ingabraham
ingabraham ingabraham is offline
Miembro
 
Registrado: ago 2007
Posts: 614
Poder: 17
ingabraham Va por buen camino
Cita:
Empezado por roman Ver Mensaje
Si pones la propiedad OwnerDraw del PageControl en true y pones el siguiente código en su evento OnDrawTab:

Código Delphi [-]
procedure TForm1.PageControl1DrawTab(
  Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
  R: TRect;
  Texto: String;

begin
  if Active then
  begin
    Control.Canvas.Font.Color := clRed;
    Control.Canvas.Font.Style := [fsBold];
  end;

  Texto := PageControl1.Pages[TabIndex].Caption;

  R := Rect;
  Control.Canvas.FillRect(R);

  if not Active then
    InflateRect(R, 0, -3);

  DrawText(
    Control.Canvas.Handle, PChar(Texto), -1, R,
    DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;

lograrás que la pestaña activa tenga su rótulo de color rojo en negritas. Pienso que algo así es lo que quieres.

// Saludos


hola y para que se le aplique a todas las pagina
__________________
Enseñar es la virtud de un sabio.
Responder Con Cita
  #10  
Antiguo 14-07-2011
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 685
Poder: 19
olbeup Va camino a la fama
Hay un problema cuando el TabSheet está oculto o no es visible, ya no se corresponden los Caption's de los TabSheet's, si tienes 6 TabSheet y el que hace 3, lo pones oculto, el resto no se corresponde con su título, ¿cómo se pueden solucionar el problema?, la verdad, no lo se.
Responder Con Cita
  #11  
Antiguo 14-07-2011
Avatar de Caro
*Caro* Caro is offline
Moderadora
 
Registrado: jul 2004
Ubicación: Cochabamba, Bolivia
Posts: 2.544
Poder: 22
Caro Va por buen camino
Cita:
Empezado por ingabraham Ver Mensaje
hola y para que se le aplique a todas las pagina
Hola, solo tienes que quitar la condición del Active:

Código Delphi [-]
var
  R: TRect;
  Texto: String;
begin
  Control.Canvas.Font.Color := clRed;
  Control.Canvas.Font.Style := [fsBold];

  Texto := PageControl1.Pages[TabIndex].Caption;

  R := Rect;
  Control.Canvas.FillRect(R);
 ...............................
  .................................

Saluditos
__________________
Disfruten cada minuto de su vida a lado de sus seres queridos como si fuese el ultimo, uno nunca sabe lo que puede pasar.
Responder Con Cita
  #12  
Antiguo 14-07-2011
Avatar de Caro
*Caro* Caro is offline
Moderadora
 
Registrado: jul 2004
Ubicación: Cochabamba, Bolivia
Posts: 2.544
Poder: 22
Caro Va por buen camino
Cita:
Empezado por olbeup Ver Mensaje
Hay un problema cuando el TabSheet está oculto o no es visible, ya no se corresponden los Caption's de los TabSheet's, si tienes 6 TabSheet y el que hace 3, lo pones oculto, el resto no se corresponde con su título, ¿cómo se pueden solucionar el problema?, la verdad, no lo se.
Hola olbeup, prueba de esta forma:

Código Delphi [-]
var
aRect: TRect;
i, TIndex, Ind: Integer;
begin
 if Active then
  begin
   Control.Canvas.Font.Style := [fsBold];
   Control.Canvas.Font.Color := clRed;
  end
 else
 begin
  Control.Canvas.Font.Style := [];
 end;
 aRect := Rect;
 TIndex := -1;
 Ind := TabIndex;
 for i := 0 to PageControl1.PageCount - 1 do
  begin
   if TIndex = TabIndex then Break;
   if not PageControl1.Pages[i].TabVisible then
    Inc(Ind)
   else
    Inc(TIndex);
  end;
 DrawText(Control.Canvas.Handle,PChar(PageControl1.Pages[Ind].Caption),
         -1,aRect,DT_CENTER or DT_SINGLELINE);
end;

Saluditos
__________________
Disfruten cada minuto de su vida a lado de sus seres queridos como si fuese el ultimo, uno nunca sabe lo que puede pasar.
Responder Con Cita
  #13  
Antiguo 15-07-2011
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 685
Poder: 19
olbeup Va camino a la fama
Perfecto, pero el problema radica cuando el Font del TabSheet es negrita lo cual agranda el texto y se sale del marco del TabSheet.

Dejo el código que realizado con el que habéis aportado todos:
Código Delphi [-]
// Redibuja el PageControl (Tab) el título en color
procedure TForm1.OnEventPageControlDrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);

  procedure SetChangeColorControl(Style: TFontStyles; Color: TColor);
  begin
    Control.Canvas.Font.Style := Style;
    Control.Canvas.Font.Color := Color;
  end;

  function GetTabIndex: Integer;
  var
    I, TIndex, Ind: Integer;
  begin
    // Iniciarlizar variables de seguimiento del TabSheet
    TIndex := -1;
    Ind    := TabIndex;

    // Iniciar bucle y devolver todos los TabSheet visible
    for I := 0 to (PageControl1.PageCount -1) do
    begin
      if (TIndex = TabIndex) then
        Break;

      if (not PageControl1.Pages[i].TabVisible) then
        Inc(Ind)
      else
        Inc(TIndex);
    end;

    Result := Ind;
  end;

var
  R: TRect;
  Texto: String;

begin
  // Comprobar si está activo y hacer cambios en el Font del TabSheet
  if Active then
    SetChangeColorControl([fsBold], clBlue)
  else
    SetChangeColorControl([], clBlack);

  // Guardar el Caption del TabSheet el cual Corresponde
  Texto := (Control as TPageControl).Pages[GetTabIndex].Caption;

  R := Rect;
  Control.Canvas.FillRect(R);

  // Redibujar el TabSheet que corresponde del PageControl
  DrawText(
    Control.Canvas.Handle, PChar(Texto), -1, R,
    DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
Responder Con Cita
  #14  
Antiguo 15-07-2011
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 685
Poder: 19
olbeup Va camino a la fama
Hay un error en el GetTabIndex, ya que sólo actúa sobre el PageControl1, si tenemos varios PageControl no funcionará, dejo código nuevo.
Código Delphi [-]
// Redibuja el Page Control (Tab) el título en color
procedure TfrmServicios.OnEventPageControlDrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);

  procedure SetChangeColorControl(Style: TFontStyles; Color: TColor);
  begin
    Control.Canvas.Font.Style := Style;
    Control.Canvas.Font.Color := Color;
  end;

  function GetTabIndex: Integer;
  var
    I, TIndex, Ind: Integer;
  begin
    // Iniciarlizar variables de seguimiento del TabSheet
    TIndex := -1;
    Ind    := TabIndex;

    // Iniciar bucle y devolver todos los TabSheet visible
    for I := 0 to ((Control as TPageControl).PageCount -1) do
    begin
      if (TIndex = TabIndex) then
        Break;

      if (not (Control as TPageControl).Pages[i].TabVisible) then
        Inc(Ind)
      else
        Inc(TIndex);
    end;

    Result := Ind;
  end;

var
  R: TRect;
  TabCaption: String;
begin
  // Comprobar si está activo y hacer cambios en el Font del TabSheet
  if Active then
    SetChangeColorControl([fsBold], clBlue)
  else
    SetChangeColorControl([], clBlack);

  // Guardar el Caption del TabSheet el cual Corresponde
  TabCaption := (Control as TPageControl).Pages[GetTabIndex].Caption;

  R := Rect;
  Control.Canvas.FillRect(R);

  // Redibujar el TabSheet que corresponde del PageControl
  DrawText(
    Control.Canvas.Handle, PChar(TabCaption), -1, R,
    DT_SINGLELINE or DT_CENTER or DT_VCENTER);
end;
Un saludo

P.D.: Perdón
Responder Con Cita
  #15  
Antiguo 21-10-2015
jose.ignacio.ve jose.ignacio.ve is offline
Miembro
 
Registrado: sep 2012
Posts: 79
Poder: 12
jose.ignacio.ve Va por buen camino
Hola, estuve buscando en todos los foros y no logro pintar toda la pestaña, solo legre pintar el titulo de la pagina seleccionada, yo necesito pintar todo el pagecontrol de azul por ejemplo, ya que lo tengo en blanco unicamente todas las paginas y lo quegre pintar las fuentes que estan dentro de cada pagina paro la pagina no lo pintar alguna ayuda?
Responder Con Cita
  #16  
Antiguo 21-10-2015
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
El PageControl por defecto no lo soporta. O usas un componente de terceros (como los Raize) o bien metes adentro de cada pagina un TForm o TFrame empotrado. Es simplemente poner como Parent del objeto empotrado la pestaña

Luego es cuestion de que el objeto empotrado este pintado
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


La franja horaria es GMT +2. Ahora son las 08:35:43.


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