Solved

Removing the app's Taskbar button

Posted on 1997-08-29
3
204 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to monitor remote shell execution on linux 9 97
only14 challenge 19 68
ShiftLeft challenge 21 76
how to use laptop or pad camera in vb.net windows application 2 49
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now