At this point we'll need to see your code to understand how you are trying to do things...
Duoas
Postaholic
2,043 posts since Oct 2007
Reputation Points: 1,140
Solved Threads: 229
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
Micheus
Junior Poster in Training
72 posts since Jun 2006
Reputation Points: 10
Solved Threads: 4
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.
Micheus
Junior Poster in Training
72 posts since Jun 2006
Reputation Points: 10
Solved Threads: 4