Ir al contenido


Foto

Eliminar negrita del speedbutton en componete?


  • Por favor identifícate para responder
1 respuesta en este tema

#1 adriano_servitec

adriano_servitec

    Advanced Member

  • Miembros
  • PipPipPip
  • 91 mensajes
  • LocationCuritiba-Pr - Brasil

Escrito 08 enero 2011 - 11:50

Hola compañeros programadores...Estoy a crear un componente, más tiene un problema.

Os speedbuttons en el lado están en negrita, quiero sppedbuttons con la fuente normal.

Segue o código:


delphi
  1. {*******************************************************}
  2. {      Autor:                                          }
  3. {      Adriano Componente Visual                      }
  4. {                                                      }
  5. {  Copyright © 2011 - 01 - 09 YYYY=MM+DD              }
  6. {                                                      }
  7. {*******************************************************}
  8. unit uConteinerFilter;
  9.  
  10. interface
  11.  
  12. uses
  13.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  14.   Dialogs, ExtCtrls, Math, StdCtrls, Buttons, XPMan, DB, ADODB, Grids, DBGrids,
  15.   ComCtrls;
  16.  
  17.   const
  18.     {Painel Container}
  19.     cHeigthPanelClient = 523;
  20.     cLeftPanelClient  = 0;
  21.     cTopPanelClient    = 0;
  22.     cWidthPanelClient  = 434;
  23.     {Panel Superior}
  24.     cHeigthPanelTop    = 41;
  25.     cLeftPanelTop      = 0;
  26.     cTopPanelTop      = 0;
  27.     cWidthPanelTop    = 385;
  28.     {Label Pesquisa}
  29.     cLeftLabelPesq    = 10;
  30.     cTopLabelPesq      = 12;
  31.     {Edit Pesquisa}
  32.     cWidthEditPesq    = 257;
  33.     cLeftEditPesq      = 40;
  34.     cTopEditPesq      = 8;
  35.     {Grade de Pesquisa}
  36.     cHeigthGradePesq    = 422;
  37.     cLeftGradePesq      = 0;
  38.     cTopGradePesq      = 43;
  39.     cWidthGradePesq    = 384;
  40.     {Button Filter}
  41.     cHeigthBtFilter    = 25;
  42.     cLeftBtFilter      = 304;
  43.     cTopBtFilter      = 8;
  44.     cWidthBtFilter    = 75;
  45.     {Painel lateral}
  46.     cWidthPanelRigth  = 40;
  47.     cHeigthPanelRigth  = 470;
  48.     {SpeedButton}
  49.     cHeigthSpeedButton = 33;
  50.     cLeftSeedButton    = 04;
  51.     cTopSeedButton    = 03;
  52.     cWidthSeedButton  = 33;
  53.  
  54. type
  55.   TContainerFilter = class(TCustomPanel)
  56.   private
  57.     FPanelSuperior: TPanel;
  58.     FLabelPesq: TLabel;
  59.     FEditPesq : TEdit;
  60.     FButtonFilter : TButton;
  61.     FGradePesq : TDBGrid;
  62.     FPanelLateral : TPanel;
  63.     FSpeedButton : TSpeedButton;
  64.     FStatusBar: TStatusBar;
  65.     FButtonExit: TNotifyEvent;
  66.     FButtonClick: TNotifyEvent;
  67.     FButtonAutoSize: Boolean;
  68.     FAutoSize: Boolean;
  69.     procedure OnSpeedButtonClick(sender: TObject);
  70.     procedure OnSpeedButtonExit(sender: Tobject);
  71.     procedure SetAutoSize(const Value: Boolean);
  72.     procedure SetButtonAutoSize(const Value: Boolean);
  73.     procedure RestrictSize(var msg: TMessage);
  74.   protected
  75.   //
  76.   public
  77.     constructor Create(AOwner: TComponent); override;
  78.     destructor Destroy; override;
  79.   published
  80.     //Propriedades dos eventos do panel
  81.     property OnClick;
  82.     property OnEnter;
  83.     property OnExit;
  84.     property OnDblClick;
  85.     property Parent;
  86.     property Owner;
  87.     property ParentWindow;
  88.     property AutoSize: Boolean read FAutoSize write SetAutoSize default False;
  89.     //Propriedades publicadas SpeedButton
  90.     property OnButtonClick: TNotifyEvent read FButtonClick write FButtonClick;
  91.     property OnButtonExit : TNotifyEvent read FButtonExit write FButtonExit;
  92.     property ButtonAutoSize: Boolean read FButtonAutoSize write SetButtonAutoSize default False;
  93.   end;
  94.  
  95. procedure Register;
  96.  
  97. implementation
  98.  
  99. procedure Register;
  100. begin
  101.   RegisterComponents('CompAraSystems', [TContainerFilter]);
  102. end;
  103.  
  104. constructor TContainerFilter.Create(Aowner: TComponent);
  105.   procedure CriarButtons(sCapiton: String; iTop: Integer);
  106.   begin
  107.     FSpeedButton := TSpeedButton.Create(Self);
  108.     with FSpeedButton do {caracteristicas do SpeedButton}
  109.     begin
  110.       Parent    := FPanelLateral;
  111.       Align    := alTop;
  112.       AllowAllUp:= True;
  113.       if GroupIndex = 0 then
  114.         GroupIndex := 1;
  115.       Left      := cLeftSeedButton;
  116.       Height    := cHeigthSpeedButton;
  117.       Width    := cWidthSeedButton;
  118.       Caption  := sCapiton;
  119.       Font.Name := 'Tahoma';
  120.       Top      := cTopSeedButton + iTop;
  121.       TabOrder  := 0;
  122.       OnClick  := OnSpeedButtonClick;
  123.       OnExit    := OnSpeedButtonExit;
  124.     end;
  125.   end;
  126.  
  127. begin
  128.   inherited Create(Aowner);
  129.  
  130.   //Montando o painel superior
  131.   Self.Parent := TWinControl(Aowner);
  132.   with Self do
  133.   begin
  134.     Align      := alClient; //sempre no topo d form
  135.     Caption    := EmptyStr;
  136.     Height    := cHeigthPanelClient;
  137.     Top        := cTopPanelClient;
  138.     Left      := cLeftPanelClient;
  139.     Width      := cWidthPanelClient;
  140.     BevelInner := bvNone;
  141.   end;
  142.  
  143.   FPanelSuperior := TPanel.Create(Self);
  144.   with FPanelSuperior do {caracteristicas do Lateral}
  145.   begin
  146.     Parent    := Self;
  147.     Font.Name  := 'Tahoma';
  148.     Caption    := EmptyStr;
  149.     Width      := cWidthPanelTop;
  150.     Height    := cHeigthPanelTop;
  151.     BevelInner := bvLowered;
  152.   end;
  153.  
  154.   FLabelPesq := TLabel.Create(Self);
  155.   with FLabelPesq do {caracteristicas do Label}
  156.   begin
  157.     Caption    := 'Filtro:';
  158.     Parent    := FPanelSuperior;
  159.     Top        := cTopLabelPesq;
  160.     Left      := cLeftLabelPesq;
  161.   end;
  162.  
  163.   FEditPesq := TEdit.Create(Self);
  164.   with FEditPesq do {caracteristicas do edit}
  165.   begin
  166.     Parent    := FPanelSuperior; 
  167.     Caption    := EmptyStr;
  168.     Top        := cTopEditPesq;
  169.     Left      := cLeftEditPesq;
  170.     Width      := cWidthEditPesq;
  171.   end;
  172.  
  173.   FButtonFilter := TButton.Create(Self);
  174.   with FButtonFilter do {caracteristicas do edit}
  175.   begin
  176.     Parent    := FPanelSuperior; 
  177.     Caption    := 'Filtrar';
  178.     Height    := cHeigthBtFilter;
  179.     Top        := cTopBtFilter;
  180.     Left      := cLeftBtFilter;
  181.     Width      := cWidthBtFilter;
  182.   end;
  183.  
  184.   FGradePesq := TDBGrid.Create(Self);
  185.   with FGradePesq do {Caracteristica da grade}
  186.   begin
  187.     Parent := Self;
  188.     Height    := cHeigthGradePesq;
  189.     Top        := cTopGradePesq;
  190.     Left      := cLeftGradePesq;
  191.     Width      := cWidthGradePesq;
  192.   end;
  193.  
  194.   FPanelLateral := TPanel.Create(Self);
  195.   with FPanelLateral do {caracteristicas do Lateral}
  196.   begin
  197.     Parent    := Self;
  198.     Align      := alRight;
  199.     Font.Name  := 'Tahoma'; 
  200.     Caption    := EmptyStr;
  201.     Width      := cWidthPanelRigth;
  202.     Height    := cHeigthPanelRigth;
  203.     BevelInner := bvLowered;
  204.   end;
  205.  
  206.   //Monta os buttons
  207.   CriarButtons('0..9',0);
  208.   CriarButtons('AB',33);
  209.   CriarButtons('CD',66);
  210.   CriarButtons('EF',99);
  211.   CriarButtons('GH',132);
  212.   CriarButtons('IJ',165);
  213.   CriarButtons('KL',198);
  214.   CriarButtons('MN',231);
  215.   CriarButtons('OP',264);
  216.   CriarButtons('QR',297);
  217.   CriarButtons('ST',330);
  218.   CriarButtons('UV',363);
  219.   CriarButtons('XW',396);
  220.   CriarButtons('YZ',429);
  221.  
  222.   FStatusBar := TStatusBar.Create(Self);
  223.   with FStatusBar do {caracteristicas do StatusBar}
  224.   begin
  225.     Parent    := Self;
  226.   end;
  227.  
  228. end;
  229.  
  230. destructor TContainerFilter.Destroy;
  231. begin
  232.  
  233.   inherited;
  234. end;
  235.  
  236. //Metodos
  237. procedure TContainerFilter.OnSpeedButtonClick(sender: TObject);
  238. begin
  239.   if Assigned(FButtonClick) then
  240.     FButtonClick(Sender);
  241. end;
  242.  
  243. procedure TContainerFilter.OnSpeedButtonExit(sender: Tobject);
  244. begin
  245.   if Assigned(FButtonExit) then
  246.     FButtonExit(Sender);
  247. end;
  248.  
  249. procedure TContainerFilter.SetAutoSize(const Value: Boolean);
  250. begin
  251.   if FAutoSize <> Value then
  252.   begin
  253.     FAutoSize := Value;
  254.     if Value then
  255.       AdjustSize; //comando da classe Controls
  256.   end;
  257. end;
  258.  
  259. procedure TContainerFilter.SetButtonAutoSize(const Value: Boolean);
  260. begin
  261.   if FButtonAutoSize <> Value then
  262.   begin
  263.     FButtonAutoSize := Value;
  264.     if Value then
  265.       AdjustSize; //comando da classe Controls
  266.   end;
  267. end;
  268.  
  269. procedure TContainerFilter.RestrictSize(var msg: TMessage);
  270. begin
  271.   if (Assigned(FSpeedButton)) then
  272.   begin
  273.     FSpeedButton.Left  := cLeftSeedButton;
  274.     FSpeedButton.Width := (Self.Width div 3)-20;
  275.     Self.Font.Size := Trunc(15 * Self.Height/cHeigthPanelRigth);
  276.   end;
  277. end;
  278.  
  279. end.



Y sies posible ajustar eltamaño en función del tamaño de speedbuttons parade jarel panel Parent.
No sé si he explicado correctamente esta parte

He intentado algo


delphi
  1. procedure TContainerFilter.RestrictSize(var msg: TMessage);
  2. begin
  3.   if (Assigned(FSpeedButton)) then
  4.   begin
  5.     FSpeedButton.Left  := cLeftSeedButton;
  6.     FSpeedButton.Width := (Self.Width div 3)-20;
  7.     Self.Font.Size := Trunc(15 * Self.Height/cHeigthPanelRigth);
  8.   end;
  9. end;


Pero sin éxito.  :(

Saludos.
  • 0

#2 adriano_servitec

adriano_servitec

    Advanced Member

  • Miembros
  • PipPipPip
  • 91 mensajes
  • LocationCuritiba-Pr - Brasil

Escrito 09 enero 2011 - 06:19

¿Quién quiere ver el componente click en link
http://www.4shared.c...CompFilter.html

Puestos a disposición del (PAS, DCU y MDB) DATABASE ACCESS.

Para probar, basta con crear un nuevo form y llame al SENDER

Exemplo en Form:


delphi
  1. procedure TForm1.ContainerFilter1EditChange(Sender: TObject);
  2. var
  3.   Acesso: TContainerFilter;
  4. begin
  5.   Acesso := TContainerFilter.Create(Self);
  6.   Acesso.EditChange(Sender);
  7. end;
  8.  
  9. procedure TForm1.ContainerFilter1ButtonClick(Sender: TObject);
  10. var
  11.   Acesso: TContainerFilter;
  12. begin
  13.   Acesso := TContainerFilter.Create(Self);
  14.   Acesso.OnButtonClick(Sender);
  15. end;
  16.  
  17. procedure TForm1.ContainerFilter1BitBtnClick(Sender: TObject);
  18. var
  19.   Acesso: TContainerFilter;
  20. begin
  21.   Acesso := TContainerFilter.Create(Self);
  22.   Acesso.OnBitBtnClick(Sender);
  23. end;





  • 0




IP.Board spam blocked by CleanTalk.