这是在XP的Shell32.dll 6.0版本(使用DllGetVersion验证).
谢谢!
#include "stdafx.h" #include "shellAPI.h" LRESulT CALLBACK WndProc(HWND hWnd,UINT message,WParaM wParam,LParaM lParam); int APIENTRY _tWinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdline,int nCmdshow) { MSG msg; WNDCLASS wc; memset(&wc,sizeof(wc)); wc.lpfnWndProc = WndProc; wc.hInstance = hInstance; wc.hCursor = LoadCursor(NulL,IDC_ARROW); wc.hbrBackground = (HBrush)(color_WINDOW+1); wc.lpszClassname = "sysTrayTest"; RegisterClass(&wc); HWND hWnd = CreateWindow("sysTrayTest","",WS_OVERLAPPEDWINDOW,CW_USEDEFAulT,500,NulL,hInstance,NulL); if (hWnd) { ShowWindow(hWnd,nCmdshow); while (GetMessage(&msg,0)) { TranslateMessage(&msg); dispatchMessage(&msg); } } return 0; } LRESulT CALLBACK WndProc(HWND hWnd,LParaM lParam) { switch (message) { case WM_DESTROY: { NOTIFYICONDATA nID; memset(&nID,sizeof(NOTIFYICONDATA)); nID.cbSize = sizeof(NOTIFYICONDATA); nID.hWnd = hWnd; nID.uID = 1; Shell_NotifyIcon(NIM_DELETE,&nID); PostQuitMessage(0); } break; case WM_CREATE: { NOTIFYICONDATA nID; memset(&nID,sizeof(NOTIFYICONDATA)); nID.cbSize = sizeof(NOTIFYICONDATA); nID.hWnd = hWnd; nID.uID = 1; nID.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nID.uCallbackMessage = WM_USER + 200; nID.hIcon = LoadIcon(NulL,IDI_informatION); lstrcpy (nID.szTip,"Test Tip"); Shell_NotifyIcon(NIM_ADD,&nID); } break; case WM_LbuttonDOWN: { NOTIFYICONDATA nID; memset(&nID,sizeof(NOTIFYICONDATA)); nID.cbSize = sizeof(NOTIFYICONDATA); nID.hWnd = hWnd; nID.uID = 1; nID.uFlags = NIF_INFO; lstrcpy(nID.szInfo,"Test balloon tip"); lstrcpy(nID.szInfoTitle,"Test Title"); nID.DWInfoFlags = NIIF_INFO; nID.uTimeout = 15000; Shell_NotifyIcon(NIM_MODIFY,&nID); } break; default: return DefWindowProc(hWnd,message,wParam,lParam); } return 0; }解决方法 呸,我明白了.出于某种原因我有标题…
sizeof(NOTIFYICONDATA)== 508
而…
NOTIFYICONDATA_V3_SIZE == 504
NOTIFYICONDATA_V2_SIZE == 488
NOTIFYICONDATA_V1_SIZE == 88
如果我指定V2或V3而不是sizeof(NOTIFYICONDATA),气球提示就会显示出来.
总结以上是内存溢出为你收集整理的c – 为什么Shell_NotifyIcon气球提示不起作用?全部内容,希望文章能够帮你解决c – 为什么Shell_NotifyIcon气球提示不起作用?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)