class
TNotifyIconDataEx = record
cbSize: DWORD;
Wnd: HWND;
uID: UINT;
uFlags: UINT;
uCallbackMessage: UINT;
hIcon: HICON;
// szTip: array[0..63] of AnsiChar;
szTip: array[0..127] of AnsiChar;
// 0..63 of WideChar in stead?
dwState: DWORD;
dwStateMask: DWORD;
szInfo: array[0..255] of AnsiChar;
uTimeout: UINT;
// union with uVersion: UINT;
szInfoTitle: array[0..63] of AnsiChar;
dwInfoFlags: DWORD;
end;
TBalloonHintIcon = (bitNone, bitInfo, bitWarning, bitError);
TBalloonHintTimeOut = 10..60;
// Windows defines 10-60 secs. as min-max
private
IconData: TNotifyIconDataEx;
// Data of the tray icon wnd.
implementation
procedure ShowBalloonHint(Title: String;
Text: String;
IconType: TBalloonHintIcon;
TimeoutSecs: TBalloonHintTimeOut): Boolean;
const
aBalloonIconTypes: array[TBalloonHintIcon] of Byte =
(_NIIF_NONE, _NIIF_INFO, _NIIF_WARNING, _NIIF_ERROR);
begin
begin
with IconDatado
begin
uFlags := uFlags or _NIF_INFO;
StrPCopy(szInfo, '');
end;
with IconDatado
begin
uFlags := uFlags or _NIF_INFO;
StrPCopy(szInfo, Text);
StrPCopy(szInfoTitle, Title);
uTimeout := TimeoutSecs * 1000;
dwInfoFlags := aBalloonIconTypes[IconType];
end;
Shell_NotifyIcon(NIM_MODIFY, @IconData);
end;