Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 07-10-2016
Avatar de geolife
[geolife] geolife is offline
Miembro Premium
 
Registrado: nov 2006
Ubicación: Barcelona
Posts: 87
Poder: 18
geolife Va por buen camino
¿Cómo cambiar fuente predeterminada de componente TBalloonHint?

Hola amig@s,

¿Hay alguna forma de cambiar la fuente que usa por defecto el componente TBalloonHint? He visto en el foro algún ejemplo para agregar/extender esta funcionalidad en class(THintWindow); la propiedad Hint por defecto; pero no consigo encontrar la manera de modificar la fuente en TBalloonHint; asociada a la propiedad CustomHint

Saludos,

Silvestre
Responder Con Cita
  #2  
Antiguo 07-10-2016
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,

Seguramente no te sirva, pero, yo uso la siguiente unidad para manejar el "hint" de mis programas, y, en este caso sí que es posible cambiar el tamaño de la fuente, entre otras cosas.

Código Delphi [-]
unit ProgramHint;

interface

uses
  // Delphi
  Vcl.Controls,
  System.Classes,
  Winapi.Windows;

type
  TProgramHint = class(THintWindow)
  private
    procedure AppHint(var HintStr: string; var CanShow:
     Boolean; var HintInfo: Vcl.Controls.THintInfo);
  protected
    procedure Paint(); override;
  public
    function ShouldHideHint(): Boolean; override;
    procedure ActivateHint(Rect: TRect; const AHint: string); override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

implementation

uses
  // Delphi
  Vcl.Forms,
  System.Types;

{ TProgramHint }

constructor TProgramHint.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Canvas.Font.Size := 9;
  Canvas.Font.Name := 'Tahoma';
  Application.OnShowHint := Self.AppHint;
end;

procedure TProgramHint.Paint();
var
  R: TRect;
begin
  R := Rect(10, 10, ClientRect.Right, ClientRect.Bottom);
  DrawText(Canvas.handle, Caption, Length(Caption), R, DT_WORDBREAK);
end;

function TProgramHint.ShouldHideHint(): Boolean;
begin
  Result := True;
end;

procedure TProgramHint.AppHint(var HintStr: string;
 var CanShow: Boolean; var HintInfo: Vcl.Controls.THintInfo);
begin
  HintInfo.HintMaxWidth := 300;
  HintInfo.HideTimeout := 20 * 1000; // 30 seconds
end;

procedure TProgramHint.ActivateHint(Rect: TRect; const AHint: string);
begin
  if ProgramConfig.GUI.ShowHints then
  begin
    Inc(Rect.Bottom, 20);
    Inc(Rect.Right, 20);
    UpdateBoundsRect(Rect);
    inherited;
  end;
end;

initialization
  Application.ShowHint := False;
  HintWindowClass := TProgramHint;
  Application.ShowHint := True;

end.

Sé que no respondo a tu pregunta, pero, igual puede servir de algo aún así.
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
  #3  
Antiguo 07-10-2016
Avatar de geolife
[geolife] geolife is offline
Miembro Premium
 
Registrado: nov 2006
Ubicación: Barcelona
Posts: 87
Poder: 18
geolife Va por buen camino
Hola Dec,

Muchísimas gracias por tu aportación y ayuda!

Al final he conseguido poder extender esta funcionalidad también en el componente TBalloohint; así que lo comparto aquí con vosotros, junto con tu código.

Código Delphi [-]
// Extendemos la clase TCustomHintWindow
type
  TMyHintWindow=class(TCustomHintWindow)
  protected
    procedure Paint; override;
  end;


// Declaración procedimiento
procedure TMyHintWindow.Paint;
begin
  Canvas.Font.Name := 'STXihei';
  inherited;
end;

//Ya dentro del programa hacemos lo siguiente, pintamos el componente TBallooHint con nuestro TMyHintWindows:
BalloonHint1.PaintHint(TMyHintWindow.Create(Form1));



Cita:
Empezado por dec Ver Mensaje
Hola,

Seguramente no te sirva, pero, yo uso la siguiente unidad para manejar el "hint" de mis programas, y, en este caso sí que es posible cambiar el tamaño de la fuente, entre otras cosas.

Código Delphi [-]
unit ProgramHint;

interface

uses
  // Delphi
  Vcl.Controls,
  System.Classes,
  Winapi.Windows;

type
  TProgramHint = class(THintWindow)
  private
    procedure AppHint(var HintStr: string; var CanShow:
     Boolean; var HintInfo: Vcl.Controls.THintInfo);
  protected
    procedure Paint(); override;
  public
    function ShouldHideHint(): Boolean; override;
    procedure ActivateHint(Rect: TRect; const AHint: string); override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

implementation

uses
  // Delphi
  Vcl.Forms,
  System.Types;

{ TProgramHint }

constructor TProgramHint.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Canvas.Font.Size := 9;
  Canvas.Font.Name := 'Tahoma';
  Application.OnShowHint := Self.AppHint;
end;

procedure TProgramHint.Paint();
var
  R: TRect;
begin
  R := Rect(10, 10, ClientRect.Right, ClientRect.Bottom);
  DrawText(Canvas.handle, Caption, Length(Caption), R, DT_WORDBREAK);
end;

function TProgramHint.ShouldHideHint(): Boolean;
begin
  Result := True;
end;

procedure TProgramHint.AppHint(var HintStr: string;
 var CanShow: Boolean; var HintInfo: Vcl.Controls.THintInfo);
begin
  HintInfo.HintMaxWidth := 300;
  HintInfo.HideTimeout := 20 * 1000; // 30 seconds
end;

procedure TProgramHint.ActivateHint(Rect: TRect; const AHint: string);
begin
  if ProgramConfig.GUI.ShowHints then
  begin
    Inc(Rect.Bottom, 20);
    Inc(Rect.Right, 20);
    UpdateBoundsRect(Rect);
    inherited;
  end;
end;

initialization
  Application.ShowHint := False;
  HintWindowClass := TProgramHint;
  Application.ShowHint := True;

end.

Sé que no respondo a tu pregunta, pero, igual puede servir de algo aún así.

Última edición por geolife fecha: 07-10-2016 a las 20:26:28.
Responder Con Cita
  #4  
Antiguo 07-10-2016
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,

Estupendo, hombre, gracias por compartir la respuesta.
__________________
David Esperalta
www.decsoftutils.com
Responder Con Cita
Respuesta


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
Cambiar ruta predeterminada dbxdrivers.ini Casimiro Notevi Conexión con bases de datos 2 11-07-2011 01:36:54
Como cambiar la fuente al showmessage? llSnakell Varios 1 26-01-2011 14:01:07
Cómo cambiar el ancho y alto de una fuente jceluce OOP 0 05-11-2008 22:16:09
Como cambiar impresora predeterminada de Windows itsi API de Windows 2 22-03-2007 16:16:23
Cambiar impresora predeterminada fany1966 Impresión 0 05-08-2006 17:25:04


La franja horaria es GMT +2. Ahora son las 16:40:26.


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