Reputation: 129
I have this code (From the Microsoft page here) that set an icon in the task bar, but I can't show any icon in it.
//Notification
nid.cbSize = sizeof(nid);
nid.uFlags = NIF_ICON | NIF_TIP | NIF_GUID;
// Note: This is an example GUID only and should not be used.
// Normally, you should use a GUID-generating tool to provide the value to
// assign to guidItem.
static const GUID myGUID =
{ 0x23977b55, 0x10e0, 0x4041,{ 0xb8, 0x62, 0xb1, 0x95, 0x41, 0x96, 0x36, 0x68 } };
nid.guidItem = myGUID;
nid.hIcon = LoadIconA(wc.hInstance, IDC_ARROW);
// This text will be shown as the icon's tooltip.
StringCchCopy(nid.szTip, ARRAYSIZE(nid.szTip), title);
//TaskBar
nid.hWnd = hwnd;
// Show the notification.
Shell_NotifyIcon(NIM_ADD, &nid) ? S_OK : E_FAIL;
Could somebody help me please? I onle get the space in the taskbar, but "transparent".
Upvotes: 0
Views: 639
Reputation: 613412
Your code to load the icon fails. You didn't check for errors. Had you done so you would have seen that LoadIcon returned NULL.
IDC_ARROW identifies a cursor rather than an icon and so you would use IDC_ARROW with LoadCursor. Further as explained in the documentation you would have to pass NULL for the module handle since it is a system cursor. But you need to load an icon in any case.
So, fix your problem by loading an icon. Make sure that LoadIcon returns a value that is not NULL. Typically you would do that by linking an icon resource to your executable and loading that. For testing purposes you could use one of the predefined icons as described by the documentation for LoadIcon.
And please don't ever neglect error checking.
Upvotes: 1