Solved

Removing the app's Taskbar button

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 149
wordcount challenge 11 145
Not needed 13 129
x-bar in Google Sheets 2 93
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: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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