Autor Beitrag
Rool
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Di 08.04.03 15:43 
Wie kann ich den Text in meinem editfeld zentrieren???

_________________
MFG Rool
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: Di 08.04.03 18:13 
das ist mit der standart komponenten nicht möglich.
musst dir ne alternative runterladen die das kann.
(frag mich nich welche das kann) :oops:

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
fcg
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 360

WinXP
D3 Prof, D6 Pers
BeitragVerfasst: Di 08.04.03 18:43 
versuch es mit den length und width Eigenschaften des Edit-Feldes. Das irgendwie so hinzurechnen, das der string (mit nen paar leerzeichen vielleicht) in der mitte steht.

fcg

_________________
.: Wer für alles offen ist, kann nicht ganz dicht sein! :.
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Di 08.04.03 19:39 
Hallo Rool!

Im Prinzip können das die Windowskomponenten schon, nur muss man denen das vor dem Erstellen sagen und das kann Delphi leider nicht.
Die einzige Möglichkeit ist es, das Edit manuell zu erstellen (näheres zu finden in Luckie's nonVCL Hilfe):
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
const
IDC_EDIT = 1;

procedure TForm1.Button1Click(Sender: TObject);
begin
hwndEdit := CreateWindowEx(WS_EX_CLIENTEDGE, 'EDIT', 'Edit1', WS_VISIBLE or
  WS_CHILD or ES_CENTER, 10, 20, 400, 20, Handle, IDC_EDIT, hInstance, nil);
Zitat:
After the control has been created, these styles cannot be modified, except as noted.

Gruß wulfskin!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 08.04.03 21:40 
wulfskin hat folgendes geschrieben:
Die einzige Möglichkeit ist es, das Edit manuell zu erstellen (näheres zu finden in Luckie's nonVCL Hilfe):

Davon würde ich abraten, weil so erstellte Controls nicht mehr mit TAB angesteuert werden können. Diese Lektion musste ich beim Versuch lernen, ein IP-Control in ein VCL-Programm einbinden zu wollen.

Also, hier sollte man sich entweder eine passende Komponente besorgen, oder (entsprechende Kenntnisse vorausgesetzt) man erweitert die Standard-Komponente von Delphi um das entsprechende Stilattribut (hab´s nicht probiert, aber es wäre eine Idee), oder man schreibt das Programm, sofern möglich!, ohne VCL auf dem API-Weg.
wulfskin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1349
Erhaltene Danke: 1

Win XP
D5 Pers (SSL), D2005 Pro, C, C#
BeitragVerfasst: Di 08.04.03 22:06 
Hast ja wie immer recht, war ja nur so ne Idee ;)!

_________________
Manche antworten um ihren Beitragszähler zu erhöhen, andere um zu Helfen.
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 09.04.03 06:56 
Nix für ungut, wulfskin. Wollte bloß meinen Senf dazu geben. :)
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mi 09.04.03 10:41 
Hallo,

ich habe mir mal eine kleine Komponente gebastelt die das kann:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
type
  tAlignmentEdit = class(TEdit)
      private
        fAlignment: TAlignment;
      protected
        procedure SetAlignment (Value: TAlignment);
      public
        procedure CreateParams (var Params: TCreateParams); override;
      published
        property Alignment: TAlignment read FAlignment write SetAlignment
          default taLeftJustify;
    end;
    
procedure Register;

implementation

procedure tAlignmentEdit.CreateParams (var Params: TCreateParams);
const
  cAlignments : Array [TAlignment] of Longint = (ES_LEFT, ES_RIGHT, ES_CENTER);
begin
  inherited CreateParams (Params);
  Params.Style := Params.Style or cAlignments [FAlignment] or ES_MULTILINE;
end;

procedure tAlignmentEdit.SetAlignment;
begin
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    RecreateWnd;
  end;
end;

procedure Register;
begin
  RegisterComponents('Samples', [tAlignmentEdit]);
end;


Gruß
Tino
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mi 09.04.03 10:43 
@Tino: Wieso aktivierst du Multiline in einem Edit?!? :shock:

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Rool Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 211



BeitragVerfasst: Mi 09.04.03 15:13 
Titel: ...
jau, vielen dank für eure antworten.
das die komponente nicht mit tab angesteuert weden kann, ist gar nicht schlimm, sie ist eigentlich immer unsichtbar, nur wenn man doppelt auf n label klickte, legt sich das feld darüber und man kann die werte editieren. sobald der focus das control verlässt wird es wieder unsichtbar. deswegen: DANKE!!!

_________________
MFG Rool
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 10.04.03 10:14 
Motzi hat folgendes geschrieben:
@Tino: Wieso aktivierst du Multiline in einem Edit?!? :shock:

Ich hatte die Komponete einwenig vom Funktionumfang gekürzt (extra für die Frage von Rool) und habe es wohl übersehen. Hier der komplette Code der Komponente:
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
Type
  tAlignmentEdit = class(TEdit)
      private
        FAlignment: TAlignment;
        FMultiline: Boolean;
      protected
        procedure SetAlignment (Value: TAlignment);
        procedure SetMultiline (Value: Boolean);
      public
        procedure CreateParams (var Params: TCreateParams); override;
      published
        property Alignment: TAlignment read FAlignment write SetAlignment
          default taLeftJustify;
        property Multiline: Boolean read FMultiline write SetMultiline;
    End;

procedure tAlignmentEdit.CreateParams (var Params: TCreateParams);
const
  cAlignments : Array [TAlignment] of Longint = (ES_LEFT, ES_RIGHT, ES_CENTER);
  cMultiline  : Array [Boolean]    of Longint = (0, ES_MULTILINE);
begin
  inherited CreateParams (Params);
  Params.Style := Params.Style or cAlignments [FAlignment] or cMultiline [FMultiline];
end;

procedure tAlignmentEdit.SetAlignment;
begin
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    RecreateWnd;
  end;
end;

procedure tAlignmentEdit.SetMultiline (Value: Boolean);
begin
  if FMultiline <> Value then
  begin
    FMultiline := Value;
    RecreateWnd;
  end;
end;

Gruß
Tino
The_Unknown
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 16



BeitragVerfasst: Mo 14.04.03 20:44 
Nimm doch ein Memo, welches du zentriert setzt (das ist nich das problem). Leider kann der user einen Zeilenumbruch machen, den müsste man unterdrücken...

_________________
Ciao The_Unknown