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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close another Windows App from FoxPro 1

Status
Not open for further replies.

tonytrini

Programmer
Nov 23, 2000
8
TT
Hi,

Can any tell me how to close another Windows Application from within a FoxPro program?
 
Hi,
You can FindWindow & SendMessage API

Declare long FindWindow in win32api string cclass, string ccaption

Declare long SendMessage in Win32Api long hwnd, long wparam, long lparam

hwnd = FindWindow(NULL,"Window Caption")


=SendMessge(hwnd,17,32) && WM_CLOSE = 32

Hope it helps

Jimmy


 
Hi Tony,

FWIW, I would advocate you use the PostMessage function instead of the SendMessage function. SendMessage places a message on the message stack and waits until the message is processed from the stack. PostMessage simply places the message on the stack and returns.

If you use SendMessage and the corresponding application is in a modal state(ie, getfile or savefile dialog box), be prepared for your app to hang until the modal state is resolved in the offending app.

Just my two cents.

For an example of the PostMessage functions, see: thread184-34969 Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top