Solved

How to use CloseWindow ?

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now