Solved

How to use CloseWindow ?

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 91
delphi parse string to params 3 136
Delphi...Split view - idea? 1 88
Multi-layered image in FireMonkey 9 48
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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