Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

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

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 17-02-2005
animal animal is offline
Miembro
 
Registrado: ene 2005
Ubicación: Mendoza, Argentina
Posts: 14
Poder: 0
animal Va por buen camino
Agregar Texto a un TImage

Buenas, primero muchisimas gracias por la buena voluntad y paciencia con mis super prengutas...
Ahora necesito hacer un Componente que hereda de TImage y quiero ponerle un texto en el medio del Timage como puedo lograrlo?.
Probe con crear un objeto TBoundLabel pero lo eventos onMouseMove y onClick no funcionan cuando el mouse esta sobre el TBoundLabel. Necesito un solo objeto y que el MouseMove se aplique a toda el área.
Gracias!.
Cuando termine el componente lo voy a subir asi lo pueden probar...

Por si lo quieren ver aqui esta el codigo.

unit BotonJpgConLabel;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, BotonJpg, Windows;
type
TLabelPosition = (lpAbove, lpBelow, lpLeft, lpRight);
TBotonJpgConLabel = class(TBotonJpg)
private
FEditLabel: TBoundLabel;
FLabelPosition: TLabelPosition;
FLabelSpacing: Integer;
procedure SetLabelPosition(const Value: TLabelPosition);
procedure SetLabelSpacing(const Value: Integer);
protected
{ Protected declarations }
procedure SetParent(AParent: TWinControl); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure SetName(const Value: TComponentName); override;
public
{ Public declarations }
constructor Create(AOwner: TComponent); override;
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;
procedure SetupInternalLabel;
property LabelPosition: TLabelPosition read FLabelPosition write SetLabelPosition;
property LabelSpacing: Integer read FLabelSpacing write SetLabelSpacing;
Procedure MouseMove(Shift: TShiftState; X, Y: Integer); Override;
procedure MouseDown(Button: Controls.TMouseButton; Shift: TShiftState; X, Y: Integer);override;
procedure MouseUP(Button: Controls.TMouseButton; Shift: TShiftState; X, Y: Integer);override;
published
{ Published declarations }
property EditLabel: TBoundLabel read FEditLabel write FEditLabel;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Standard', [TBotonJpgConLabel]);
end;
procedure TBotonJpgConLabel.SetLabelPosition(const Value: TLabelPosition);
var
P: TPoint;
begin
if FEditLabel = nil then exit;
FLabelPosition := Value;
P := Point((Left + (Width - FEditLabel.Width) div 2), (Top + (Height -FEditLabel.Height) div 2));
FEditLabel.SetBounds(P.x, P.y, FEditLabel.Width, FEditLabel.Height);
end;
procedure TBotonJpgConLabel.SetLabelSpacing(const Value: Integer);
begin
FLabelSpacing := Value;
SetLabelPosition(FLabelPosition);
end;

procedure TBotonJpgConLabel.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (AComponent = FEditLabel) and (Operation = opRemove) then
FEditLabel := nil;
end;
procedure TBotonJpgConLabel.SetName(const Value: TComponentName);
begin
if (csDesigning in ComponentState) and ((FEditlabel.GetTextLen = 0) or
(CompareText(FEditLabel.Caption, Name) = 0)) then
FEditLabel.Caption := Value;
inherited SetName(Value);
if csDesigning in ComponentState then
Text := '';
end;
procedure TBotonJpgConLabel.SetParent(AParent: TWinControl);
begin
inherited SetParent(AParent);
if FEditLabel = nil then exit;
FEditLabel.Parent := AParent;
FEditLabel.Visible := True;
end;
constructor TBotonJpgConLabel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FLabelPosition := lpAbove;
FLabelSpacing := 3;
SetupInternalLabel;
end;
procedure TBotonJpgConLabel.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
begin
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
SetLabelPosition(FLabelPosition);
end;
procedure TBotonJpgConLabel.SetupInternalLabel;
begin
if Assigned(FEditLabel) then exit;
FEditLabel := TBoundLabel.Create(Self);
FEditLabel.FreeNotification(Self);
FEditLabel.SendToBack;// .FocusControl := Self;
end;
Procedure TBotonJpgConLabel.MouseMove(Shift: TShiftState; X, Y: Integer);
Begin
Inherited; // y ejecutar el procedimiento del ascendient
End;
procedure TBotonJpgConLabel.MouseDown(Button: Controls.TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
inherited MouseDown(Button, Shift, X, Y);
end;
procedure TBotonJpgConLabel.MouseUP(Button: Controls.TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
inherited MouseUP(Button, Shift, X, Y);
end;
end.
Responder Con Cita
  #2  
Antiguo 22-02-2005
Avatar de defcon1_es
defcon1_es defcon1_es is offline
Miembro
 
Registrado: mar 2004
Ubicación: Cuenca - España
Posts: 533
Poder: 21
defcon1_es Va por buen camino
Hola, creo que no te funciona porque el componente FEditLabel no tiene código en esos eventos.
¿has probado a asignarle a FEditLabel el mismo manejador de eventos OnClick y OnMouseMove que el del componente BotonJpgConLabel?
Código Delphi [-]
procedure TBotonJpgConLabel.SetupInternalLabel;
begin
  if Assigned(FEditLabel) then exit;
  FEditLabel := TBoundLabel.Create(Self);
  FEditLabel.FreeNotification(Self);
  FEditLabel.SendToBack;// .FocusControl := Self;
  FEditLabel.OnClick := Self.OnClick;
  FEditLabel.OnMouseMove := Self.OnMouseMove;
end;
Puede que con esto soluciones el problema que tienes con esos eventos.

salu2.
__________________
Progress Openedge
https://abevoelker.com/progress_open...dered_harmful/


Delphi forever...
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 23:30:24.


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