?
Solved

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

Posted on 2003-03-29
12
Medium Priority
?
329 Views
Last Modified: 2010-04-04
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
Comment
Question by:timns
[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
  • 6
  • 5
12 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 8230389
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
 

Author Comment

by:timns
ID: 8238044
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
 
LVL 6

Expert Comment

by:DaFox
ID: 8241726
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.

 

Author Comment

by:timns
ID: 8247463
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
 
LVL 6

Expert Comment

by:DaFox
ID: 8252554
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
 

Author Comment

by:timns
ID: 8274643
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
 
LVL 6

Expert Comment

by:DaFox
ID: 8279256
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
 

Author Comment

by:timns
ID: 8279346
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
 
LVL 6

Expert Comment

by:DaFox
ID: 8279425
Hehe, I knew that you'll say that. ;-)
No problem, but please give me some time!!!

Markus
0
 
LVL 6

Accepted Solution

by:
DaFox earned 1500 total points
ID: 8340257
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
 

Author Comment

by:timns
ID: 8343964
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
 

Expert Comment

by:CleanupPing
ID: 9316549
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 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