Solved

How to use CloseWindow ?

Posted on 1998-12-03
4
803 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

Independent Software Vendors: 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

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