Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing another application

Status
Not open for further replies.

Nephila

Programmer
May 14, 2002
13
ZA
How can I close a command window from my delphi program?

Thanks!
 
If you know the window's handle;
Code:
SendMessage(WindowHandle, WM_SYSCOMMAND, SC_CLOSE, 0)
 
You can get the window handle by using the Findwindow command.

Handle := FindWindow(PChar(ApplicationClassName),Pchar(MainFormWindowName));

The application class name will be TApplication for a delphi application, and the MainFormWindowName will is typically the caption on the main form opened from the .dpr. The Winsight tool that comes with delphi will show you the class name and main window name as well, if you don't already know them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top