#include "FIVEWIN.CH"
#define WIN_NIIF_USER 0x00000004
/*------------------------------------------------------
MsgBalloon( cMessage, [ cTitle ], [ xIcon ], [ nFlags ] ) -> nil
Copyright 2007-2013 Grigory Filatov <gfil...@inbox.ru>
Parameters:
cMessage -> info text
cTitle -> info title
xIcon -> resource id / resource name / filename
of the icon displayed to the left of the title
nFlags -> bit masked icon flags (default = WIN_NIIF_INFO)
for the icon displayed to the left of the message
set from ShellNotifyIcon() dwInfoFlags values:
#define WIN_NIIF_NONE 0x00000000
#define WIN_NIIF_INFO 0x00000001
#define WIN_NIIF_WARNING 0x00000002
#define WIN_NIIF_ERROR 0x00000003
#define WIN_NIIF_USER 0x00000004
#define WIN_NIIF_NOSOUND 0x00000010
#define WIN_NIIF_LARGE_ICON 0x00000020
#define WIN_NIIF_RESPECT_QUIET_TIME 0x00000080
#define WIN_NIIF_ICON_MASK 0x0000000F
if nFlags is used via symbolic names it's needed to include "hbwin.ch" in source
Samples:
MsgBallon( "Some text" )
MsgBallon( "Some text", "A title" )
MsgBallon( "Some text", "A title", 123 ) 123 is the id of the icon set in resource file
MsgBallon( "Some text", "A title", "PRGICON" ) "PRGICON" is the icon name set in resource file
MsgBallon( "Some text", "A title", "c:\path\icon.ico" )
MsgBallon( "Some text", "A title", "c:\path\icon.ico", NIIF_ERROR ) same as previous, but with an error icon
MsgBallon( "Some text", "A title", "c:\path\icon.ico", NIIF_USER + NIIF_NOSOUND ) no sound, same icon as title icon
--------------------------------------------------------*/
Procedure Main
* MsgBalloon( "Any text", "Any title", "A2MAIN", WIN_NIIF_USER )
* MsgBalloon( "Some text", "A title", "A2MAIN" )
MsgBalloon( "Some text", "A title", 10002 )
RETURN
function MsgBalloon( cMessage, cTitle, xIcon, nFlags )
ShowNotifyInfo( 0, .F. , xIcon, NIL, NIL, NIL, NIL )
ShowNotifyInfo( 0, .T. , xIcon, NIL, cMessage, cTitle, hb_defaultValue( nFlags, 1 ) )
Return Nil
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle, int nFlags );
HB_FUNC ( SHOWNOTIFYINFO )
{
HICON hIcon;
if ( HB_ISNUM( 3 ) )
{
hIcon = LoadIcon( ( HINSTANCE ) GetModuleHandle( NULL ), MAKEINTRESOURCE( hb_parni( 3 ) ) );
}
else
{
hIcon = LoadIcon( ( HINSTANCE ) GetModuleHandle( NULL ), hb_parc( 3 ) );
if ( hIcon == NULL )
hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 3 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
}
ShowNotifyInfo( (HWND) hb_parnl(1), (BOOL) hb_parl(2), hIcon , (LPSTR) hb_parc(4), (LPSTR) hb_parc(5), (LPSTR) hb_parc(6), hb_parni( 7 ) );
}
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle, INT nFlags )
{
NOTIFYICONDATA nid;
ZeroMemory( &nid, sizeof(nid) );
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hIcon = hIcon;
nid.hWnd = hWnd;
nid.uID = 0;
nid.uFlags = NIF_INFO | NIF_ICON;
nid.dwInfoFlags = nFlags;
lstrcpy( nid.szTip, TEXT(szText) );
lstrcpy( nid.szInfo, TEXT(szInfo) );
lstrcpy( nid.szInfoTitle, TEXT(szInfoTitle) );
if(bAdd)
Shell_NotifyIcon( NIM_ADD, &nid );
else
Shell_NotifyIcon( NIM_DELETE, &nid );
if(hIcon)
DestroyIcon( hIcon );
}
#pragma ENDDUMP