tray icon tooltip text
-
//Shell_NotifyIcon NOTIFYICONDATA notifyData; notifyData.cbSize = sizeof(notifyData); notifyData.hWnd = hwnd; notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE; notifyData.uCallbackMessage = MSG_STATUSICON; notifyData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); ::strcpy((char*)notifyData.szTip, "hello"); <-- not working ::strcpy((char*)notifyData.szInfo, "blablabla"); char tp [128] ; ::strcpy(tp,(char*)notifyData.szTip); //test tp gets "hello" value Shell_NotifyIcon(NIM_ADD, ¬ifyData);
instead of hello im getting gibberish on my icon ToolTip ..long string looks like chinese. something wrong with this line? ::strcpy((char*)notifyData.szTip, "hello"); thank you -
//Shell_NotifyIcon NOTIFYICONDATA notifyData; notifyData.cbSize = sizeof(notifyData); notifyData.hWnd = hwnd; notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE; notifyData.uCallbackMessage = MSG_STATUSICON; notifyData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); ::strcpy((char*)notifyData.szTip, "hello"); <-- not working ::strcpy((char*)notifyData.szInfo, "blablabla"); char tp [128] ; ::strcpy(tp,(char*)notifyData.szTip); //test tp gets "hello" value Shell_NotifyIcon(NIM_ADD, ¬ifyData);
instead of hello im getting gibberish on my icon ToolTip ..long string looks like chinese. something wrong with this line? ::strcpy((char*)notifyData.szTip, "hello"); thank youLamefif wrote:
notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE;
What if you remove
NIF_STATE
?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
//Shell_NotifyIcon NOTIFYICONDATA notifyData; notifyData.cbSize = sizeof(notifyData); notifyData.hWnd = hwnd; notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE; notifyData.uCallbackMessage = MSG_STATUSICON; notifyData.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)); ::strcpy((char*)notifyData.szTip, "hello"); <-- not working ::strcpy((char*)notifyData.szInfo, "blablabla"); char tp [128] ; ::strcpy(tp,(char*)notifyData.szTip); //test tp gets "hello" value Shell_NotifyIcon(NIM_ADD, ¬ifyData);
instead of hello im getting gibberish on my icon ToolTip ..long string looks like chinese. something wrong with this line? ::strcpy((char*)notifyData.szTip, "hello"); thank youLamefif wrote:
something wrong with this line? ::strcpy((char*)notifyData.szTip, "hello");
If it's a unicode build then yes, there's something wrong with that line :) I would recommend NOT using casts unless you need to. Write code without the casts. If the compiler complains, then investigate why. For a Unicode build, that line should be something like: // Unicode only ::wcscpy(notifyData.szTip, L"hello"); or better yet // generic _tcscpy(notifyData.szTip, _T("hello")); If this is indeed the problem, had you omitted the casts to char*, the compiler would have let you know. Mark -- modified at 14:23 Monday 16th July, 2007
Mark Salsbery Microsoft MVP - Visual C++ "Great job team! Head back to base for debriefing and cocktails."
-
Lamefif wrote:
notifyData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_STATE;
What if you remove
NIF_STATE
?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Lamefif wrote:
something wrong with this line? ::strcpy((char*)notifyData.szTip, "hello");
If it's a unicode build then yes, there's something wrong with that line :) I would recommend NOT using casts unless you need to. Write code without the casts. If the compiler complains, then investigate why. For a Unicode build, that line should be something like: // Unicode only ::wcscpy(notifyData.szTip, L"hello"); or better yet // generic _tcscpy(notifyData.szTip, _T("hello")); If this is indeed the problem, had you omitted the casts to char*, the compiler would have let you know. Mark -- modified at 14:23 Monday 16th July, 2007
Mark Salsbery Microsoft MVP - Visual C++ "Great job team! Head back to base for debriefing and cocktails."
-
You're welcome :) Also check out DavidCrow's reply...you are using a flag that indicates members of the struct are valid but you didn't show those members being initialized. Cheers, Mark
Mark Salsbery Microsoft MVP - Visual C++ "Great job team! Head back to base for debriefing and cocktails."