Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 869
  • Last Modified:

Hide Task Bar Icons

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
DarrinE
Asked:
DarrinE
  • 7
  • 7
1 Solution
 
gelbertCommented:
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
 
DarrinEAuthor Commented:
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
 
MadshiCommented:
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
DarrinEAuthor Commented:
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
 
MadshiCommented:
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
 
MadshiCommented:
I meant of course: "The rest is the same AS in Win95."...
0
 
DarrinEAuthor Commented:
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
 
DarrinEAuthor Commented:
under win95 there is no ReBarWindow32 thats why my function did not work - do you mind if I delete the question ??
0
 
DarrinEAuthor Commented:
I did not realise that you picked it earlier (I did not read your comment correctly)

Heres the points !!

Thanks

DarrinE
0
 
MadshiCommented:
This way it should work:

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

Regards, Madshi.
0
 
MadshiCommented:
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
 
DarrinEAuthor Commented:
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
 
MadshiCommented:
>> 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
 
DarrinEAuthor Commented:
It does a lot of little things - like emulate the NT Lockdown dialog
0
 
MadshiCommented:
Well, then please send me a copy to "madshi@gmx.net". Thank you...   :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

  • 7
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now