Solved

Hide Task Bar Icons

Posted on 2000-03-10
15
858 Views
Last Modified: 2013-12-03
The following code works perfectly in win98 - but in win95 the taskbar icons are still visible ?

The taskbar icons reside in what I think is the SysTabControl32 class - SPY says that the heirachy is the same yet the code fails to hide the icons ?

DarrinE

int WINAPI HideIt (void)
{
  // The visible DeskTop is NOT the Desktop refered to by
  // the Win32 API, like the GetDesktopWindow()

      // Find the Programm Managers main Window
  // Param:   pointer to class name,  pointer to window name
  hPMWnd    = FindWindow("Progman", NULL);
 

  // The Progman has a chain of childs
  //   1) SHELLDLL_DefView (1820FED0-473E-11D0-A96C-00C04FD705A2)
  //   2)   SysListView32
  //   3)     SysHeader32
  // The same hirachy is used by the Explorer
  // Some part of the documentation mentioned that the 1) level is
  // used as well with the WebView
  //
  // Param:  handle to parent window, handle to child window
  // Param:  pointer to class name,  pointer to window name
  hDVWnd    = FindWindowEx(hPMWnd, NULL, "SHELLDLL_DefView", NULL);

 
  // since we just clean up (hopefully someone will awake us)
  // remove the taskbar as well, there may be still someone out
  // there who does not have auto background set for it
  //
  // This includes everything in it, excluding the Notify Window

  hTBWnd    = FindWindow("Shell_TrayWnd", NULL);

  hBVWnd    = FindWindowEx(hTBWnd, NULL, "Button", NULL);

  hRBWnd = FindWindowEx(hTBWnd, NULL, "ReBarWindow32", NULL);

  hMSTWnd = FindWindowEx(hRBWnd, NULL, "MSTaskSwWClass", NULL);

  hSTWnd = FindWindowEx(hMSTWnd, NULL, "SysTabControl32", NULL);


/*  
  hBVWnd = FindWindow("Button", NULL);

  hRBWnd = FindWindow("ReBarWindow32", NULL);

  hMSTWnd = FindWindow("MSTaskSwWClass", NULL);

  hSTWnd = FindWindow("SysTabControl32", NULL);
*/  

  //
  // the SysListView and below is not used if it is a Progman
  // at least it is not visible
 
  // hLCWnd    = FindWindowEx(hDVWnd, NULL, "SysListView32", NULL);
  //
  // hiding of the application window would hide everything,
  // but why hitting hard if softly does it as well
  //
  // Param:  handle to window,  show state of window);
  ShowWindowAsync(hDVWnd, SW_HIDE);
  ShowWindowAsync(hBVWnd, SW_HIDE);
  ShowWindowAsync(hRBWnd, SW_HIDE);  
  ShowWindowAsync(hMSTWnd, SW_HIDE);  
  ShowWindowAsync(hSTWnd, SW_HIDE);

//  ShowWindowAsync(hTBWnd, SW_HIDE);

  return(0);
  /* tell errorlevel the out come of the operation */
}



int WINAPI ShowIt(void)
{

  // ShowWindowAsync(hPMWnd, SW_SHOW);
  ShowWindowAsync(hDVWnd, SW_SHOW);
  ShowWindowAsync(hTBWnd, SW_SHOW);
  ShowWindowAsync(hBVWnd, SW_SHOW);

  ShowWindowAsync(hRBWnd, SW_SHOW);  
  ShowWindowAsync(hMSTWnd, SW_SHOW);  
  ShowWindowAsync(hSTWnd, SW_SHOW);


return 0;

}
0
Comment
Question by:DarrinE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 7
15 Comments
 
LVL 8

Expert Comment

by:gelbert
ID: 2605136
Adding and Deleting Taskbar Icons


You add an icon to the taskbar status area by filling in a NOTIFYICONDATA structure and then passing the structure to Shell_NotifyIcon with the NIM_ADD message. The structure members must specify the handle to the window that is adding the icon, as well as the icon identifier and icon handle. You can also specify ToolTip text for the icon. If you need to receive mouse messages for the icon, specify the identifier of the callback message that the system should use to send the message to the window procedure.

The function in the following example demonstrates how to add an icon to the taskbar.

// MyTaskBarAddIcon - adds an icon to the taskbar status area.
// Returns TRUE if successful, or FALSE otherwise.
// hwnd - handle to the window to receive callback messages.
// uID - identifier of the icon.
// hicon - handle to the icon to add.
// lpszTip - ToolTip text.
BOOL MyTaskBarAddIcon(HWND hwnd, UINT uID, HICON hicon, LPSTR lpszTip)
{
    BOOL res;
    NOTIFYICONDATA tnid;
 
    tnid.cbSize = sizeof(NOTIFYICONDATA);
    tnid.hWnd = hwnd;
    tnid.uID = uID;
    tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    tnid.uCallbackMessage = MYWM_NOTIFYICON;
    tnid.hIcon = hicon;
    if (lpszTip)
        lstrcpyn(tnid.szTip, lpszTip, sizeof(tnid.szTip));
    else
        tnid.szTip[0] = '\0';
 
    res = Shell_NotifyIcon(NIM_ADD, &tnid);
 
    if (hicon)
        DestroyIcon(hicon);
 
    return res;
}

To delete an icon from the taskbar status area, fill a NOTIFYICONDATA structure and send it to the system when you send an NIM_DELETE message. When deleting a taskbar icon, specify only the cbSize, hWnd, and uID members, as the following example shows.

// MyTaskBarDeleteIcon - deletes an icon from the taskbar
//     status area.
// Returns TRUE if successful, or FALSE otherwise.
// hwnd - handle to the window that added the icon.
// uID - identifier of the icon to delete.
BOOL MyTaskBarDeleteIcon(HWND hwnd, UINT uID)
{
    BOOL res;
    NOTIFYICONDATA tnid;
 
    tnid.cbSize = sizeof(NOTIFYICONDATA);
    tnid.hWnd = hwnd;
    tnid.uID = uID;
         
    res = Shell_NotifyIcon(NIM_DELETE, &tnid);
    return res;
}

0
 
LVL 2

Author Comment

by:DarrinE
ID: 2606018
I'm sorry I must not have been clear - its not the icons in the system trya I am playing with but the icons on the taskbar when a window becomes minimized - my program hides the desktop and everything else except the taskbar and system tray

In win95 - the icons of minimized windows do no hide whereas in win98 the code I have posed works - why ?
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607269
Use this one:

function GetTaskButtonWindow : dword;
var c1 : dword;
begin
  result := FindWindow('Shell_TrayWnd', '');
  if result <> 0 then begin
    c1 := FindWindowEx(result, 0, 'ReBarWindow32', '');
    if c1 <> 0 then result := FindWindowEx(c1, 0, 'MSTaskSwWClass', '')
    else            result := FindWindowEx(result, 0, 'MSTaskSwWClass', '');
  end;
end;

Regards, Madshi.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 2

Author Comment

by:DarrinE
ID: 2607273
I'll try to convert it to C - I dont work with Delphi at all <s> - if you get the chance to convert it it would be nice

DarrinE
0
 
LVL 20

Accepted Solution

by:
Madshi earned 100 total points
ID: 2607280
Well, I can read C++, but I'm not good in writing it. But it should be really easy to convert those 5 lines. Basically it's only API calls to FindWindow(Ex) - the same that your code does. The extra thing in Win98 is that there's a child window ReBarWindow32, that wasn't there in Win95. The rest is the same in Win95.

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607282
I meant of course: "The rest is the same AS in Win95."...
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2607288
OK - I converted it as follows - it did not work

hTBWnd    = FindWindow("Shell_TrayWnd", NULL);

  if (hTBWnd)
  {
      hBVWnd    = FindWindowEx(hTBWnd, NULL, "Button", NULL);
      hRBWnd    = FindWindowEx(hTBWnd, NULL, "ReBarWindow32", NULL);

      if(hRBWnd)
            hMSTWnd = FindWindowEx(hRBWnd, NULL, "MSTaskSwWClass", NULL);
      else
        hMSTWnd = FindWindow("MSTaskSwWClass", NULL);

      if (hMSTWnd)
       hSTWnd = FindWindowEx(hMSTWnd, NULL, "SysTabControl32", NULL);
  }

I get the same result - on win98 it works on win95 it does not

The MSTaskSwWClass for some reason cannot be found although under spy - its there - strange

Any other ideas ??

Darrin
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2607339
under win95 there is no ReBarWindow32 thats why my function did not work - do you mind if I delete the question ??
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2607355
I did not realise that you picked it earlier (I did not read your comment correctly)

Heres the points !!

Thanks

DarrinE
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607359
This way it should work:

if(hRBWnd)
hMSTWnd = FindWindowEx(hRBWnd, NULL, "MSTaskSwWClass", NULL);
else
        hMSTWnd = FindWindowEx(hTBWnd, "MSTaskSwWClass", NULL);

Regards, Madshi.
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607362
P.S: It would be better to use an empty string (don't know in C++, perhaps "" ?) instead of NULL, cause these windows really have an empty window text. If you give in NULL, you might get a different window with the same window class but with a window text.
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2607384
These classes dont have a string so far as I can tell

Many thanks for the help

If you send me a private email I'll send to you the program (only 165k)

DarrinE
dwe@primus.com.au
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607406
>> These classes dont have a string so far as I can tell

That's exactly the reason why you can give in "" instead of NULL...   :-)

>> If you send me a private email I'll send to you the program (only 165k)

Thank you. What does this program do? If it only hides the taskbar icons/buttons, I don't need it...   (-:

Regards, Madshi.
madshi@gmx.net
0
 
LVL 2

Author Comment

by:DarrinE
ID: 2607421
It does a lot of little things - like emulate the NT Lockdown dialog
0
 
LVL 20

Expert Comment

by:Madshi
ID: 2607454
Well, then please send me a copy to "madshi@gmx.net". Thank you...   :-)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

762 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