Mensagem na bandeja do windows com ShowNotifyInfo
Enviado: 29 Abr 2011 09:24
Senhores,
Com a minigui eu tenho um sistema monitor que fica no tray (bandeja) do windows. Quando há algum evento no sistema eu notifico no tray com uma mensagem do evento usando a função abaixo:
Existe algo parecido em hwgui?
[]´s
Com a minigui eu tenho um sistema monitor que fica no tray (bandeja) do windows. Quando há algum evento no sistema eu notifico no tray com uma mensagem do evento usando a função abaixo:
Existe algo parecido em hwgui?
Código: Selecionar todos
PROCEDURE MsgBalloon( cMessage, cTitle )
LOCAL i := Ascan( _HMG_aFormhandles, GetFormHandle("Form_1") )
Default cMessage := "Prompt", cTitle := PROGRAM
ShowNotifyInfo( _HMG_aFormhandles[i], .F. , NIL, NIL, NIL, NIL )
ShowNotifyInfo( _HMG_aFormhandles[i], .T. , LoadTrayIcon( GetInstance(), ;
_HMG_aFormNotifyIconName[i] ), _HMG_aFormNotifyIconToolTip[i], cMessage, cTitle )
RETURN Nil
Código: Selecionar todos
*-----------------------------------------------------------------------------*
/*
* C-level
*/
#pragma BEGINDUMP
#define _WIN32_IE 0x0500
#define HB_OS_WIN_32_USED
#define _WIN32_WINNT 0x0400
#include <shlobj.h>
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle);
HB_FUNC ( SHOWNOTIFYINFO )
{
ShowNotifyInfo( (HWND) hb_parnl(1), (BOOL) hb_parl(2), (HICON) hb_parnl(3), (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
#pragma BEGINDUMP
#define HB_OS_WIN_32_USED
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"
/*HB_FUNC( DRAWICON )
{ HWND hwnd;
HDC hdc;
hwnd = (HWND) hb_parnl( 1 ) ;
hdc = GetDC( hwnd ) ;
hb_retl( DrawIcon( (HDC) hdc , hb_parni( 2 ) , hb_parni( 3 ) , (HICON) hb_parnl( 4 ) ) ) ;
ReleaseDC( hwnd, hdc ) ;
} */
HB_FUNC( SHOWERROR )
{
LPVOID lpMsgBuf;
DWORD dwError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox(NULL, (LPCSTR)lpMsgBuf, "Shutdown", MB_OK | MB_ICONEXCLAMATION);
// Free the buffer.
LocalFree( lpMsgBuf );
}
HB_FUNC( ENABLEPERMISSIONS )
{
LUID tmpLuid;
TOKEN_PRIVILEGES tkp, tkpNewButIgnored;
DWORD lBufferNeeded;
HANDLE hdlTokenHandle;
HANDLE hdlProcessHandle = GetCurrentProcess();
OpenProcessToken(hdlProcessHandle, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hdlTokenHandle);
LookupPrivilegeValue(NULL, "SeShutdownPrivilege", &tmpLuid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = tmpLuid;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hdlTokenHandle, FALSE, &tkp, sizeof(tkpNewButIgnored), &tkpNewButIgnored, &lBufferNeeded);
}
HB_FUNC( EXITWINDOWSEX )
{
hb_retl( ExitWindowsEx( (UINT) hb_parni( 1 ), (DWORD) hb_parnl( 2 ) ) );
}
HB_FUNC( GETPRIVATEPROFILESTRING )
{
TCHAR bBuffer[ 1024 ] = { 0 };
DWORD dwLen ;
char * lpSection = hb_parc( 1 );
char * lpEntry = ISCHAR(2) ? hb_parc( 2 ) : NULL ;
char * lpDefault = hb_parc( 3 );
char * lpFileName = hb_parc( 4 );
dwLen = GetPrivateProfileString( lpSection , lpEntry ,lpDefault , bBuffer, sizeof( bBuffer ) , lpFileName);
if( dwLen )
hb_retclen( ( char * ) bBuffer, dwLen );
else
hb_retc( lpDefault );
}
HB_FUNC( WRITEPRIVATEPROFILESTRING )
{
char * lpSection = hb_parc( 1 );
char * lpEntry = ISCHAR(2) ? hb_parc( 2 ) : NULL ;
char * lpData = ISCHAR(3) ? hb_parc( 3 ) : NULL ;
char * lpFileName= hb_parc( 4 );
if ( WritePrivateProfileString( lpSection , lpEntry , lpData , lpFileName ) )
hb_retl( TRUE ) ;
else
hb_retl(FALSE);
}
HB_FUNC( GETWINDOWTEXT )
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
int iLen = GetWindowTextLength( hWnd );
LPSTR pText;
if( iLen > 0 )
{
pText = hb_xgrab( iLen + 1 );
GetWindowText( hWnd, pText, iLen + 1 );
hb_retclen( pText, iLen );
hb_xfree( pText );
}
else
hb_retc( "" );
}
HB_FUNC( LOADTRAYICON )
{
HICON himage;
HINSTANCE hInstance = (HINSTANCE) hb_parnl(1); // handle to application instance
LPCTSTR lpIconName = (LPCTSTR) hb_parc(2); // name string or resource identifier
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 16, 16, LR_SHARED ) ;
if (himage==NULL)
{
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 0, 0, LR_LOADFROMFILE + LR_DEFAULTSIZE ) ;
}
hb_retnl ( (LONG) himage );
}
HB_FUNC( LOADMAINICON )
{
HICON himage;
HINSTANCE hInstance = (HINSTANCE) hb_parnl(1); // handle to application instance
LPCTSTR lpIconName = (LPCTSTR) hb_parc(2); // name string or resource identifier
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 0, 0, LR_DEFAULTSIZE ) ;
if (himage==NULL)
{
himage = (HICON) LoadImage( hInstance , lpIconName , IMAGE_ICON, 0, 0, LR_LOADFROMFILE + LR_DEFAULTSIZE ) ;
}
hb_retnl ( (LONG) himage );
}
#pragma ENDDUMP
