Search code examples
cwindowswinapinotifications

C create Windows Taskbar Notification


How do i create a Popup like this: Popup

I try Shell_NotifyIcon() but this only creates an image in the Taskbar and the Balloon function don´t work in Windows 10 anymore. Maybe i missed something but i don´t find any other function to do that.

Following is my setup:

NOTIFYICONDATAA dataa;
dataa.cbSize=sizeof(dataa);
dataa.hWnd=hWnd;
dataa.uID=0;
dataa.uFlags=NIF_ICON | NIF_TIP | NIF_MESSAGE;
dataa.hIcon=LoadIcon(NULL, IDI_QUESTION);
strcpy(dataa.szTip, "Test1");
Shell_NotifyIcon(NIM_ADD, &dataa);
Shell_NotifyIcon(NIM_MODIFY, &dataa); 

Solution

  • With following code i can create a Notification like this:

    Notification

    NOTIFYICONDATAA dataa;
        dataa.uTimeout          =       3000;
        dataa.uVersion          =       NIM_SETVERSION;
        dataa.cbSize            =       sizeof(dataa);
        dataa.hWnd              =       hWnd;
        dataa.uID               =       0;
        dataa.uFlags            =       NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_INFO;
        dataa.hIcon             =       LoadIcon(NULL, IDI_WARNING);
        dataa.dwInfoFlags       =       NIIF_WARNING;
        strcpy(dataa.szTip, "Test1");
        strcpy(dataa.szInfo, "Test2");
        strcpy(dataa.szInfoTitle, "Test3");
        Shell_NotifyIcon(NIM_ADD, &dataa);
        Shell_NotifyIcon(NIM_SETVERSION, &dataa);
    

    Thanks to Remy and Jonathan. This seems easier than the toast notification option. In my tests i can only change the Test2 and Test3 string. The title string i can not change, i think this do Windows. After running the .exe, the App name will used as title string.

    To generate the Notification and use the struct like in code, the Version must set to

    #define _WIN32_IE 0x0650 //or other value above 0x600

    before including shellapi.h.