Delphi-PRAXiS
Seite 1 von 3  1 23      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Hints formatieren (https://www.delphipraxis.net/138023-hints-formatieren.html)

Vasco da Gama 2. Aug 2009 12:49


Hints formatieren
 
Hallo ihr Experten!
Bei Problemen habe ich bereits häufig die DP zur Hilfe gezogen und muss sagen, ihr seid fantastisch.

Meine Frage:
Wie kann ich in einem Delphi-Programm in Hints einzelne Wörter Fett(, Kursiv, farbig, etc.) schreiben?
Möglichst indem ich den Hint zur Laufzeit zuweise:
z.B.

Delphi-Quellcode:
  Label1.Hint := ''+#bold+'Hinweis:'+#none+'blablabla';
Weitere Frage: Kann man in einem Hint ein Bild einbauen?

Danke, mfG

[edit=mkinzler]Tag korrigiert Mfg, mkinzler[/edit]

patti 2. Aug 2009 12:54

Re: Hints formatieren
 
Da hilft wohl bloß selber malen. Habe über die DP folgenden Link gefunden: Link, vielleicht hilft dir das schonmal etwas weiter. Ansonsten gibt es vielleicht auch fertige Komponenten, die sowas unterstützen...

Patti

mkinzler 2. Aug 2009 12:54

Re: Hints formatieren
 
Einen normalen Hint gar nicht, da es sich um einen normalen String handelt. In D2009 gibt es aber einen neuen Hint, der auf HTML basiert (TCustomHint)
http://www.codegear.com/article/3808...sandComponents

Vasco da Gama 2. Aug 2009 13:00

Re: Hints formatieren
 
Danke euch beiden, das zweite werde ich probieren, wenn ich was nicht verstehe melde ich mich hier.

mfG :dp:

himitsu 2. Aug 2009 13:06

Re: Hints formatieren
 
Zitat:

Hint, der auf HTML basiert (TCustomHint)
TCustomHint ist "nur" die Hint-Basisklasse und kann kein HTML,
davon abgeleitet gibt es eigentlich nur noch TBalloonHint.

Also, wie schon gesagt, entweder du leitest dir was von TCustomHint ab und übernimmst selber das Zeichnen (ist garnicht so schwer und es gibt auch Threads dazu in der DP)

oder du nimmst eine Fremdkomponente, welche dieses schon kann.

patti 2. Aug 2009 13:22

Re: Hints formatieren
 
Zitat:

Zitat von himitsu
...und übernimmst selber das Zeichnen (ist garnicht so schwer und es gibt auch Threads dazu in der DP)...

Da du ganz normal auf ein Canvas zeichnen kannst (siehe mein Link oben) sollte das wirklich nicht zu schwer werden. Das einzige Problem könnte es sein, den Hint-Inhalt dynamisch zu ändern bzw. einen string mit Tags zu verwenden, so wie du es in deinem ersten Post geschrieben hattest. Aber bei Problemen einfach fragen.

Patti

himitsu 2. Aug 2009 13:30

Re: Hints formatieren
 
wir haben auch hier eine dp-eigene Hintklasse:
http://www.delphipraxis.net/internal...highlight=hint

und hier wird auch einer der HTML-Hints erwähnt
http://www.delphipraxis.net/internal...highlight=hint

Bernhard Geyer 2. Aug 2009 13:55

Re: Hints formatieren
 
Der Hint vom ElPack (LMD) kann Unicode (aktuell wird noch D6 unterstützt) und unterstützt HTML

Vasco da Gama 2. Aug 2009 17:46

Re: Hints formatieren
 
Ok, jetzt wollte ich mir mal die Grundversion von pattis link ansehen.
Ich habe die Unit folgendermasen gemacht:
Delphi-Quellcode:
unit GraphicHint;

interface

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

 Mit Hilfe des folgendes Codes lassen sich leicht beliebige
 Hints erstellen. Dazu muss nur dir Prozedur "Paint" den
 Wünschen entsprechend angepasst werden.

 With the following Code you can simply create custom hints.
 You just have to change the procedur "Paint".

 *********************************************************}

type
  TGraphicHintWindow = class(THintWindow)
    constructor Create(AOwner: TComponent); override;
  private
    FActivating: Boolean;
  public
    procedure ActivateHint(Rect: TRect; const AHint: string); override;
  protected
    procedure Paint; override;
  published
    property Caption;
  end;

  {...}

constructor TGraphicHintWindow.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  {
   Hier können beliebige Schrift Eigenschaften gesetzt
   werden.

   Here you can set custom Font Properties:
   }

  with Canvas.Font do
  begin
    Name := 'Arial';
    Style := Style + [fsBold];
    Color := clBlack;
  end;
end;

procedure TGraphicHintWindow.Paint;
var
  R: TRect;
  bmp: TBitmap;
begin
  R := ClientRect;
  Inc(R.Left, 2);
  Inc(R.Top, 2);

  {*******************************************************
   Der folgende Code ist ein Beispiel wie man die Paint
   Prozedur nutzen kann um einen benutzerdefinierten Hint
   zu erzeugen.

   The folowing Code ist an example how to create a custom
   Hint Object. :
   }

  bmp := TBitmap.Create;
  bmp.LoadfromFile('D:\hint.bmp');

  with Canvas do
  begin
    Brush.Style := bsSolid;
    Brush.Color := clsilver;
    Pen.Color  := clgray;
    Rectangle(0, 0, 18, R.Bottom + 1);
    Draw(2,(R.Bottom div 2) - (bmp.Height div 2), bmp);
  end;

  bmp.Free;
  //Beliebige HintFarbe
  //custom Hint Color
  Color := clWhite;

  Canvas.Brush.Style := bsClear;
  Canvas.TextOut(20, (R.Bottom div 2) - (Canvas.Textheight(Caption) div 2), Caption);
  {********************************************************}
end;

procedure TGraphicHintWindow.ActivateHint(Rect: TRect; const AHint: string);
begin
  FActivating := True;
  try
    Caption := AHint;
    //Höhe des Hints setzen setzen
    //Set the "Height" Property of the Hint
    Inc(Rect.Bottom, 14);
    //Breite des Hints setzen
    //Set the "Width" Property of the Hint
    Rect.Right := Rect.Right + 20;
    UpdateBoundsRect(Rect);
    if Rect.Top + Height > Screen.DesktopHeight then
      Rect.Top := Screen.DesktopHeight - Height;
    if Rect.Left + Width > Screen.DesktopWidth then
      Rect.Left := Screen.DesktopWidth - Width;
    if Rect.Left < Screen.DesktopLeft then Rect.Left := Screen.DesktopLeft;
    if Rect.Bottom < Screen.DesktopTop then Rect.Bottom := Screen.DesktopTop;
    SetWindowPos(Handle, HWND_TOPMOST, Rect.Left, Rect.Top, Width, Height,
      SWP_SHOWWINDOW or SWP_NOACTIVATE);
    Invalidate;
  finally
    FActivating := False;
  end;
end;

end.
Im Form Create meines Projektes:
Delphi-Quellcode:
HintWindowClass := TGraphicHintWindow;
Allerdings der Fehler:
Zitat:

[DCC Fehler] BTest.pas(40): E2003 Undeklarierter Bezeichner: 'TGraphicHintWindow'

DeddyH 2. Aug 2009 17:49

Re: Hints formatieren
 
Hast Du auch GraphicHint in der uses-Klausel hinzugefügt und befindet sich diese im Suchpfad?


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:13 Uhr.
Seite 1 von 3  1 23      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz