Einzelnen Beitrag anzeigen

Willie1

Registriert seit: 28. Mai 2008
618 Beiträge
 
Delphi 10.1 Berlin Starter
 
#4

AW: Balloon Tooltip

  Alt 21. Feb 2011, 08:56
wie beschrieben funktioniert mein Balloon Tip in einem Programm ohne Tochterfenster. Fehlerbeschreibung: in einem Tochterfenster (statisch oder dynamisch) passiert einfach nichts!

W.

Delphi-Quellcode:
procedure ShowBalloonTip(hWnd: THandle; Icon: integer; Title, Text: string;
                         BackCL, TextCL: TColor; RightTop: Boolean=false);
var
  hWndTip: THandle;
  ti: TOOLINFO;
  fl: Integer;
  b: pWideChar;
  pTitle: PChar;
begin
  if RightTop then
    fl:=TTF_TRANSPARENT or TTF_SUBCLASS
  else
    fl:=TTF_CENTERTIP or TTF_TRANSPARENT or TTF_SUBCLASS;
  GetMem(b,2*256);
  pTitle := PChar(Title);

  hWndTip := CreateWindow(TOOLTIPS_CLASS, nil,
    WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
    0, 0, 0, 0, hWnd, 0, HInstance, nil);
  if hWndTip <> 0 then
  begin
    SetWindowPos(hWndTip, HWND_TOPMOST, 0, 0, 0, 0,
      SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
    ti.cbSize := SizeOf(ti);
    ti.uFlags := fl;
    ti.hwnd := hWnd;
    ti.lpszText := StringToWideChar(Text, b, 2*356);
    Windows.GetClientRect(hWnd, ti.rect);
    SendMessage(hWndTip, TTM_SETTIPBKCOLOR, BackCL, 0);
    SendMessage(hWndTip, TTM_SETTIPTEXTCOLOR, TextCL, 0);
    SendMessage(hWndTip, TTM_ADDTOOL, 1, Integer(@ti));
    SendMessage(hWndTip, TTM_SETTITLE, Icon mod 4, Integer(pTitle));
  end;
  FreeMem(b);
end;
  Mit Zitat antworten Zitat