Solved

Removing the app's Taskbar button

Posted on 1997-08-29
3
207 Views
Last Modified: 2013-11-20
I'm trying to fill the NOTIFYICONDATA struct and pass it to
Shell_NotifyIcon() to delete my app's icon from the taskbar, but the Shell_NotifyIcon() method fails.  ( I'd also like to be able to add its icon in the system tray.)

I create an SDI app with the wizard, and put the following code at the end of InitInstance():

      NOTIFYICONDATA tnid;
      int res;

      tnid.cbSize = sizeof(NOTIFYICONDATA);
      tnid.hWnd = m_pMainWnd->m_hWnd;
      tnid.uID = IDR_MAINFRAME;
      tnid.uFlags = NIF_ICON;
      tnid.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
      tnid.szTip[0] = '\0';
         
      res = Shell_NotifyIcon(NIM_DELETE, &tnid);

I must be setting some of the fields incorrectly.  Does someone know how to fill this struct?  Am I missing something?

Thanks!

P.S. Is the code/process any different for a dialog-based app?
0
Comment
Question by:mcsilver
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
davmarc earned 100 total points
ID: 1305268
I think you misunderstood the documentation.
Shell_NotifyIcon() adds/deletes/changes only icons in the status area of the taskbar (also known as Tray Notification Area).
Hence it can help you with your second request - adding an icon to the system tray.

If you want your app not to be shown in the taskbar like all other processes generally are, you should not create any windows...alternatively, try registering your app as a service.

Davide Marcato.
0
 
LVL 1

Author Comment

by:mcsilver
ID: 1305269
The answer given was clear and easy to understand.  And it did clear up some confusion that I had.  But as for getting my code (included in the question) to work, the question was not answered.  Even if what it's supposed to do is to put an icon in the System Tray, the code still fails. :(  Help.  Also, for implementing the first part of the question, I just looked up "register" and "service" in the help and got no where.  Help.
0
 
LVL 4

Expert Comment

by:davmarc
ID: 1305270
Your code tries to remove a TNA icon that simply doesn't exist, that's why it doesn't work. This cannot be resolved.
If you want to *add* an icon, call Shell_NotifyIcon(NIM_ADD, &tnid).

As for the service thing, call RegisterServiceProcess().

Davide Marcato.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question