Autor Beitrag
juergen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Di 07.01.03 09:46 
Hallo,

wie kann ich in einem EDIT-Feld zur Laufzeit Text in verschiedenen FONTS eingeben ?

Ich möchte Sonderzeichen über ein Popupmenü einfügen mit folgendem Code

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:
procedure TForm1.FormContextPopup(Sender: TObject; MousePos: TPoint; 
  var Handled: Boolean); 
var 
  pos : tpoint; 
  x, y :integer; 
begin 

if ActiveControl <> nil then 
test    := ActiveControl; 
test_name:= test.Name; 
popupmenu1.Popup(mousepos.X+form1.left,mousepos.y+form1.top); 

end; 

procedure TForm1.Einfgen1Click(Sender: TObject); 
begin 

        form2.show; 

end; 

// Aus einer Listbox wird das Zeichen ausgewählt 
procedure TForm2.Button1Click(Sender: TObject); 
begin 
        form1.show; 
        hide; 
        try 
        for i:=0 to listbox1.Count-1 do 
        if listbox1.Selected[i] then 
        test.SetTextBuf(pchar(listbox1.Items[i])); 
        except 
        end; 
end;



Das EDIT-Feld sollte default den FONT ARIAL haben und die Sonderzeichen den FONT SYMBOL

DANKE

juergen
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 07.01.03 10:49 
Hallo Jürgen,

mit dem Edit-Feld geht das nicht. Nimm die RichEdit Komponente und schau mal in der Hilfe die Eingenschaften dieser Komponente an. Da gibt es unter anderem die Eingeschaft SelAttributes. Diese sollte Dir eigentlich helfen. Hier im Forum findest Du unter dem Begriff SelAttributes auch einige brauchbare Beispiele!

Gruß
TINO
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Di 07.01.03 14:52 
Danke Tino,

ich denke das es mit TRichEdit funktioniert

ABER

die aktive Komponente stelle ich mit
ausblenden Quelltext
1:
2:
3:
if ActiveControl <> nil then 
test    := ActiveControl; 
test_name:= test.Name;

fest.
Wenn ich nun mit SelAttributes die Schriftart zuweisen möchte funktioniert das nicht, weil TWinControl nicht die Eigenschaft SelAttributes besitzt.

Was kann ich tun ?

DANKE

juergen
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 07.01.03 17:16 
Die Variable test sollte dann vom Type tRichEdit sein.

Ungefähr so:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
if (ActiveControl <> nil) and (ActiveControl is tRichEdit) then
  Begin
    test := tRichEdit (ActiveControl); 
    test_name:= test.Name;
  End
Else
  Begin
    test := nil;
    test_name := '';
  End;


Gruß
TINO
juergen Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 87



BeitragVerfasst: Mi 08.01.03 12:19 
DANKE

jetzt läuft alles !

juergen