Solved

Removing the app's Taskbar button

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

705 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

14 Experts available now in Live!

Get 1:1 Help Now