CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    1

    Application that displays an icon in the system tray and not in the taskbar?

    How can i make an application that displays an icon in the system tray and not in the taskbar?
    And how can i make it without any icon? I mean, like winamp.


  2. #2
    Join Date
    May 1999
    Posts
    19

    Re: Application that displays an icon in the system tray and not in the taskbar?

    Use Shell_NotifyIcon() API,

    [email protected]
    B'lore,
    India.


  3. #3
    Guest

    Re: Application that displays an icon in the system tray and not in the taskbar?


    This is a sample code which displays an icon with a context menu in the systemtray. Use can the code by changing the menu identifier,icon identifier etc..

    Partha Sarathy

    #define WM_ICONNOTIFY WM_USER + 1

    LRESULT CEmailGUIDlg:efWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
    {
    NOTIFYICONDATA nid;


    switch(message)
    {
    case WM_CREATE :
    nid.cbSize = sizeof(nid);
    nid.hWnd = m_hWnd;
    nid.uID = 1;
    nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
    nid.uCallbackMessage = WM_ICONNOTIFY;
    nid.hIcon = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_SAMPLE));
    strcpy(nid.szTip,"System Tray");
    Shell_NotifyIcon(NIM_ADD,&nid);
    break;


    case WM_ICONNOTIFY :
    if((UINT)lParam == WM_LBUTTONDOWN)
    {
    ::ShowWindow(m_hWnd,SW_SHOW);
    ::SetForegroundWindow(m_hWnd);
    }
    if((UINT)lParam == WM_RBUTTONDOWN)
    {
    CMenu menu,*SubMenu;
    menu.LoadMenu(IDR_ICONMENU);
    SubMenu = menu.GetSubMenu(0);
    // Make first menu item the default (bold font)
    ::SetMenuDefaultItem(SubMenu->m_hMenu, 0, TRUE);

    CPoint point;
    GetCursorPos(&point);
    ::SetForegroundWindow(m_hWnd);
    SubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,point.x,point.y,this);

    ::PostMessage(m_hWnd,WM_ICONNOTIFY, 0, 0);
    menu.DestroyMenu();
    }

    break;

    case WM_DESTROY :
    nid.cbSize = sizeof(nid);
    nid.hWnd = m_hWnd;
    nid.uID = 1;
    nid.uFlags = 0;
    Shell_NotifyIcon(NIM_DELETE,&nid);
    PostQuitMessage(0);
    break;
    default :
    break;
    };


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured