VC ++ uses air bubble tips

xiaoxiao2021-04-08  445

First, you need to update the SDK of VC6.0, the method is as follows: Replace the function and constant of the task bar prompt in the shellapi.h file to the following:

Tray notification definitionstypedef struct _NOTIFYICONDATAA {DWORD cbSize; HWND hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; HICON hIcon; #if (_WIN32_IE <0x0500) CHAR szTip [64]; # else CHAR szTip [128]; # endif # if ( _WIN32_IE> = 0x0500) DWORD dwState; DWORD dwStateMask; CHAR szInfo [256]; union {UINT uTimeout; UINT uVersion;} DUMMYUNIONNAME; CHAR szInfoTitle [64]; DWORD dwInfoFlags; # endif # if (_WIN32_IE> = 0x600) GUID guidItem; #endif} NOTIFYICONDATAA, * PNOTIFYICONDATAA; typedef struct _NOTIFYICONDATAW {DWORD cbSize; HWND hWnd; UINT uID; UINT uFlags; UINT uCallbackMessage; HICON hIcon; #if (_WIN32_IE <0x0500) WCHAR szTip [64]; # else WCHAR szTip [128] ; # Endif # ix (_win32_ie> = 0x0500) DWORD DWSTATE; DWORD DWSTATEMASK; Wchar Szinfo [256]; union {uint UT imeout; UINT uVersion;} DUMMYUNIONNAME; WCHAR szInfoTitle [64]; DWORD dwInfoFlags; # endif # if (_WIN32_IE> = 0x600) GUID guidItem; #endif} NOTIFYICONDATAW, * PNOTIFYICONDATAW; #ifdef UNICODEtypedef NOTIFYICONDATAW NOTIFYICONDATA; typedef PNOTIFYICONDATAW PNOTIFYICONDATA; #elsetypedef Notifyicondata; Typedef Pnotifyicondata PNOTIFYICONDATA;

#endif // UNICODE # define NOTIFYICONDATAA_V1_SIZE FIELD_OFFSET (NOTIFYICONDATAA, szTip [64]) # define NOTIFYICONDATAW_V1_SIZE FIELD_OFFSET (NOTIFYICONDATAW, szTip [64]) # ifdef UNICODE # define NOTIFYICONDATA_V1_SIZE NOTIFYICONDATAW_V1_SIZE # else # define NOTIFYICONDATA_V1_SIZE NOTIFYICONDATAA_V1_SIZE # endif # define NOTIFYICONDATAA_V2_SIZE FIELD_OFFSET (NOTIFYICONDATAA , guidItem) #define NOTIFYICONDATAW_V2_SIZE fIELD_OFFSET (NOTIFYICONDATAW, guidItem) #ifdef UNICODE # define NOTIFYICONDATA_V2_SIZE NOTIFYICONDATAW_V2_SIZE # else # define NOTIFYICONDATA_V2_SIZE NOTIFYICONDATAA_V2_SIZE # endif # if (_WIN32_IE> = 0x0500) #define NIN_SELECT (WM_USER 0) #define NINF_KEY 0x1 # define NIN_KEYSELECT (NIN_SELECT | NINF_KEY) # endif # if (_WIN32_IE> = 0x0501) #define NIN_BALLOONSHOW (WM_USER 2) #define NIN_BALLOONHIDE (WM_USER 3) #define NIN_BALLOONTIMEOUT (WM_USER 4) #define NIN_BALLOONUSERCLICK (WM_USER 5) # endif # Define nim_add 0x00000000 # Define Nim _MODIFY 0x00000001 # define NIM_DELETE 0x00000002 # if (_WIN32_IE> = 0x0500) #define NIM_SETFOCUS 0x00000003 # define NIM_SETVERSION 0x00000004 # define NOTIFYICON_VERSION 3 # endif # define NIF_MESSAGE 0x00000001 # define NIF_ICON 0x00000002 # define NIF_TIP 0x00000004 # if (_WIN32_IE> = 0x0500) #define Nif_State 0x00000008 # define nif_info 0x00000010 # endif # i (_win32_ie> = 0x600) #define nif_guid 0x00000020 # Endif # IF (_WIN32_IE> =

0x0500) #define NIS_HIDDEN 0x00000001 # define NIS_SHAREDICON 0x00000002 // says this is the source of a shared icon // Notify Icon Infotip flags # define NIIF_NONE 0x00000000 // icon flags are mutually exclusive // ​​and take only the lowest 2 bits # define NIIF_INFO 0x00000001 # define NIIF_WARNING 0x00000002 # define NIIF_ERROR 0x00000003 # define NIIF_ICON_MASK 0x0000000F # if (_WIN32_IE> = 0x0501) #define NIIF_NOSOUND 0x00000010 # endif # endifSHSTDAPI_ (BOOL) Shell_NotifyIconA (DWORD dwMessage, PNOTIFYICONDATAA lpData); SHSTDAPI_ (BOOL) Shell_NotifyIconW (DWORD dwMessage, ! PNOTIFYICONDATAW lpData); # ifdef UNICODE # define Shell_NotifyIcon Shell_NotifyIconW # else # define Shell_NotifyIcon Shell_NotifyIconA # endif // UNICODE End Tray Notification Icons in stdafx.h add the following file: #ifndef _WIN32_IE // allowed to use IE 4.0 or higher Specific functions. #define_win32_ie 0x0500 / / Changes to the appropriate value for IE 5.0 and updated versions. #ENDIF Custom Messages and Processing Functions:

#define myWM_notifyicon WM_USER 1AFX_MSG Void Onmyiconnotify (WPARAM WPARAM, LPARAM LPARAM); ON_MESSAGE (MyWM_Notifyicon, Onmyiconnotify)

Add variable: notifyicondata m_ndata;

Add icons and prompts to add icons and prompts in the taskbar:

m_nData.cbSize = sizeof (NOTIFYICONDATA); m_nData.hWnd = GetSafeHwnd (); m_nData.uFlags = NIF_MESSAGE | NIF_INFO | NIF_ICON; m_nData.uCallbackMessage = MYWM_NOTIFYICON; m_nData.uID = IDR_MAINFRAME; m_nData.hIcon = AfxGetApp () -> LoadIcon ( IDR_MAINFRAME); m_ndata.dwinfoflags = niif_info; _tcscpy (m_ndata.szinfotitle, "administrator"); _ tcscpy (m_ndata.szinfo, "welcome"); shell_notifyicon (nim_add, & m_ndata);

Modify the code of the bubble tips: void ctipdlg :: Onbutton1 () {_ tcscpy (m_ndata.szinfotitle, "reminder you"); _ tcscpy (m_ndata.szinfo, "content change"); m_ndata.utimeout = 1000; m_ndata.uversion = notifyicon_version; Shell_notifyicon (Nim_Modify, & m_ndata);} Deleted code: Bool ctipdlg :: destroyWindow () {shell_notifyicon (nim_delete, & m_ndata); return cdialog :: destroyWindow ();}

Message handler: void CTipDlg :: OnMyIconNotify (WPARAM wParam, LPARAM lParam) {UINT uMouseMsg = LOWORD (lParam); switch (uMouseMsg) {case WM_LBUTTONDBLCLK: SendMessage (WM_CLOSE, 0,0); break; case WM_LBUTTONDOWN: Shell_NotifyIcon (NIM_MODIFY , & m_ndata); Break;}}

Please refer to the source code and related information for specific methods!

转载请注明原文地址:https://www.9cbs.com/read-132768.html

New Post(0)