/////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <windows.h>
//
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
#define NIM_ADD 0x00
#define NIM_MODIFY 0x01
#define NIM_DELETE 0x02
#define NIF_MESSAGE 0x001
#define NIF_ICON 0x002
#define NIF_TIP 0x004
#define NIF_INFO 0x010
#define IMAGE_ICON 0x0001
#define LR_LOADFROMFILE 0x00010
#define LR_VGACOLOR 0x00080
#define LR_SHARED 0x08000
//
//
//
typedef struct NOTIFYICONDATA
{
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
long hIcon;
char szTip[128];
DWORD dwState;
DWORD dwStateMask;
char szInfo[256];
DWORD uTimeout;
char szInfoTitle[64];
DWORD dwInfoFlags;
}NOTIFYICONDATA;
//
//
NOTIFYICONDATA _nid;
//
BOOL __stdcall Shell_NotifyIcon(DWORD dwMessage, NOTIFYICONDATA* lpData);
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
void ShowBalloonTip(char* msg, char* title, char* icon, var Timeout)
{
_nid.cbSize =sizeof(NOTIFYICONDATA);
_nid.hWnd = hWnd;
_nid.uFlags = NIF_ICON | NIF_TIP | NIF_INFO;
_nid.uTimeout = 10000;
_nid.dwInfoFlags = NIF_MESSAGE;
strcpy(_nid.szInfo, ""); if(msg) strcpy(_nid.szInfo, msg);
strcpy(_nid.szInfoTitle, ""); if(title) strcpy(_nid.szInfoTitle, title);
if(!_nid.uID) _nid.hIcon = (long)LoadImage(GetModuleHandle(NULL),"26.ico",
IMAGE_ICON, 16, 16, LR_SHARED | LR_LOADFROMFILE | LR_VGACOLOR);
if(!_nid.uID)
{ //create temporary ShellNotifyIcon, and delete when done with it.
_nid.uID = -hWnd;
strcpy(_nid.szTip, ""); if(icon) strcpy(_nid.szTip, icon);
Shell_NotifyIcon(NIM_ADD, &_nid);
wait(-Timeout);
Shell_NotifyIcon(NIM_DELETE, &_nid); //delete "temporary" _nid
DeleteObject(_nid.hIcon); //Free resources and
_nid.hIcon = 0; //mark "_nid"
_nid.uID = 0; //as being "empty"
return;
}
Shell_NotifyIcon(NIM_MODIFY, &_nid);
}
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
// USAGE - ALL text parameters are optional, use NULL for unused text's /
// /
// ShowBalloonTip(char* message, char* title, char* icon_text, var Timeout_in_seconds) /
/////////////////////////////////////////////////////////////////////////////////////////
// /
// If the NOTIFYICONDATA object named "_nid" is already in use for a ShellNotifyIcon /
// then the Ballon message will appear attached to that icon. /
// Note:: Timeout does not yet work if the ballon is attached to an existing Icon /
// /
// But, the NOTIFYICONDATA object named "_nid" is NOT in use, marked by _nid.uID=NULL /
// then the function ShowBalloonTip will create a temporary ShellNotifyIcon to /
// popup from, and will remove it at the end of the Timeout period. /
// /
/////////////////////////////////////////////////////////////////////////////////////////
// /
// ... /
// ShowBalloonTip("Message text", "Title text", "icon text", 5); /
// or /
// ShowBalloonTip(Message_string.chars, Title_string.chars, IconText_string.chars, 5); /
// ... /
// /
/////////////////////////////////////////////////////////////////////////////////////////