Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: Windows API / MS.NET Framework API (https://www.delphipraxis.net/20-library-windows-api-ms-net-framework-api/)
-   -   Delphi Ballontipp erstellen (https://www.delphipraxis.net/88137-ballontipp-erstellen.html)

Matze 10. Mär 2007 19:26


Ballontipp erstellen
 
ErazerZ hat hier eine Funktion zum Anzeigen von Ballontipps veröffentlicht. Dabei handelt es sich um eine nonVCL-Version, die natürlich auch in Verbindung der VCL genutzt werden kann.

Delphi-Quellcode:
uses CommCtrl;

const
  TTS_BALLOON    = $40;
  TTI_NONE       = 0;
  TTI_INFO       = 1;
  TTI_WARNING    = 2;
  TTI_ERROR      = 3;
  TTM_SETTITLEA  = WM_USER + 32;

procedure SetHint(Handle: hWnd; dwIconType: DWORD; lpText, lpTitle: PChar; dwFlags: DWORD = TTS_BALLOON);
var
  TI: TToolInfo;
  trRect: TRect;
  hHint: THandle;
begin
  if (Handle <> 0) and (GetClientRect(Handle, trRect)) then
  begin
    hHint := CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nil, TTS_NOPREFIX or WS_POPUP or dwFlags,
                            Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),
                            Handle, 0, hInstance, nil);
    SetWindowPos(hHint, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
    ZeroMemory(@TI, sizeof(TToolInfo));
    with TI do
    begin
      cbSize := sizeof(TToolInfo);
      hwnd := Handle;
      uId := Handle;
      hInst := hInstance;
      uFlags := TTF_SUBCLASS or TTF_IDISHWND;
      Rect := trRect;
      lpszText := lpText;
    end;
    SendMessage(hHint, TTM_ADDTOOL, 0, LPARAM(@TI));
    SendMessage(hHint, TTM_SETTITLEA, dwIconType, LPARAM(lpTitle));
  end;
end;
Ein Beispielaufruf (VCL):

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  SetHint(Button1.Handle, TTI_INFO, 'My Text ...', 'Info');
end;
Suchbegriffe: Ballontip, Hint, Ballonhint

[edit=Chakotay1308]Kleine Code-Korrektur. Mfg, Chakotay1308[/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 15:59 Uhr.

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