[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Removing the app's Taskbar button

Posted on 1997-08-29
3
Medium Priority
?
217 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 200 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

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…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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