Add How to create balloon tooltips with API


uses
commctrl;

...

const
TTS_BALLOON = $40;
TTM_SETTITLE = (WM_USER + 32);

var
Form1: TForm1;
hTooltip: Cardinal;
ti: TToolInfo;
buffer : array[0..255] of char;

...

procedure CreateToolTips(hWnd: Cardinal);
begin
hToolTip := CreateWindowEx(0, 'Tooltips_Class32', nil, TTS_ALWAYSTIP or TTS_BALLOON,
Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT), hWnd, 0, hInstance, nil);
if hToolTip 0 then
begin
SetWindowPos(hToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
SWP_NOSIZE or SWP_NOACTIVATE);
ti.cbSize := SizeOf(TToolInfo);
ti.uFlags := TTF_SUBCLASS;
ti.hInst := hInstance;
end;
end;

procedure AddToolTip(hwnd: dword; lpti: PToolInfo; IconType: Integer; Text, Title: PChar);
var
Item: THandle;
Rect: TRect;
begin
Item := hWnd;
if (Item 0) AND (GetClientRect(Item, Rect)) then
begin
lpti.hwnd := Item;
lpti.Rect := Rect;
lpti.lpszText := Text;
SendMessage(hToolTip, TTM_ADDTOOL, 0, Integer(lpti));
FillChar(buffer, sizeof(buffer), #0);
lstrcpy(buffer, Title);
if (IconType > 3) or (IconType < 0) then IconType := 0;
SendMessage(hToolTip, TTM_SETTITLE, IconType, Integer(@buffer));
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
CreateToolTips(Form1.Handle);
AddToolTip(Memo1.Handle, @ti, 1, 'Tooltip text', 'Title');
end;

{
IconType can be:

0 - No icon
1 - Information
2 - Warning
3 - Error
}
Related Discussions
  • USING DLLS (2001-01-04 01:47:50)
    Hi again Goober ... :o) Let's take NETAPI32.DLL as an example. This DLL is created by Microsoft and the explanation of its use is described in...
  • DOT ON SCREEN (2001-01-03 05:42:55)
    Delphi does not support a Pixel function with a HDC, you have to use the Windows-API-function COLORREF SetPixel( HDC hdc, // handle...
  • HOW TO RUN DATABASE APPLICATION ON THE INTERNET (2017-06-09 10:54:22)
    Well, in design I think there is already an issue. Backend is more then just a database with which you connect. There should be a complete layer...
  • HELP WITH CHDIR !!!! TURBO PASCAL VS DELPHI (2001-01-03 08:48:49)
    This is because the ChDir Procedure, the SetCurrentDir and SetCurrentDirectory Functions are changing the directory in the active process. Try...
  • SENDING ICQ MSGS FROM DELPHI (2001-01-03 16:54:03)
    I tried the ICQ Api, but never used it. I've added a simple ICQPager component to delphipages (Winsock/TCPIP).. it might help... Q
  • REPEATING FUNCTIONS (2001-01-04 11:46:34)
    The OnIdle event is not hardware dependent. It is called when the program has idle time. The OnIdle event is in TApplication and is a warpper...
  • HOW TO CREATE SEQURE LOGIN TO DESKTOP APPLICATION (2001-01-05 11:30:01)
    I'm not pretty sure, what your intention is. One possible approach would be to use a edit-field, which cannot be "spyed out" by the usual password...
  • HOW TO FREE UP A QUICKREPORT COMPONENT IN MEMORY...? (2001-01-09 10:05:01)
    Use : Begin if RepForm=Nil then RepForm:=TRepForm.Create(Application); End;
  • QUERY PARAMETER QUESTION...? (2001-01-05 00:44:03)
    there are two parts first is writing the script with variable and another is using bind variable eg- for first you can say query1.sql.text...
  • HOW TO LOAD INI INTO A DLL (2001-01-05 16:43:45)
    unfortunatelly I haven't found anything interesting in the win32api help. I tried different methods. It seems like it is loading the data while...
Latest News
Submit News Form Past News
Latest Forum Entries