Autor Beitrag
CodexX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Mi 06.02.08 23:37 
Ich würde gerne Text in einem Hint fett hervorheben können. Von Haus aus geht das wohl nicht und große Komponenten möchte ich deswegen nicht unbedingt einbingen müssen.
Was ist die einfachste Methode? Vielleicht wurde das schon irgendwo beantwortet, ich habe leider nichts Passendes gefunden...
Calculon
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 676

Win XP Professional
Delphi 7 PE, Delphi 3 PRO
BeitragVerfasst: Do 07.02.08 00:07 
Hi,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.FormCreate(Sender: TObject);
begin
  screen.HintFont.Style := [fsbold];
end;


Gruß

Calculon
--

_________________
Hallo Mutti
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Do 07.02.08 00:25 
Hallo,

wenn Du nur Teile fett hervorheben möchtest, hilft das weiter:
swissdelphicenter: [url=www.swissdelphicente...php?id=1390]...einen grafischen Hint erstellen?
[/url]

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 07.02.08 00:43 
Mir geht es tatsächlich darum, nur bestimmte Testteile fett darzustellen.
Also etwas wie:
Zitat:
Titel1
Ein bisschen Text

Titel2
Noch mehr Text


Aber in dem Beispiel bei SDC sehe ich auch nur die Möglichkeit, diese Eigenschaften für das ganze Hint-"Fenster" festzulegen.
Ich bräuchte die Stilfestlegung eben gezielt...
Bernhard Geyer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 721
Erhaltene Danke: 3



BeitragVerfasst: Do 07.02.08 08:22 
user profile iconCodexX hat folgendes geschrieben:
Aber in dem Beispiel bei SDC sehe ich auch nur die Möglichkeit, diese Eigenschaften für das ganze Hint-"Fenster" festzulegen.
Ich bräuchte die Stilfestlegung eben gezielt...

Entweder viel selbst implementieren oder fertige Komponenten wie vom ElPack verwenden die hier HTML-Code unterstützen.
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 07.02.08 17:46 
user profile iconBernhard Geyer hat folgendes geschrieben:
Entweder viel selbst implementieren ...

Ja, daran scheiter's ja leider gerade.

user profile iconBernhard Geyer hat folgendes geschrieben:
... oder fertige Komponenten wie vom ElPack verwenden die hier HTML-Code unterstützen.

149$ für eine Fett-Markierung ...


Also ich sehe ja in dem SDC Beispiel, wie man die Klasse ableiten kann, aber ich habe leider keine Idee, wie man die Markierungen Zeilenweise oder Wortweise festlegen könnte. Deswegen ja meine Bitte um Hilfe...
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 07.02.08 18:01 
In Paint kannst du den Text komplett selber schreiben. Also auch unterschiedlich formatieren:

ausblenden 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:
var i, X, Y: Integer;
const
  BoldChar = '$' // Zeichen für fett an- und ausmachen

Canvas.Font.Style := Canvas.Font.Style - [fsBold]; // Nicht fett am anfang
X := 0// Linke Position auf null

for i := 1 to Length(Caption) do
  if Caption[i] = BoldChar then                         // Wenn Fett-Zeichen
  begin
    if not ([fsBold] in Canvas.Font.Style) then         // Wenn noch nicht fett,
      Canvas.Font.Style = Canvas.Font.Style + [bsBold]  // dann fett;
    else                                                // sonst
      Canva.sFont.Style = Canvas.Font.Style - [bsBold]; // nicht fett.
  end
  else if Caption[i] = #13 then          // Wenn Zeilenumbruch
  begin
    inc(Y, Canvas.Font.Height);          // Um Zeilenhöhe erhöhen
    X := 0;                              // X wieder auf links setzen
  end
  else                                   // Wenn anderes Zeichen
  begin
    Canvas.TextOut(X, Y, Caption[i];     // Zeichen an Position anzeigen
    inc(X, Canvas.TextWidth(Caption[i]); // Position erneuern
  end;


Zuletzt bearbeitet von Yogu am So 10.02.08 20:17, insgesamt 4-mal bearbeitet
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 07.02.08 19:35 
OK, wir kommen der Sache näher. :)
Die gewünschten Bereiche werden nun richtig markiert.
Leider geht die Möglichkeit des Zeilenumbruchs in einem Textstring verloren:

ausblenden Delphi-Quelltext
1:
Caption := 'Erste Zeile'+#13#10+'Zweite Zeile'					

ignoriert den Zeilenumbruch einfach. Wie kriegt man das wieder hin?
Ja, man könnte das TextOut für jede gewünschte Zeile neu aufrufen, aber der gesamte Text soll ja nur in einem Textstring drinstehen und damit sollte Caption auch nur ein Mal von TextOut ausgegeben werden.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 07.02.08 19:40 
Ok, das hab ich vergessen. Habs hinzugefügt, siehe mein erster Post.
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 07.02.08 21:54 
edit: Okay, passt. Danke sehr!
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 07.02.08 22:52 
Gut, das funktioniert jetzt auf der MainForm und auf den UnterForms, aber leider nicht beim Tooltipp des TrayIcons (TCoolTrayIcon). Wie weise ich das dem explizit zu?
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 07.02.08 22:56 
Ich glaube, die Hints kannst du da nicht verändern. So wie das aussieht, regelt Windows das komplett Du kannst aber auf das MouseMove-Ereignis reagieren und deinen Toolip manuell anzeigen lassen.
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Do 07.02.08 23:05 
Hm, das ist ja doof. Na dann versuche ich mal herauszufinden, wie man einen Tooltipp gezielt an einer Stelle anzeigen kann...
Zorro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 76

Win 2000, Win XP Pro
Delphi 7 Architect
BeitragVerfasst: So 10.02.08 16:07 
user profile iconYogu hat folgendes geschrieben:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
...
    if Canvas.Font.Style = [] then  // Wenn noch nicht fett,
      Canvas.Font.Style = [bsBold]  // dann fett;
    else                            // sonst
      Canva.sFont.Style = [];       // fett.


Würde ich noch verfeinern, damit eventuelle vorhandene (andere) Styles (zB kursiv) nicht verlorengehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
if not (Canvas.Font.Style >= [fsBold] then          // wenn noch nicht fett
  Canvas.Font.Style := Canvas.Font.Style + [fsBold] // dann fett
else
  Canvas.Font.Style := Canvas.Font.Style - [fsBold] // nix mehr fett


Greetz
Zorro
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 10.02.08 20:16 
Gut, user profile iconZorro, das ist eine gute Idee. :zustimm: Ich habs mal ergänzt. So langsam wird die Funktion noch richtig professionell ;)

Allerdings hab ich noch was verbessern müssen: Du darfst nicht einfach mit

ausblenden Delphi-Quelltext
1:
if Canvas.Font.Style = [] then {...}					

kontrollieren, ob noch nicht fett geschrieben wird, sondern auf das nichtvorkommen von fsBold prüfen:

ausblenden Delphi-Quelltext
1:
if not ([fsBold] in Canvas.Font.Style) then {...}					
CodexX Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Fr 15.02.08 00:42 
Hm, ich komme nicht weiter. Gibts da jetzt eine Möglichkeit das Hint beim Erscheinen im Tray abzufangen und statt dessen sein eigenes anzuzeigen? Sowas wie onHintPopup habe ich leider nicht gefunden und dann müsste es ja noch an die richtige Stelle... Eieiei...
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Fr 15.02.08 16:46 
ausblenden 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:
type
  TForm1 = class(TForm)
  {...}
  private
    procedure WndProc(var Message: TMessage); override;
  {...}
  end;

{...}

procedure TForm1.WndProc(var Message: TMessage);
var Point: TPoint;
begin
  case Message.Msg of
    WM_TRAYMSG:
      case Message.lParam of
        WM_MOUSEMOVE:
        begin
          GetCursorPos(Point);
          { Hint anzeigen }
        end;
      end;
    else
      inherited WndProc(Message);
  end;
end;

Eigentlich müsste es klappen.

Grüße,
Yogu