i have look into Sample c:\fwh\samples\testtray.prg which use CLASS TTrayIcon()
but it "just" show how to use Icon in TaskTray
https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shell_notifyicona
this what CLASS TTrayIcon() use
- Code: Select all Expand view RUN
- ::lSuccess = Shell_NotifyIcon( If( lAdd, NIM_ADD, NIM_MODIFY ), @c )
but Shell_NotifyIcon() can have "more" Parameter than Microsoft say
TrayBallon will "fly-out" like Windows Message
you can change Icon and use Resource or from Disk
have a look at HB_FUNC ( SHOWNOTIFYINFO ) in Demo CODE
- Code: Select all Expand view RUN
- #include "Fivewin.ch"
PROCEDURE MAIN
MsgBalloon("Hello Fivewin-Forum","Tip from Jimmy")
RETURN
Function MsgBalloon( cMessage, cTitle )
// NEED before
ShowNotifyInfo( 0, .F. , NIL, NIL, NIL, NIL )
// this all work
ShowNotifyInfo( 0, .T. , Nil, Nil, cMessage, cTitle )
// Resource "Number" or "Name"
// ShowNotifyInfo( 0, .T. , 10002 , "large Text not working", cMessage, cTitle )
// ShowNotifyInfo( 0, .T. ,"A2MAIN" , "large Text not working", cMessage, cTitle )
// load from Disk
// ShowNotifyInfo( 0, .T. , ".\RES\BOLOR.ICO" , "large Text not working", cMessage, cTitle )
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);
HB_FUNC ( SHOWNOTIFYINFO )
{
#ifndef _WIN64
HWND hWnd = ( HWND ) hb_parnl( 1 );
#else
HWND hWnd = ( HWND ) hb_parnll( 1 );
#endif
HICON hIcon;
if ( HB_ISNUM( 3 ) )
{
hIcon = LoadIcon( ( HINSTANCE ) GetModuleHandle (NULL), MAKEINTRESOURCE( hb_parni( 3 ) ) );
}
else
{
hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 3 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE );
}
ShowNotifyInfo( (HWND) hWnd, (BOOL) hb_parl(2), hIcon , (LPSTR) hb_parc(4), (LPSTR) hb_parc(5), (LPSTR) hb_parc(6) );
}
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle)
{
NOTIFYICONDATA nid;
ZeroMemory( &nid, sizeof(nid) );
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hIcon = hIcon;
nid.hWnd = hWnd;
nid.uID = 0;
nid.uFlags = NIF_INFO | NIF_TIP | NIF_ICON ;
nid.dwInfoFlags = NIIF_INFO ;
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