Solved

How to hide other window program

Posted on 2001-07-02
5
219 Views
Last Modified: 2010-04-06
How to hide or deactivate other running Window programs ?
When I run my application, I want to hide/deactivate all applications which active at that time.
So the only running application is my application.

Thanks,
Hendra
0
Comment
Question by:hjohari
[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
  • 2
5 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 6244709
Hi hjohari,

Add this code to your OnCreate Event:

procedure tForm1.FormCreate ( Sender:TObject);
var
  h:HWnd;
begin
  h:=handle;
  while h > 0 do
  begin
  if isWindowVisible(h) then
    ShowWindow(h,SW_HIDE );
    h:=getnextwindow(h,GW_HWNDNEXT);
  end;
  ShowWindow(handle,SW_HIDE );
end;

// dont forgent to show the windows again ;-)

Best Regards

Cesario
0
 
LVL 17

Expert Comment

by:inthe
ID: 6244760
hi,

>>dont forgent to show the windows again ..

with even the taskbar being hidden here you'd have to save those handles somewhere (maybe ini file?) as theres no WasWindowVisibleBefore_I_Hid_It() api to know what was not hidden before :-)
0
 
LVL 8

Accepted Solution

by:
Cesario earned 50 total points
ID: 6244816
I argree with inthe,

you can use a Open Array to store the handles...

VAR
  hiddenwindows : Array OF TWND;

procedure tForm1.FormCreate ( Sender:TObject);
var
 h:HWnd;
begin
 SetLength ( hiddenwindows,0);
 h:=handle;
 while h > 0 do
 begin
   if isWindowVisible(h) then
     ShowWindow(h,SW_HIDE );
     h:=getnextwindow(h,GW_HWNDNEXT);
    SetLength(hiddenwindows,Length(hiddenwindows)+1);
    hiddenwindows[High(hiddenwindows)] := H;
 end;
 ShowWindow(handle,SW_HIDE );
end;

to show them again

VAR
 cnt : Integer;

begin
  For cnt := 0 To High(hiddenwindows) DO
     ShowWindow(h,SW_SHOW );
  SetLength(hiddenwindows);

Best Regards

Cesario
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8701442
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept Cesario's comment as answer

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 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