• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 333
  • Last Modified:

Hiding a window from the taskbar, but retaining the standard icons in the top right

Hello,

I have a requirement to control (minimize and restore mainly) certain windows owned by other applications, without them ever showing up on the taskbar.

I tried something similar to the code below:

ShowWindow(Handle, SW_HIDE);
SetWindowLong(Handle, GWL_EXSTYLE,
 GetWindowLong(Handle, GWL_EXSTYLE)
   or WS_EX_TOOLWINDOW and not WS_EX_APPWINDOW);

And of course it works, but I don't want the windows to appear as tool windows - I'd like them to look like 'proper' windows :-)

Can this be done?
0
timns
Asked:
timns
  • 6
  • 5
1 Solution
 
DaFoxCommented:
Hi.

AFAIK this only works for Delphi apps, since there are two windows (Application.Handle & Form1.Handle). Application.Handle is responsible for the taskbar button. But this is a delphi behavior.
So, what I would suggest is to hack the SysTabControl32 get the items and close (one of) them.
Don't know if this is the only (and best) solution, though.

-

FindWindow('Shell_TrayWnd', nil);
Wnd := FindWindowEx(h, 0, 'SysTabControl32', nil);
cnt := SendMessage(h, TCM_GETITEMCOUNT, 0, 0)
...

-

Oh, btw: You gotta be in explorer's address space, of course!

Good luck,
Markus
0
 
timnsAuthor Commented:
Sounds nasty ;-)

I have seen only one application which seems to have the behaviour I want to mimic, which is the Apache Service Monitor...

 
0
 
DaFoxCommented:
Yeah, it actually is a bad hack for such a ordinary task...

Could you give me the complete download address for this monitor? I'm too lazy to search it myself ;)
I want to have a look at it, so that I know exactly want you want to imitate. Altough I don't think that the program will be much helpful to find a nicer solution than the one above.

Markus
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
timnsAuthor Commented:
The url is
http://nagoya.apache.org/mirror/httpd/binaries/win32/#stable

But be warned it's a big download, although of course you end up with the lovely apache web server software if you like that sort of thing.

0
 
DaFoxCommented:
I found another way. Problem: Works only if IE 4.0 or above is installed and after every minimzing, maximizing, ... the button appears again.

Let's see if it is helpful for you:

{ uses ComObj }

const
  CLSID_TaskbarList: TGUID = '{56FDF344-FD6D-11d0-958A-006097C9A090}';
type
  ITaskbarList = interface
    ['{56FDF342-FD6D-11d0-958A-006097C9A090}']
       { virtual HRESULT STDMETHODCALLTYPE HrInit( void) = 0;}
       function HrInit: HResult; stdcall;
       { virtual HRESULT STDMETHODCALLTYPE AddTab(/* [in] */ HWND hwnd) = 0; }
       function AddTab(hwnd: Cardinal): HResult; stdcall;
       { virtual HRESULT STDMETHODCALLTYPE DeleteTab(/* [in] */ HWND hwnd) = 0; }
       function DeleteTab(hwnd: Cardinal): HResult; stdcall;
      { virtual HRESULT STDMETHODCALLTYPE ActivateTab(/* [in] */ HWND hwnd) = 0; }
       function ActivateTab(hwnd: Cardinal): HResult; stdcall;
      { virtual HRESULT STDMETHODCALLTYPE SetActiveAlt(/* [in] */ HWND hwnd) = 0; }
       function SetActiveAlt(hwnd: Cardinal): HResult; stdcall;
  end;

// ...

procedure TForm1.Button1Click(Sender: TObject);
const
  CLSID_TaskBarList: TGUID ='{56FDF344-FD6D-11D0-958A-006097C9A090}';
  IID_ITaskBarList: TGUID ='{56FDF342-FD6D-11D0-958A-006097C9A090}';
var
  FTaskbarList: ITaskBarList;
  Wnd: hWnd;
begin
 Wnd := FindWindow('IEFrame',nil);
  if (Wnd <> 0) then
  begin
     FTaskbarList := CreateComObject(CLSID_TaskbarList) as ITaskbarList;
     FTaskbarList.HrInit;
     FTaskbarList.HrInit;
     FTaskbarList.DeleteTab(Wnd);
  end;
end;

Markus

PS: Didn't download it yet. I don't want to install apache ;)
0
 
timnsAuthor Commented:
Markus, I do admire your doggedness here. I'm beginning to think I'll be unable to quite achieve the functionality I really need, although I did find your code snippets extremely educational! :)
0
 
DaFoxCommented:
I don't think that it is impossible! To achieve your aim you definitely have to make use of some (bad) hacks. And the question is if this ordinary feature (hiding taskbar button) justifies the use of this hacks.

But (!!) you are able to achieve this functionality! If you don't believe me I'll do some code to convince you... ;)

Markus
0
 
timnsAuthor Commented:
Oh yes, please - convince away... but don't kill yourself over it. I figure you've probably earned your points by now anyway.

Thanks.

Tim
0
 
DaFoxCommented:
Hehe, I knew that you'll say that. ;-)
No problem, but please give me some time!!!

Markus
0
 
DaFoxCommented:
Tim, I'm working on it! Unfortunately I don't have enough time to finish the DLL atm.

How should the DLL work? Do you want the it to search for hWnds, window classes or window captions? Should the DLL avoid that there are task button created or do you want to remove buttons that are already shown on the taskbar?
Sorry, I think I don't have the time to add all of these features, that's why I'm asking. Expanding the functionality of the DLL shouldn't be a problem for you, though.

Markus

PS: The first release of my sample will only work on Win2k!
0
 
timnsAuthor Commented:
Markus

I really appreciate your effort here, so I've increased the points for a start.

I want to remove buttons from the taskbar for all windows with a certain classname, although of course I can create my own list of hWnds and pass that in.

And I also want to prevent taskbar buttons appearing when the window is restored, I'm afraid.

Tim.
0
 
CleanupPingCommented:
timns:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

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