Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1052023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:01:35+00:00 2026-05-16T17:01:35+00:00

i wanna make a program runs in the background and shows an icon in

  • 0

i wanna make a program runs in the background and shows an icon in notification area of taskbar. I’m using win32. What api should i use? Do you know any good tutorials?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T17:01:35+00:00Added an answer on May 16, 2026 at 5:01 pm

    To make a program run in the background, you either add it as a service or make it “unavailable” to shutdown (for instance, hide the window for the program). To add an icon in the toolbar you use winapi. Call Shell_NotifyIcon and pass in a NOTIFYICONDATA structure

    This should be defined somewhere

    enum TrayIcon {
        ID = 13, CALLBACKID = WM_APP+1
    };
    

    Also, in the below code the hWnd is a HWND, which is the window that you want to associate with the notification icon. This HWND's wndProc will receive the messages for the icon.

    Notes:

    • the NIF_ICON flag makes the hIcon valid in the NOTIFICATIONICONDATA structure. So if you don’t want to have an icon, don’t specify it.
    • the NIF_MESSAGE flag makes the uCallbackMessage valid. If you don’t want to handle any messages, don’t specify this flag.
    • You have to remove the icon before you shut down your program, or it will get stuck there until you hover over it
    • At startup of your computer, Shell_NotifyIcon may have some difficulties to succeed. I can’t find the reference for it, but I know I have read it somewhere.. So, when not successful, don’t assume that it will not work at all – just try again.

    With this said, this is how you add, remove and handle the messages for the tray icon

    To add the icon

    // in HICON hIcon: this is the icon you want as the image in the tray
    NOTIFYICONDATA nid;
    nid.cbSize = sizeof(NOTIFYICONDATA);
    nid.hWnd = hWnd;
    nid.uID = ID;
    nid.uFlags = NIF_ICON | NIF_MESSAGE;
    nid.hIcon = hIcon;
    nid.uCallbackMessage = /*TrayIcon::*/CALLBACKID;
    Shell_NotifyIcon(NIM_ADD, &nid);
    

    To remove the icon

    NOTIFYICONDATA nid;
    nid.cbSize = sizeof(NOTIFYICONDATA);
    nid.hWnd = hWnd;
    nid.uID = /*TrayIcon::*/ID;
    Shell_NotifyIcon(NIM_DELETE, &nid);
    

    Handling the messages for the icon

    LRESULT wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){
        switch (msg){
            // ...
            case /*TrayIcon::*/CALLBACKID:
            {
                // here, you handle the messages for your tray icon
            }
            break;
            // ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna make use of the Ternary Operator with an object. if($msg == 'hello'){
I wanna get the Timedate value from another page using request.querystring and then use
I wanna write a little c++ program using libcurl. It's for a school project
I wanna make a function that erases everything inside of a multiple select using
I wanna add server controls by using javascript. The main purpose of why I
how can i make java program working with multiple languages (frensh, english , arabic
I wanna make a text editor but its different other text editors.It will get
i need to make a cron job to run a java program every 40
I have a puzzling problem with trying to make an ajax/static state program. What
i wanna make really sure, that a user can upload large files to my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.