Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Lazarus, FreePascal, Kylix, etc. (https://www.clubdelphi.com/foros/forumdisplay.php?f=14)
-   -   Componente no actúa como debe en ejecución (https://www.clubdelphi.com/foros/showthread.php?t=94079)

José Luis Garcí 20-07-2019 10:14:09

Componente no actúa como debe en ejecución
 
Buenas tardes, compañero, un placer comunicarme con vosotros otra vez después de tanto tiempo.



Resulta que he empezado a trabajar con Lazarus y estoy comenzando a pasar mis componentes delphi a Lazarus.



Este es el primero que paso, funciona bien en modo de diseño, pero al ejecutar el texto me desaparece. He estado buscando la información pero no la encuentro, a ver si podéis ayudar, gracias como siempre por adelantado



Los problemas son:

No aparece el caption de cada botón

El hint que muestra es en ingles

Código Delphi [-]

unit U_L_DBNavigator1;
 
{$mode delphi}
 
interface
 
uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, DBCtrls, Buttons;
 
type
 
  { U_L_DBNavigator1 }
 
  { TL_DBNavigator1 }
 
  TL_DBNavigator1 = class(TDBNavigator)
  private
    FColorFont: Tcolor;
    FLayout: TButtonLayout;
    FSizeFontText: Integer;
    FUserText: Boolean;
    procedure SetColorFont(AValue: Tcolor);
    procedure setlayout(AValue: TButtonLayout);
    procedure SetSizeFontText(AValue: Integer);
    procedure SetUserText(AValue: Boolean);
 
  protected
 
  public
     constructor Create(AOwner: TComponent); override;
     procedure Repaint; override;
  published
    property  UserText       :Boolean  read FUserText     write SetUserText;      //Ver nombre en los botones  AQUI PONER EL DEFAULT si es necesario
    property  SizeFontText  :Integer  read FSizeFontText   write SetSizeFontText;  //tamaño de la fuente del texto  AQUI PONER EL DEFAULT si es necesario
    property  Layout        :TButtonLayout  read Flayout write setlayout;
    property  ColorFont     :Tcolor   read FColorFont write SetColorFont;
  end;
 
procedure Register;
 
implementation
 
procedure Register;
begin
  {$I u_l_dbnavigator1_icon.lrs}
  RegisterComponents('AA_MIOS',[TL_DBNavigator1]);
end;
 
{ U_L_DBNavigator1 }
 
procedure TL_DBNavigator1.SetSizeFontText(AValue: Integer);
//------------------------------------------------------------------------------
//**********************************************************[ SIZEFONTTEXT ]****
// tamaño de la fuente del texto
//------------------------------------------------------------------------------
begin
  if FSizeFontText<>Avalue then FSizeFontText:=AValue;
  setUserText(FUserText);
end;
 
procedure TL_DBNavigator1.setlayout(AValue: TButtonLayout);
begin
  if Flayout=AValue then Exit;
  Flayout:=AValue;
  setUserText(FUserText);
end;
 
procedure TL_DBNavigator1.SetColorFont(AValue: Tcolor);
begin
  if FColorFont=AValue then Exit;
  FColorFont:=AValue;
  SetUserText(FUserText);
end;
 
procedure TL_DBNavigator1.SetUserText(AValue: Boolean);
//------------------------------------------------------------------------------
//**************************************************************[ USERTEXT ]****
// Ver nombre en los botones
//------------------------------------------------------------------------------
var
  B: TNavigateBtn;
begin
   if FUserText<>Avalue then FUserText:=AValue;
   if FUserText=true then
   begin
       for B := Low ( TNavigateBtn ) to High ( TNavigateBtn ) do
        begin
          with TL_DBNavigator1( Self ).Buttons [ B ] do
          begin
              Case Index of
                nbFirst   : Caption := 'Primero';
                nbPrior   : Caption := 'Anterior';
                nbNext    : Caption := 'Siguiente';
                nbLast    : Caption := 'Último';
                nbInsert  : Caption := 'Insertar';
                nbDelete  : Caption := 'Borrar';
                nbEdit    : Caption := 'Editar';
                nbPost    : Caption := 'Grabar';
                nbCancel  : Caption := 'Cancelar';
                nbRefresh : Caption := 'Refrescar';
              End;
              Case Index of
                nbFirst   : Hint := 'Ir al primer registro';
                nbPrior   : hint := 'Ir al registro anterior';
                nbNext    : hint := 'Ir al siguiente registro';
                nbLast    : hint := 'Ir al último registro';
                nbInsert  : hint := 'Insertar un nuevo registro';
                nbDelete  : hint := 'Borrar el registro actual';
                nbEdit    : hint := 'Editar el registro actual';
                nbPost    : hint := 'Grabar el registro actual';
                nbCancel  : hint := 'Cancelar la edición del registro actual';
                nbRefresh : hint := 'Refrescar los datos';
              End;
 
              Buttons[b].Layout:=Flayout;      //posición del icono
              Buttons[b].Font.Color:=FColorFont;        //Damos color a la fuente
              Buttons[b].Font.Size:=FSizeFontText;  //tamaño que le damos a la fuente
              Buttons[b].Hint := Caption;           // asignamos al hint el valor del literal del caption
              Buttons[b].ShowHint := True;
          end;
        end;
   end else
   begin
          for B := Low ( TNavigateBtn ) to High ( TNavigateBtn ) do
        begin
          with TL_DBNavigator1 ( Self ).Buttons [ B ] do
          begin
              Case Index of
                nbFirst   : Caption := '';
                nbPrior   : Caption := '';
                nbNext    : Caption := '';
                nbLast    : Caption := '';
                nbInsert  : Caption := '';
                nbDelete  : Caption := '';
                nbEdit    : Caption := '';
                nbPost    : Caption := '';
                nbCancel  : Caption := '';
                nbRefresh : Caption := '';
              End;
              Buttons[b].Layout := Flayout;      //posición del icono
              Buttons[b].Font.Color:=FColorFont;        //Damos color a la fuente
              Buttons[b].Font.Size:=FSizeFontText;  //tamaño que le damos a la fuente
              Buttons[b].Hint := Caption;           // asignamos al hint el valor del literal del caption
              Buttons[b].ShowHint := True;
          end;
        end;
   end;
   Repaint;
End;
 
{begin
  if FUserText=AValue then Exit;
  FUserText:=AValue;
end;}   //Original
 
constructor TL_DBNavigator1.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FUserText  := False  ; //Ver nombre en los botones
  FSizeFontText  := 6;       //tamaño de la fuente del texto
  VisibleButtons:= [nbFirst,nbPrior,nbNext,nbLast]; //Botones visibles de entrada
  Flayout:=blGlyphTop;
  setUserText(FUserText);
end;
 
procedure TL_DBNavigator1.Repaint;
begin
  inherited Repaint;
end;
 
end.

Casimiro Notevi 20-07-2019 17:49:50

¿No estarás usando uno anterior al nuevo editado?

José Luis Garcí 20-07-2019 20:53:22

No lo he editado, siguiendo el código del anterior en delphi, pero partiendo desde 0 en Lazarus.

El tema es que en fase de diseño, muestra el texto, pero en cuanto lo ejecuto desaparece.

Ahora si cojo la parte del código y lo pongo en el oncreate del Form, funciona bien, por lo que no tengo mayor problema, pero no entiendo cual es el problema a la hora de ejecutarlo.

Como siempre gracias.


La franja horaria es GMT +2. Ahora son las 10:24:10.

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