Creating system tray icon only app

Hi I'm needing help on how to convert my app to only show an icon in the system tray and not the task bar.

is this a simple thing todo?
Anybody knwo how?

Cheers, s.

Comments

  • : to only show an icon in the system tray and not the task bar.

    after you create your window in WinMain, don't call

    ShowWindow()
    and/or
    UpdateWindow()

    : is this a simple thing todo?

    yes



  • : : to only show an icon in the system tray and not the task bar.
    :
    : after you create your window in WinMain, don't call
    :
    : ShowWindow()
    : and/or
    : UpdateWindow()

    And Windows won't draw your window to screen and you can't see it. And this won't create icon in system tray.

    :
    : : is this a simple thing todo?
    :
    : yes
    :
    :
    :

  • : And Windows won't draw your window to screen and you can't see it. And this won't create icon in system tray.

    oh, forgive me, dear sire. i was assuming that he/she already had his/her program put an icon in the system tray. and all he/she needed to do was keep his/her program from showing in the task bar. pardon me. but if it makes you happy, i'll put the code here...

    [code]//... this is the message our program recieves when something
    //... happens to our icon. i.e. mouse over, mouse click.
    #define TRAY_NOTIFY (WM_USER + 1) //... this goes under our "#include"s



    //... the structure used in displaying our icon.
    NOTIFYICONDATA NIDStruct; //... declare this globally.



    //... put this in our WinMain right after we create your window.

    //... declares everything for NOTIFYICONDATA structure.
    nidStruct.cbSize = sizeof(NOTIFYICONDATA);
    nidStruct.hWnd = hwnd;
    nidStruct.uID = 1;
    nidStruct.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    nidStruct.uCallbackMessage = TRAY_NOTIFY;
    nidStruct.hIcon = LoadImage(hInstance, "ID_Of_Icon", IMAGE_ICON, 16, 16, 0);

    //... the tooltip that is displayed when the mouse is over our icon.
    strcpy(nidStruct.szTip, "Doubleclick icon to exit");

    //... this is very important. this adds the icon to the system tray.
    Shell_NotifyIcon(NIM_ADD, &NIDStruct);



    //... the coordinates of the mouse. used when displaying the menu.
    POINT ptMouse; //... declare this in our window's procedure.



    //... the switch statement, in our window's procedure, should
    //... at least look something like this.
    switch(Message)
    {
    case WM_DESTROY:
    //... this removes the icon from the tray when our program closes.
    NIDStruct.cbSize = sizeof(NOTIFYICONDATA);
    NIDStruct.hWnd = hwnd;
    NIDStruct.uID = 1;

    Shell_NotifyIcon(NIM_DELETE, &NIDStruct);

    PostQuitMessage(0);

    break;

    //... message we will recieve from our icon. i.e. mouse over, mouse click.
    case TRAY_NOTIFY:
    switch (lParam)
    {
    //... if user doubleclicks the icon it closes the program.
    case WM_LBUTTONDBLCLK:
    SendMessage(hwnd, WM_DESTROY, 0, 0);

    break;

    //... if user right clicks the icon it displays a menu.
    case WM_RBUTTONDOWN:
    //... get the coordinates of the mouse pointer.
    GetCursorPos(&ptMouse);

    //... basically, this just makes it possible to use the
    //... keyboard to select menu items.
    SetForegroundWindow(hwnd);

    //... TrackPopupMenu displays the menu and returns the menu
    //... item clicked.
    switch (TrackPopupMenu(GetSubMenu(LoadMenu(hInstance,
    "ID_Of_Menu"), 0), TPM_RETURNCMD | TPM_RIGHTBUTTON,
    ptMouse.x, ptMouse.y, 0, hwnd, NULL))
    {
    //... id of a menu item.
    case IDM_EXIT:
    SendMessage(hwnd, WM_DESTROY, 0, 0);
    break;
    }

    //... free up memory.
    DestroyMenu(LoadMenu(hInstance, "ID_Of_Menu"));

    break;
    }

    break;
    [/code]
    i know its hard to follow but play around with it you'll get it. if you need more help, just post again.

  • Thats great!!

    I'll give it a shot

    Cheers s.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories