views:

287

answers:

2

this is my code..

set trayicon .......

NOTIFYICONDATA data;//this is global variable.
case WM_CREATE :
data.cbSize = sizeof(NOTIFYICONDATA);
data.hWnd =hWnd;
data.uID = IDR_MAINFRAME;
data.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
data.uCallbackMessage = ID_TRAYICON_NOTIFY;
data.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_INFO));

wcscpy_s(data.szTip,128,a);

Shell_NotifyIcon( NIM_ADD, &data );

........

and set balloon ......

case WM_RBUTTONDBLCLK:
data.hWnd = hWnd;
data.cbSize =sizeof(NOTIFYICONDATA);
data.hIcon =  LoadIcon(hInst, MAKEINTRESOURCE(IDI_INFO));
data.uTimeout = 5000;
data.uFlags = NIF_INFO;
data.dwInfoFlags = NIIF_INFO;
_tcscpy_s(data.szInfoTitle,_T("TITLE"));
_tcscpy_s(data.szInfo,_T("SOME TEXT"));
Shell_NotifyIcon(NIM_MODIFY,&data);

.......

but, can't show balloon tooltip

plz teach me.

+1  A: 

You should check shell32.dll version, and set cbSize to (as described in the Remarks section of the NOTIFYICONDATA docs):

  • sizeof(NOTIFYICONDATA) if version is >=6.0.6
  • NOTIFYICONDATA_V3_SIZE if version is 6.0 (WinXP)
  • NOTIFYICONDATA_V2_SIZE if version is 5.0 (Win2000)
  • NOTIFYICONDATA_V1_SIZE if version is <5.0 (NT4/95/98)
PiotrLegnica
A: 

You forgot to specify

data.uID = IDR_MAINFRAME;

in the set balloon code

Indeera