winapi - Showing a tooltip via TTM_TRACKACTIVATE does not work -


in background process want display short message balloon in tray area. however, not want add tray icon that. hence create tooltip icon , want place near tray. however, sending ttm_updatetiptext, ttm_trackposition, ttm_trackactivate returns 0. while not sure if should case or not, following code not show tooltip window , don't know why:

this code:

// "hwnd" hwnd hidden background window of background process hwnd htraywnd = findwindow(_t("shell_traywnd"), null); getwindowrect(htraywnd, &traypos); hwnd hwndtip = createwindowex(null, tooltips_class, null,     ws_popup | tts_alwaystip | tts_balloon,     cw_usedefault, cw_usedefault,     cw_usedefault, cw_usedefault,     hwnd, null, null, null); lresult ret; toolinfo toolinfo = { 0 }; zeromemory(&toolinfo, sizeof(toolinfo)); toolinfo.cbsize = sizeof(toolinfo); toolinfo.hinst = getmodulehandle(null); toolinfo.lpsztext = _t("test test"); toolinfo.hwnd = hwnd; ret = sendmessage(hwndtip, ttm_settitle, tti_info , (lparam)_t("test title")); 

this call returns zero:

ret = sendmessage(hwndtip, ttm_updatetiptext, 0 , (lparam)&toolinfo); // needs hinst, lpsztext, hwnd, cbsize 

this call returns 0 too:

ret = sendmessage(hwndtip, ttm_trackposition, 0, makelparam(traypos.left, traypos.top)); zeromemory(&toolinfo, sizeof(toolinfo)); toolinfo.cbsize = sizeof(toolinfo); toolinfo.hwnd = hwnd; toolinfo.uid = 1; 

and too:

ret = sendmessage(hwndtip, ttm_trackactivate, true, (lparam)&toolinfo); // needs hwnd, uid, cbsize 

and tooltip window never shown.

i tried use ttm_addtool (as suggested in comment) ad different order of sendmessage calls returns 0 , no tooltip shown:

lresult ret; toolinfo toolinfo = { 0 }; zeromemory(&toolinfo, sizeof(toolinfo)); toolinfo.cbsize = sizeof(toolinfo); toolinfo.lpsztext = _t("test test"); toolinfo.hwnd = hwnd; toolinfo.uid = 1; toolinfo.rect.bottom = traypos.bottom; toolinfo.rect.left = traypos.left; toolinfo.rect.right = traypos.right; toolinfo.rect.top = traypos.top;  //ret = sendmessage(hwndtip, ttm_addtool, 0, (lparam)&toolinfo); ret = sendmessage(hwndtip, ttm_settitle, tti_info , (lparam)_t("test title")); //ret = sendmessage(hwndtip, ttm_updatetiptext, 0 , (lparam)&toolinfo); // needs hinst, lpsztext, hwnd, uid, cbsize //ret = sendmessage(hwndtip, ttm_trackposition, 0, makelparam(traypos.left, traypos.top)); //ret = sendmessage(hwndtip, ttm_trackactivate, true, (lparam)&toolinfo); // needs hwnd, uid, cbsize ret = sendmessage(hwndtip, ttm_addtool, 0, (lparam)&toolinfo); 


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -