Solved

How to use CloseWindow ?

Posted on 1998-12-03
4
807 Views
Last Modified: 2010-07-27
Hello !

I use Word 7 with Delphi 3.
To open Word I use this code :
WinExec(PChar('c:\msoffice\winword\winword.exe'),SW_SHOW);
How to know the handle of the Word window to use CloseWindow
to close it ?

Thanx for advance.
0
Comment
Question by:nk51
[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
4 Comments
 

Author Comment

by:nk51
ID: 1349109
I found the shellexecute function return the handle but have you an example of using of this function, please ?
Thanx
0
 
LVL 1

Expert Comment

by:sassas081597
ID: 1349110
NK51!
I have a TLauncher component (made according to R.Konopka) which is a good interface to ShellExecute and ShellExecuteEx functions. If you'd like, I will send its source to you. Give me your E-mail address and I'll send it to you.
SASSAS
0
 
LVL 4

Accepted Solution

by:
BoRiS earned 50 total points
ID: 1349111
nk51

To find the handle for word window and minimize it which is what closewindow does use this code

procedure TForm1.Button1Click(Sender: TObject);
var
Hwd: HWND;
begin
  Hwd := FindWindow('OpusApp', nil);
   CloseWindow(Hwd);
end;

or if wish to close the app down use this code

PostMessage(FindWindow('OpusApp', nil), WM_QUIT, 0, 0);

You can use the FindWindow API to get the handle of an app as first example

Later
BoRiS
0
 

Author Comment

by:nk51
ID: 1349112
For SASSAS :
I'm very interesting by this component.
my email is : nkohut@micropole.com
thanx.

For BORIS :
Your answer is correct BORIS.
You're great !
Thanx.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

695 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