Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;BALLOON TOOLTIP IN SYSTRAY ;This is a system tray icon example. ;Left clicking the icon pops up a Balloon tool tip. ;Right clicking the asks you if you want to exit. ; ;NOTE: This example will not work in WinBatch Studio in debug mode, as IntControl 1007 and WinBatch Studio debug mode are not compatible. #DefineFunction ShellTrayModifyTip() ;typedef struct _NOTIFYICONDATA { ;[Size] [Offset] ; 4 DWORD cbSize; 0 ; 4 HWND hWnd; 4 ; 4 UINT uID; 8 ; 4 UINT uFlags; 12 ; 4 UINT uCallbackMessage; 16 ; 4 HICON hIcon; 20 ; 128 TCHAR szTip[128]; 24 ; 4 DWORD dwState; 152 ; 4 DWORD dwStateMask; 156 ;256 TCHAR szInfo[256]; 160 ; union { ; 4 UINT uTimeout; 416 ; 4 UINT uVersion; ; }; ; 64 TCHAR szInfoTitle[64]; 420 ; 4 DWORD dwInfoFlags; 484 ; 16 GUID guidItem; 488 ; 4 HICON hBalloonIcon; 504 ;} NOTIFYICONDATA, *PNOTIFYICONDATA IDI_TRAYICON = 100 ;!!!DO NOT CHANGE!!!. Special value defined by Winbatch. cbsize = 504 bbnid = BinaryAlloc(cbsize) BinaryPoke4(bbnid, 0, cbsize) ;cbSize BinaryPoke4(bbnid, 4, DllHwnd("")) ;hWnd BinaryPoke4(bbnid, 8, IDI_TRAYICON) ;uID 100 unique identifier defined by WinBatch BinaryPoke4(bbnid, 12, 16) ;uFlags NIF_INFO - Use a balloon ToolTip instead of a standard ToolTip. The szInfo, uTimeout, ;szInfoTitle, and dwInfoFlags members are valid. ;BinaryPoke4(bbnid, 16, 0) ;uCallbackMessage ;BinaryPoke4(bbnid, 20, 0) ;hIcon ;BinaryPokeStr(bbnid, 24, "My Tool Tip") ;szTip[64] ;BinaryPoke4(bbnid, 152, 0) ;dwState; ;BinaryPoke4(bbnid, 156, 0) ;dwStateMask BinaryPokeStr(bbnid, 160, "My Balloon Tip Text") ;szInfo[256] text for a balloon ToolTip. It can have a maximum of 255 characters ;Union BinaryPoke4(bbnid, 416, 10000 ); uTimeout The timeout value, in milliseconds, for a balloon ToolTip. ; or ; BinaryPoke4(bbnid, 416, 0 ); uVersion BinaryPokeStr(bbnid, 420, "My Balloon Tip Title") ;szInfoTitle[64] string containing a title for a balloon ToolTip BinaryPoke4(bbnid, 484, 1 );dwInfoFlags; ;BinaryPoke4(bbnid, 488, 0 );guidItem reserved ;BinaryPoke4(bbnid, 504, 0 );hBalloonIcon BinaryEodSet( bbnid, cbsize ) ;Call Shell_NotifyIcon(NIM_MODIFY, nid) NIM_MODIFY = 1 user32=StrCat(DirWindows(1),"shell32.dll") ret = DllCall(user32,long:"Shell_NotifyIconA", long:NIM_MODIFY, lpbinary:bbnid) If ret == 0 Message("Shell_NotifyIcon Error",DllLastError()) EndIf Return(ret) #EndFunction IntControl(1007, 1, 1, "", 0) While 1 ;1=left button 2=right button button=IntControl(1007, 3,0, 0, "") Switch button Case 1 ; left mouse button ret = ShellTrayModifyTip() ;Message("ShellTrayModifyTip Result ",ret) Break Case 2 ; right mouse button ret = AskYesNo( "You clicked the left mouse button","Do you want to Exit?") If ret == @YES IntControl(1007, 2,0, "", "") Exit EndIf Break Case button Message("Default button",button) Exit Break EndSwitch EndWhile IntControl(1007, 2,0, "", "") Exit
This code sample displays a balloon tool tip form the system tray icon, and dynamically updates the title and text.
#DefineFunction ShellTrayModifyTip(title, text) ; This example will not work in WinBatch Studio in debug mode, ; as IntControl 1007 and WinBatch Studio debug mode are not compatible. status = RtStatus() If status == 10 Pause('Notice','This function is not supported in debug mode') Exit EndIf IDI_TRAYICON = 100 ;!!!DO NOT CHANGE!!!. Special value defined by Winbatch. cbsize = 504 bbnid = BinaryAlloc(cbsize) BinaryPoke4(bbnid, 0, cbsize) ;cbSize BinaryPoke4(bbnid, 4, DllHwnd("")) ;hWnd BinaryPoke4(bbnid, 8, IDI_TRAYICON) ;uID 100 unique identifier defined by WinBatch BinaryPoke4(bbnid, 12, 16) ;uFlags NIF_INFO - Use a balloon ToolTip instead of a standard ToolTip. The szInfo, uTimeout, BinaryPokeStr(bbnid, 160, StrSub( text, 1, 255 )) ;szInfo[256] text for a balloon ToolTip. BinaryPoke4(bbnid, 416, 10000 ); uTimeout The timeout value, in milliseconds, for a balloon ToolTip. BinaryPokeStr(bbnid, 420, StrSub( title, 1, 64 )) ;szInfoTitle[64] string containing a title for a balloon ToolTip BinaryPoke4(bbnid, 484, 1 );dwInfoFlags; BinaryEodSet( bbnid, cbsize ) ;Call Shell_NotifyIcon(NIM_MODIFY, nid) NIM_MODIFY = 1 user32=StrCat(DirWindows(1),"shell32.dll") ret = DllCall(user32,long:"Shell_NotifyIconA", long:NIM_MODIFY, lpbinary:bbnid) If ret == 0 Message("Shell_NotifyIcon Error",DllLastError()) EndIf Return(ret) #EndFunction IntControl(1007, 1, 1, '', 0) For x=1 To 5 ret = ShellTrayModifyTip('Sample Dynamic Balloon Tip', 'Counter = ' : x) TimeDelay(1) Next IntControl(1007, 2,0, "", "") Exit
Article ID: W17272
File Created: 2011:04:14:10:15:28
Last Updated: 2011:04:14:10:15:28