AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Nachricht/Ereignis wenn Tooltips aktiviert werden
Thema durchsuchen
Ansicht
Themen-Optionen

Nachricht/Ereignis wenn Tooltips aktiviert werden

Ein Thema von fylo · begonnen am 25. Feb 2008 · letzter Beitrag vom 27. Feb 2008
Antwort Antwort
API

Registriert seit: 18. Apr 2004
637 Beiträge
 
#1

Re: Tooltips per Code aktivieren

  Alt 25. Feb 2008, 19:18
Hallo,

Einen Hint kannst du mit ActivateHint() anzeigen.

Delphi-Quellcode:
  private
    { Private declarations }
    FMyHint: THintWindow;
    function RevealHint(Control: TControl; Color: TColor): THintWindow;
    procedure RemoveHint(var Hint: THintWindow);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// Hint Fenster anzeigen

function TForm1.RevealHint(Control: TControl; Color: TColor): THintWindow;
var
  ShortHint: string;
  AShortHint: array[0..255] of Char;
  HintPos: TPoint;
  HintBox: TRect;
  HeightOfText: Integer;
begin
   { Hint Fenster erstellen falls noch nicht }
  if not Assigned(Result) then
    Result := THintWindow.Create(Control);
  if Color <> 0 then
    Result.Color := Color;
  ShortHint := GetShortHint(Control.Hint);
   { Hint Fenster Position & Größe: }
  HintPos := Control.ClientOrigin;
  Inc(HintPos.Y, Control.Height + 6);
  HintBox := Bounds(0, 0, Screen.Width, 0);
  HeightOfText := DrawText(Result.Canvas.Handle, StrPCopy(PChar(@AShortHint), ShortHint),
    -1, HintBox, DT_CALCRECT or DT_LEFT or DT_WORDBREAK or DT_NOPREFIX);
  OffsetRect(HintBox, HintPos.X, HintPos.Y);
  Inc(HintBox.Right, 6);
  Inc(HintBox.Bottom, 2);
{ Hint zeigen }
  Result.ActivateHint(HintBox, ShortHint);
end;

// Hint verstecken
procedure TForm1.RemoveHint(var Hint: THintWindow);
begin
  if Assigned(Hint) then
  begin
    Hint.ReleaseHandle;
    Hint.Free;
    Hint := nil;
  end;
end;

// Test: Hint von Button2 anzeigen bei Klick auf Button1
procedure TForm1.Button1Click(Sender: TObject);
begin
  FMyHint := RevealHint(Button2, clInfoBk);
  Application.Processmessages;
  Sleep(Application.HintHidePause);
  RemoveHint(FMyHint)
end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:17 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz