G
gotiger
Unregistered / Unconfirmed
GUEST, unregistred user!
我用下面的方法实现的气泡窗口,但是只能在鼠标移动到控件上才会显示气泡窗口。请问怎么实现自动显示。比如5秒显示一次。<br><br>unit BalloonToolTips;<br><br>interface<br><br> uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs,commctrl, StdCtrls;<br>const<br> TTS_BALLOON = $40;<br> TTM_SETTITLE = (WM_USER + 32);<br><br>var<br> hTooltip: Cardinal;<br> ti: TToolInfo;<br> buffer : array[0..255] of char;<br><br><br>implementation<br><br>procedure CreateToolTips(hWnd: Cardinal);<br>begin<br> hToolTip := CreateWindowEx(0, 'Tooltips_Class32', nil, TTS_ALWAYSTIP or TTS_BALLOON,<br> Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),Integer(CW_USEDEFAULT),<br> Integer(CW_USEDEFAULT), hWnd, 0, hInstance, nil);<br> if hToolTip <> 0 then<br> begin<br> SetWindowPos(hToolTip, HWND_TOPMOST, 0,0, 0, 0, SWP_NOMOVE or<br> SWP_NOSIZE or SWP_NOACTIVATE);<br> ti.cbSize := SizeOf(TToolInfo);<br> ti.uFlags := TTF_SUBCLASS or TTF_TRANSPARENT;<br> ti.hInst := hInstance;<br> end;<br>end;<br><br>procedure AddToolTip(hwnd: dword; lpti: PToolInfo; IconType: Integer; Text, Title: PChar;<br> BackColor,TextColor:TColor);<br>var<br> Rect: TRect;<br>begin<br> if (hwnd <> 0) AND (GetClientRect(hwnd, Rect)) then<br> begin<br> lpti.hwnd := hwnd;<br> lpti.Rect := Rect;<br> lpti.lpszText := Text;<br> SendMessage(hToolTip, TTM_ADDTOOL, 0, Integer(lpti));<br> FillChar(buffer, sizeof(buffer), #0);<br> lstrcpy(buffer, Title);<br> if (IconType > 3) or (IconType < 0) then IconType := 0;<br> if BackColor<>0 then<br> SendMessage(hToolTip, TTM_SETTIPBKCOLOR, BackColor, 0);<br> if TextColor<>0 then<br> SendMessage(hToolTip, TTM_SETTIPTEXTCOLOR, TextColor, 0);<br> SendMessage(hToolTip, TTM_SETTITLE, IconType, Integer(@buffer));<br> end;<br>end;<br><br>end.