Hi friends again. Can you tell me how I will justify right edit box components in delphi. Ok I have found the memo to justify right for my input variables. But when I delete the text inside the memo components. Some of strings in memo components are not coming to labels in my display form. For example : when I enter the 5 integer variables to memo component such as 1,2,3,4 and 5 but when I click button in main form. the 5 labels such as label1,label2, label3 etc. would carry these 5 input variables inside memo component. but I saw nothing in the text of labels. Such as Label1.Text:='1', Label2.Text:='2', but
Label3.text :=' ', Label4.text:=' ',

At this point we'll need to see your code to understand how you are trying to do things...

hi duoas dont go anywhere I will show codes now to you...

for i:=1 to 82 do
TLabel(DisplayForm.FindComponent('Label'+inttostr(i))).caption:=
TMemo(Anaform.FindComponent('Memo'+inttostr(i)))).Lines[0];

Member Avatar for Micheus

Can you tell me how I will justify right edit box components in delphi.

You must to install some new component with this option or create them by your self.
This code can be adapted to be installed like a component, but You can just use in your form source and create these edits at run-time:

type
  TNewEdit = class(TEdit)
  private
    procedure CreateParams(var Params: TCreateParams); override;
  end;
...

procedure TNewEdit.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style or ES_LEFT; // ES_CENTER, ES_RIGHT
end;

so, to create at run-time you put in the Form at OnCreate event:

procedure TForm1.FormCreate(Sender: TObject);
begin
  with TNewEdit.Create(Self) do
  begin
    Name := 'Edit1';
    Parent := Self;
    Top := 8;
    Left := 24;
  end;
  ... // create others edits 
end;

The good choice could be create a new component and install them. I can't write a code and to explain about this now.

Bye

Ok Micheus, thank you for your help. I will try to improve my program destroying my memos, with your code examples.

come on Micheus pls explain with a code about that. I will need this worth information that related to creation of a new component and installing it....

Member Avatar for Micheus

come on Micheus pls explain with a code about that. I will need this worth information that related to creation of a new component and installing it....

type
  TNewEdit = class(TEdit)
  private
    procedure CreateParams(var Params: TCreateParams); override;
  end;
...

here you declare a new class from TEdit. All properties will be inherited from tham, You need just to override some methods to generete the new component.

procedure TNewEdit.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.Style := Params.Style or ES_LEFT; // ES_CENTER, ES_RIGHT
end;

The method CreateParams is called before the component be created. It provide a way to modify some window characteristics - take a look at Win32 help and search for CreateWindow API function.

To create your own component, put this code in an exclusive unit and add some properties like Alignment to be used into CreateParams to define appropriate text align. This property will be published and You will can modify tham at design-time.
Some thing like:

unit MyEdit;
interface
uses
    StdCtrls,  // to refer TEdit
    Classes;  // to refer TAlignment
type
  TNewEdit = class(TEdit)
    FAlignment :TAlignment;
  private
    procedure CreateParams(var Params: TCreateParams); override;
  published
    Alignment :TAlignment read FAlignment write FAlignment;
  end;

procedure Register;  // exporting procedure Register

implementation

procedure TNewEdit.CreateParams(var Params: TCreateParams);
begin
  inherited;
  case FAlignment of
    taLeftJustify :  
      Params.Style := Params.Style or ES_LEFT; 
    taCenter :
      Params.Style := Params.Style or ES_CENTER;
    taRightJustify :
      Params.Style := Params.Style or ES_RIGHT;
  end;
end;
...

You must to define a register procedure to register the component. This is made using RegisterComponents procedure.
You will define the destination pallete (in this example, Additional) where it be placed.
Some thing like:

...
// and at last on unit...
procedure Register;
begin
  RegisterComponents('Additional', [TNewEdit]);
end;

end.

It by this way. I don't sure that the code is 100% right, so forgives me some error. :icon_wink:

I hope help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.