Einzelnen Beitrag anzeigen

Willie1

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

AW: Balloon Tooltip

  Alt 7. Mär 2011, 16:32
Ich habe die Lösung gefunden.

Delphi-Quellcode:
Const
  TTM_SETTTTLEW = (WM_USER + 33); // Neu

function ShowBalloonTipHandle(hWnd: THandle; Icon: integer; Title, Text: string;
                         BackCL, TextCL: TColor;
                         RightTop: Boolean=false): THandle;
var
  ti: TOOLINFO;
  fl: Integer;
  b: pWideChar;
  pTitle: PWideChar;
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 := PWideChar(Title);

  Result := CreateWindow(TOOLTIPS_CLASS, nil,
    WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
    0, 0, 0, 0, hWnd, 0, HInstance, nil);
  if Result <> 0 then
  begin
    SetWindowPos(Result, 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(Result, TTM_SETTIPBKCOLOR, BackCL, 0);
    SendMessage(Result, TTM_SETTIPTEXTCOLOR, TextCL, 0);
    SendMessage(Result, TTM_ADDTOOL, 1, Integer(@ti));
    SendMessage(Result, TTM_SETTITLEW, Icon mod 4, Integer(pTitle)); //<-- Ändern
  end;
  FreeMem(b)
end;
Willie.
  Mit Zitat antworten Zitat