Autor Beitrag
Alex
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Mi 16.02.05 11:02 
Ich suche das Zeichen für Delta und hab es auch gefunden im ISO 8859-7 neugriechischen Zeichensatz. das Problem ist aber wenn ich: #196 angebe kommt das Zeichen Ä.
Ä ist im Zeichensatz 8859-1 Latin 1 untergebracht.
Muß ich vorher was umstellen um das Delta Zeichen darstellen zu können ? Oder gibt es eine andere Möglichkeit ?

Alex
wwwdirk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D6 Prof / D2005 Prof
BeitragVerfasst: Mi 16.02.05 11:53 
Hallo,
vielleicht sowas in der Art:
ausblenden Delphi-Quelltext
1:
2:
  Edit1.Font.Name := 'Symbol';
  Edit1.Text := 'd';

Das Funktioniert auch mit Label, allerdings gilt die eingestellte Schriftart für das ganze Feld, d.h. man kann auf diese Art und Weise nicht das Delta-Zeichen mit normalen Zeichen kombinieren. Ich hab's bisher nur mal in einem Canvas-Objekt implementiert, da geht's dann, da mit TextOut sofort ein Zeichen in der eingestellten Schriftart gezeichnet wird. Anschliessend kann man dann wieder auf eine andere Schriftart umschalten und "weiterschreiben"!

Viele Grüße

Dirk
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Mi 16.02.05 18:50 
Danke für die Antwort aber
bei mir sieht das so aus:
ausblenden Delphi-Quelltext
1:
2:
Label12.Caption:= (#196)+ 'P von Tc - To - Druckverlust Armaturen(2 Bar) ='
+ Format('%f',[(PC-Po)-Pa])+' bar';


bei (#196) steht dann ein Ä,
möchte aber gerne ein Delta, also ein kleines Dreieck.
Gruß, Alex

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 16.02.05 19:21 
Titel: Unicode
Leider unterstützt TLabel kein Unicode. Hier ist eine (semi-seriöse) Erweiterung von TLabel, welches Unicode unterstützt. Es soll keine komplette oder saubere Erweiterung sein. Es ist einfach ein Lösungsvorschlag. :D

Wie du siehst ist "TemperaturWideLabel" privat in Form1 deklariert. Du könntest im Prinzip auch eine Delphikomponente draus basteln, sodass du dann das Label auch im Delphi-Editor platzieren könntest. Wenn du keine eigene Komponente draus basteln willst, musst du halt die Position in FormCreate selbst setzen.
Hoffentlich reicht es für deine Bedürfnisse!

Gruss

ausblenden volle Höhe Delphi-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:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type

{ kleine Erweiterung von TLabel }
  TWideLabel = class(TLabel)
   private
    FWideText : WideString;
    procedure DoDrawText(var Rect: TRect; Flags: Longint); override;
    procedure SetWideText(const Value: WideString);
   published
    property WideText : WideString read FWideText write SetWideText;
  end;

{ Form }
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    TemperaturWideLabel : TWideLabel;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TWideLabel }

procedure TWideLabel.DoDrawText(var Rect: TRect; Flags: Integer);
Var WideText : WideString;
begin
  WideText := FWideText;
  if (Flags and DT_CALCRECT <> 0and ((WideText = ''or ShowAccelChar and
    (WideText[1] = '&'and (WideText[2] = #0)) then WideText := WideText + ' ';
  if not ShowAccelChar then Flags := Flags or DT_NOPREFIX;
  Flags := DrawTextBiDiModeFlags(Flags);
  Canvas.Font := Font;
  if not Enabled then
  begin
    OffsetRect(Rect, 11);
    Canvas.Font.Color := clBtnHighlight;
    DrawTextW(Canvas.Handle, @WideText[1], Length(WideText), Rect, Flags);
    OffsetRect(Rect, -1, -1);
    Canvas.Font.Color := clBtnShadow;
    DrawTextW(Canvas.Handle, @WideText[1], Length(WideText), Rect, Flags);
  end
  else
    DrawTextW(Canvas.Handle, @WideText[1], Length(WideText), Rect, Flags);
end;

procedure TWideLabel.SetWideText(const Value: WideString);
begin
  FWideText := Value;
  if AutoSize then
   AdjustBounds;
  Invalidate;
end;

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
begin
 Canvas.Font.Name := 'Arial'// Am besten wählst du für das ganze Form einen Font der Unicode unterstützt

 TemperaturWideLabel := TWideLabel.Create(Form1);
 with TemperaturWideLabel do // TempoeraturWideLabel positionieren und Text setzen. 
 begin
  Parent := Form1;
  Top := 10;
  Left := 10;
  WideText := #$394 + WideString('2°C'); // "Delta 2°C"
 end;
end;

end.
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 10:51 
Danke für die Hilfe, aber bei mir funktioniert die Lösung leider nicht
komme aber nicht dahinter warum. :cry:
Kann man den Zeichensatz nicht umstellen, das Zeichen ausgebeben und wieder
zurückstellen.

Gruß Alex
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Do 17.02.05 11:07 
Alex hat folgendes geschrieben:
Kann man den Zeichensatz nicht umstellen, das Zeichen ausgebeben und wieder
zurückstellen.

Es gibt 'ne einfachen Weg und eine etwas komplexere Lösung. Interessant wäre, wo du dieses Zeichen benutzen willst. Und ob vor oder nach dem Zeichen noch Buchstaben kommen.

_________________
Ciao, Sprint.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 17.02.05 11:10 
Hmm, welche Delphi-Version benützst du? Arbeitest du unter Windows 98?
Sonst versuch mal Font.CharSet zu ändern. Du kannst natürlich nicht einfach ein Zeichen ausgeben und den CharSet wieder zurückstellen. Entweder alles oder gar nichts.
Gruss

(Edit: Ok du benützst D5, steht ja in deinem Profil. Ich hab's leider nur auf Delphi7 testen können und dort funktioniert's. Was funktioniert genau nicht?)


Zuletzt bearbeitet von delfiphan am Do 17.02.05 11:16, insgesamt 1-mal bearbeitet
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 11:14 
ich möchte es in einem Label ausgeben, es solln nach dem Zeichen noch Buchstaben kommen
zb. Delta P oder Delta T

Gruß, Alex
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 11:18 
habe D5 und windows XP
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 11:24 
er meckert bei 'Variants'
wenn ich das rausnehme dann kommt 'Zugriffsverletzung'
und es geht gar nix mehr
Gruß, Alex
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 17.02.05 11:26 
Ich kenne leider D5 nicht so genau. Der Windows-API Befehl für WideString Ausgabe ist "DrawTextW", damit habe ich das TLabel auch erweitert. Ich müsste schon wissen, was genau nicht klappt.

Kriegst du eine Fehlermeldung, dass "DrawTextW" nicht deklariert ist? Dann schreibe mal folgendes dazu:

function DrawTextW(hDC: HDC; lpString: PWideChar; nCount: Integer; var lpRect: TRect; uFormat: UINT): Integer; stdcall; external 'user32.dll' name 'DrawTextW';

Kriegst du ein Fragezeichen oder ein leeres Kästchen, statt das Delta? Dann musst du das Font des TWideLabel explizit auf "Arial" stellen (mit TemperaturWideLabel.Font.Name := "Arial;)

Ich frage mich, was sonst noch schief laufen könnte? Wenn TLabel in D5 anders implementiert ist dann geht die Erweiterung leider ebenfalls nicht.

Edit: Hast du mal probiert den Source code zu kopieren, ausser die Uses Zeile. Versuch mal die Uses Zeile zu nehmen, die dir dein D5 kreiert.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 17.02.05 12:56 
Mein letzter Versuch. Wenn das nicht haut, sind die andern gefordert! Es ist leider immer noch keine wirklich saubere Erweiterung von TLabel. Hab das
ganze ein bisschen erweitert und eine Komponente draus gemacht. Variants ist auch nicht mehr in der Uses-Klausel.

Wie dem auch sei: Speichere folgenden Source ab als WideLabel.pas und installier sie als Komponente.
(Component -> Install Component -> Into new package -> Unit file name "C:\hier das korrekte verzeichnis\WideLabel.pas", gib dem Package nen Namen und drück OK. Das Package musst du dann kompilieren, installieren und speichern)

Danach solltest die Komponente WideLabel im Tab "Standard" drin haben. Füge so ein WideLabel in dein Projekt hinzu. Dann kannst du mit folgendem Code den gewünschten Effekt kriegen:
ausblenden Delphi-Quelltext
1:
2:
 WideLabel1.Font.Name := 'Arial';
 WideLabel1.Caption := #916+WideString('P');


Gruss

ausblenden volle Höhe Delphi-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:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
unit WideLabel;

interface

uses
  Windows, Messages, Classes, Graphics, Controls, StdCtrls;

type
  TWideLabel = class(TLabel)
   private
    FWideText : WideString;
    procedure SetWideText(const Value: WideString);
    procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
    function GetText: TCaption; reintroduce;
   protected
    procedure DoDrawText(var Rect: TRect; Flags: Longint); override;
   published
    property Caption : WideString read FWideText write SetWideText;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Standard', [TWideLabel]);
end;

function TWideLabel.GetText: TCaption;
var
  Len: Integer;
begin
  Len := GetTextLen;
  SetString(Result, PChar(nil), Len);
  if Len <> 0 then GetTextBuf(Pointer(Result), Len + 1);
end;

procedure TWideLabel.CMTextChanged(var Message: TMessage);
begin
 Caption := GetText;
 inherited;
end;

procedure TWideLabel.DoDrawText(var Rect: TRect; Flags: Integer);
Var WideText : WideString;
begin
  WideText := FWideText;
  if (Flags and DT_CALCRECT <> 0and ((WideText = ''or ShowAccelChar and
    (WideText[1] = '&'and (WideText[2] = #0)) then WideText := WideText + ' ';
  if not ShowAccelChar then Flags := Flags or DT_NOPREFIX;
  Flags := DrawTextBiDiModeFlags(Flags);
  Canvas.Font := Font;
  if not Enabled then
  begin
    OffsetRect(Rect, 11);
    Canvas.Font.Color := clBtnHighlight;
    DrawTextW(Canvas.Handle, @WideText[1], Length(WideText), Rect, Flags);
    OffsetRect(Rect, -1, -1);
    Canvas.Font.Color := clBtnShadow;
    DrawTextW(Canvas.Handle, @WideText[1], Length(WideText), Rect, Flags);
  end
  else
    DrawTextW(Canvas.Handle, @WideText[1], Length(WideText), Rect, Flags);
end;


procedure TWideLabel.SetWideText(const Value: WideString);
begin
  FWideText := Value;
  if AutoSize then
   AdjustBounds;
  Invalidate;
end;

end.
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 14:04 
Hallo, Delfiphan

Komponente ist installiert, doch leider kommt die Fehlermeldung :

Fehler: Zugriffsverltzung bei Adresse 0086E06E im Modul Dcc50.dll
Lesen von Adresse 00000009
Dann muß man Delphi neu Starten....
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 17.02.05 14:09 
Sorry dann kann ich nicht weiterhelfen. Es handelt sich wohl um ein Delphi5 compiler bug.
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 14:20 
Danke erstmal für Deine Hilfe
Hab festgestellt, daß er sich bei dem
ausblenden Quelltext
1:
 WideLabel1.Caption := #916+WideString('P');					

aufhängt,
bei
ausblenden Quelltext
1:
WideLabel1.Caption := #916;					

funktioniert es,
es kommt ein Senkrechter Strich...im Label.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 17.02.05 14:24 
Senkrechter Strich bedeutet normalerweise, dass du den falschen Font gewählt hast. Kästchen oder Balken stehen für undefinierte Zeichen. Hast du den Font auf Arial gestellt? ...
Versuch mal folgendes:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
Var
 S : WideString;
begin
 S := '_P';
 Word(S[1]) := 916// ersetze das erste Zeichen durch das Delta
 WideLabel1.Font.Name := 'Arial';
 WideLabel1.Caption := S;
end;


Vielleicht schaffen wir es doch noch.... ;)
Alex Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28


D5 Epr
BeitragVerfasst: Do 17.02.05 14:51 
:D super jetzt geht's
war eine schwere Geburt,
Danke nochmal
Gruß, Alex