Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. No Balloon Tip

No Balloon Tip

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Great ATuin

    hi, I want to display a little balloon tip on my tray icon but the balloon just won't appear, although the tray icon is visible. the app is based on MFC and here's the code that doesn't work. it is located in OnInitDialog: ndata.cbSize=sizeof(NOTIFYICONDATA); ndata.hWnd = m_hWnd; ndata.uFlags = NIF_ICON | NIF_MESSAGE | NIF_INFO; ndata.uID = IDI_DISABLED; ndata.dwInfoFlags = NIIF_NONE; ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_DISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); ndata.uCallbackMessage = WM_POPUP; ndata.uTimeout = 10000; wcscpy(ndata.szInfoTitle,_T("Test")); wcscpy(ndata.szInfo, _T("Test")); Shell_NotifyIcon(NIM_ADD, &ndata); ndata is of type NOTIFYICONDATA and is a member of my dialog class. any clues what could be wrong with that ? greets -- modified at 4:38 Wednesday 1st February, 2006

    O Offline
    O Offline
    Owner drawn
    wrote on last edited by
    #2

    You have to set the version.

    ndata.uVersion=NOTIFYICON_VERSION;
    Shell_NotifyIcon(NIM_SETVERSION, &nData);
    

    Jesus Lives Forever - Amen:rose:

    --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

    G 1 Reply Last reply
    0
    • O Owner drawn

      You have to set the version.

      ndata.uVersion=NOTIFYICON_VERSION;
      Shell_NotifyIcon(NIM_SETVERSION, &nData);
      

      Jesus Lives Forever - Amen:rose:

      --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

      G Offline
      G Offline
      Great ATuin
      wrote on last edited by
      #3

      ... no effect. setting the version didn't fix it :(

      O 1 Reply Last reply
      0
      • G Great ATuin

        ... no effect. setting the version didn't fix it :(

        O Offline
        O Offline
        Owner drawn
        wrote on last edited by
        #4

        Where did you do it. Note: uTimeout and uVersion is wrapped inside a union so you must be careful. Both cannot be used at once.

        Jesus Lives Forever - Amen:rose:

        --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

        G 1 Reply Last reply
        0
        • O Owner drawn

          Where did you do it. Note: uTimeout and uVersion is wrapped inside a union so you must be careful. Both cannot be used at once.

          Jesus Lives Forever - Amen:rose:

          --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

          G Offline
          G Offline
          Great ATuin
          wrote on last edited by
          #5

          right after ndata.cbSize = sizeof(NOTIFYICONDATA);

          O 2 Replies Last reply
          0
          • G Great ATuin

            right after ndata.cbSize = sizeof(NOTIFYICONDATA);

            O Offline
            O Offline
            Owner drawn
            wrote on last edited by
            #6

            No you are wrong. First set the icon:

            Shell_NotifyIcon(NIM_ADD, &ndata);
            

            Then the set the version:

            ndata.uVersion = NOTIFYICON_VERSION;
            Shell_NotifyIcon(NIM_SETVERSION, &ndata);
            

            The reason being that you cannot use both uVersion and uTimeout together since they are wrapped inside a union.

            Jesus Lives Forever - Amen:rose:

            --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

            1 Reply Last reply
            0
            • G Great ATuin

              right after ndata.cbSize = sizeof(NOTIFYICONDATA);

              O Offline
              O Offline
              Owner drawn
              wrote on last edited by
              #7

              The code that you gave is working here, with the following modifications... _tcscpy(ndata.szInfoTitle,_T("Test")); _tcscpy(ndata.szInfo, _T("Test"));

              Jesus Lives Forever - Amen:rose:

              --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

              G 1 Reply Last reply
              0
              • O Owner drawn

                The code that you gave is working here, with the following modifications... _tcscpy(ndata.szInfoTitle,_T("Test")); _tcscpy(ndata.szInfo, _T("Test"));

                Jesus Lives Forever - Amen:rose:

                --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

                G Offline
                G Offline
                Great ATuin
                wrote on last edited by
                #8

                ok here's my new code: ZeroMemory(&ndata, sizeof(NOTIFYICONDATA)); ndata.cbSize = sizeof(NOTIFYICONDATA); ndata.hWnd = m_hWnd; ndata.uFlags = NIF_ICON | NIF_MESSAGE; ndata.uID = IDI_DISABLED; ndata.uCallbackMessage = WM_POPUP; ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_DISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); Shell_NotifyIcon(NIM_ADD, &ndata); ndata.uVersion = NOTIFYICON_VERSION; Shell_NotifyIcon(NIM_SETVERSION, &ndata); ndata.uTimeout = 10000; ndata.uFlags |= NIF_INFO; _tcscpy(ndata.szInfoTitle,_T("Test")); _tcscpy(ndata.szInfo, _T("Test")); Shell_NotifyIcon(NIM_MODIFY, &ndata); but still no balloon :wtf:

                O 2 Replies Last reply
                0
                • G Great ATuin

                  ok here's my new code: ZeroMemory(&ndata, sizeof(NOTIFYICONDATA)); ndata.cbSize = sizeof(NOTIFYICONDATA); ndata.hWnd = m_hWnd; ndata.uFlags = NIF_ICON | NIF_MESSAGE; ndata.uID = IDI_DISABLED; ndata.uCallbackMessage = WM_POPUP; ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_DISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); Shell_NotifyIcon(NIM_ADD, &ndata); ndata.uVersion = NOTIFYICON_VERSION; Shell_NotifyIcon(NIM_SETVERSION, &ndata); ndata.uTimeout = 10000; ndata.uFlags |= NIF_INFO; _tcscpy(ndata.szInfoTitle,_T("Test")); _tcscpy(ndata.szInfo, _T("Test")); Shell_NotifyIcon(NIM_MODIFY, &ndata); but still no balloon :wtf:

                  O Offline
                  O Offline
                  Owner drawn
                  wrote on last edited by
                  #9

                  You don't need to modify anything .... Yeah Because szInfo is TCHAR and szInfoTitle is also TCHAR so you must use _tcscpy to copy strings... You can use the original code with the modifications that I told. i.e. Replace wcscpy with _tcscpy

                  Jesus Lives Forever - Amen:rose:

                  --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

                  1 Reply Last reply
                  0
                  • G Great ATuin

                    ok here's my new code: ZeroMemory(&ndata, sizeof(NOTIFYICONDATA)); ndata.cbSize = sizeof(NOTIFYICONDATA); ndata.hWnd = m_hWnd; ndata.uFlags = NIF_ICON | NIF_MESSAGE; ndata.uID = IDI_DISABLED; ndata.uCallbackMessage = WM_POPUP; ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_DISABLED), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); Shell_NotifyIcon(NIM_ADD, &ndata); ndata.uVersion = NOTIFYICON_VERSION; Shell_NotifyIcon(NIM_SETVERSION, &ndata); ndata.uTimeout = 10000; ndata.uFlags |= NIF_INFO; _tcscpy(ndata.szInfoTitle,_T("Test")); _tcscpy(ndata.szInfo, _T("Test")); Shell_NotifyIcon(NIM_MODIFY, &ndata); but still no balloon :wtf:

                    O Offline
                    O Offline
                    Owner drawn
                    wrote on last edited by
                    #10

                    I did set the IE version to 0x0500

                    #define _WIN32_IE 0x0500
                    
                    ndata.cbSize=sizeof(NOTIFYICONDATA);
                    ndata.hWnd = m_hWnd;
                    ndata.uFlags = NIF_ICON | NIF_MESSAGE | NIF_INFO;
                    ndata.uID = 123;
                    ndata.dwInfoFlags = NIIF_ERROR;
                    
                    ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 
                    
                    ndata.uCallbackMessage = 0;
                    ndata.uTimeout = 10000;
                    
                    _tcscpy(ndata.szInfoTitle,_T("Test"));
                    _tcscpy(ndata.szInfo, _T("Test")); 
                    
                    Shell_NotifyIcon(NIM_ADD, &ndata);
                    

                    This works...

                    Jesus Lives Forever - Amen:rose:

                    --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

                    G 1 Reply Last reply
                    0
                    • O Owner drawn

                      I did set the IE version to 0x0500

                      #define _WIN32_IE 0x0500
                      
                      ndata.cbSize=sizeof(NOTIFYICONDATA);
                      ndata.hWnd = m_hWnd;
                      ndata.uFlags = NIF_ICON | NIF_MESSAGE | NIF_INFO;
                      ndata.uID = 123;
                      ndata.dwInfoFlags = NIIF_ERROR;
                      
                      ndata.hIcon = (HICON) LoadImage(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); 
                      
                      ndata.uCallbackMessage = 0;
                      ndata.uTimeout = 10000;
                      
                      _tcscpy(ndata.szInfoTitle,_T("Test"));
                      _tcscpy(ndata.szInfo, _T("Test")); 
                      
                      Shell_NotifyIcon(NIM_ADD, &ndata);
                      

                      This works...

                      Jesus Lives Forever - Amen:rose:

                      --Owner drawn:rose: --An eye for an eye makes the whole world blind. --If you find my post helpful then do rate it. --Jesus is Lord:rose:

                      G Offline
                      G Offline
                      Great ATuin
                      wrote on last edited by
                      #11

                      yesss. that's it. i forgot the #define. ok man thank you! i appreciate your efforts!

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups