Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2025-07

custom component problems

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Larry Dalton
unit string_panel;
{$MODE Delphi}
interface

uses
LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

  ExtCtrls,StdCtrls;
type
  Tstring_panel = class(TPanel)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
  Constructor Create(AOwner:TComponent);override;
  Procedure textred(Sender:TObject);
  procedure textwhite(Sender:TObject);
  procedure import_string(import_string:string);
  procedure export_string(var export_string:string);
  Destructor Destroy;override;
    { Public declarations }
  published
   StringEdit1:TEdit;
    { Published declarations }
  end;
procedure Register;
implementation
procedure Register;
begin
  RegisterComponents('Dalton', [Tstring_panel]);
end;
Constructor Tstring_panel.Create;
begin
inherited create(AOwner);
Alignment:=taLeftJustify;
Height:=29;
Width:=325;
Font.Style:=[fsBold];
Font.Color:=clwhite;
Color:=clBlue;
stringEdit1:=TEdit.Create(stringEdit1);
with stringEdit1 do begin
Left:=85;
Width:=233;
Parent:=self;
font.Color:=clblack;
Text:='';
Top:=3;
OnEnter:=textred;
OnExit:=textwhite;
end;{ends with stringedit1}
end;
Destructor Tstring_panel.Destroy;
begin
stringEdit1.Destroy;
inherited destroy;

end;{ends destructor destroy}

procedure Tstring_panel.textred;
begin
with Sender as TObject do begin
stringEdit1.Color:=clred;
stringEdit1.Font.Color:=clwhite;
end;
end;
procedure Tstring_panel.textwhite;
begin
with Sender as TObject do begin
stringEdit1.Color:=clwhite;
stringEdit1.Font.Color:=clblack;
end;
end;
procedure TSTring_panel.import_string;
begin
stringEdit1.Text:=import_string;
end;{ends import_string}

procedure Tstring_panel.export_string;
begin
export_string:=stringEdit1.Text;
end;{ends export string}
end. That is a custom component I have used for years on several applications. There apparently is a resizing happening on my laptop, because width is set at 325, but when I put on on a tform, it is resizing to 975. The problem is that the stringEdit1 doesnt resize, so it is actually smaller in relation to the tpanel, and the stringedit1.left doesnt resize either, so it moves everything to the left. Help, please. This is on a laptop with a 17" screen. It doesnt resize on my desktop.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20250729/e2e9054f/attachment.htm>

Reply by email

Werner Pamler
to Larry Dalton
Larry Dalton wrote 7 lines
There apparently is a resizing happening on my laptop, because width is set at 325, but when I put on on a tform, it is resizing to 975. The problem is that the stringEdit1 doesnt?resize, so it is actually smaller in relation to the tpanel, and the stringedit1.left?doesnt?resize either, so it moves everything to the left. Help, please. This is on a laptop with a 17" screen. It doesnt?resize on my desktop.

Resizing could be caused when one monitor has a larger pixel density (Pixels per inch) than the other one. Just for testing, turn off LCLscaling in the project options.

The? right side of the stringEdit1 does not follow the right side of the stringpanel because it is not anchored to it. In constructor, where stringEdit1 is created add a line stringEdit1.Anchors := StringEdit1.Anchors + [akRight].

Reply by email

Larry Dalton
to Werner Pamler

Thanks .

On Tue, Jul 29, 2025 at 13:33 Werner Pamler via lazarus <

Show quoted text 26 lines
wrote: Am 29.07.2025 um 15:10 schrieb Larry Dalton via lazarus: > There apparently is a resizing happening on my laptop, because width > is set at 325, but when I put on on a tform, it is resizing to 975. > The problem is that the stringEdit1 doesnt resize, so it is actually > smaller in relation to the tpanel, and the > stringedit1.left doesnt resize either, so it moves everything to the > left. Help, please. This is on a laptop with a 17" screen. It > doesnt resize on my desktop. Resizing could be caused when one monitor has a larger pixel density (Pixels per inch) than the other one. Just for testing, turn off LCLscaling in the project options. The right side of the stringEdit1 does not follow the right side of the stringpanel because it is not anchored to it. In constructor, where stringEdit1 is created add a line stringEdit1.Anchors := StringEdit1.Anchors + [akRight]. -- _______________________________________________ lazarus mailing list https://lists.lazarus-ide.org/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20250729/97b8c431/attachment.htm>

Reply by email