Solved

Hide Task Bar Icons

Posted on 2000-03-10
15
854 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
  • 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
 
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

759 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

16 Experts available now in Live!

Get 1:1 Help Now