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

window maipulation(C++) 2

Status
Not open for further replies.

Leibnitz

Programmer
Apr 6, 2001
393
CA
I will like to know how to close a window wen you know his title.
Exemple:eek:nce you've open "My documents" by this code:
ShellExecute
(HWND_DESKTOP,open,"c:\\my documents",NULL,NULL,SW_SHOWNORMAL),
how to close it ?
 
Use FindWindow API to Find the Window by it's name. Then you get the window's HWND if the system find's it, otherwise NULL is returned.

HWND FindWindow(
LPCTSTR lpClassName, // class name
LPCTSTR lpWindowName // window name
);

To know lpClassName of a window beforehand use Spy++ that comes with Visual Studio.

When you have the HWND of the window just do:
::SendMessage(myHWND,WM_CLOSE,0,0);

HTH, s-)

Blessed is he who in the name of justice and goodwill, sheperds the weak through the valley of darkness...
 
Thanks Ionel for the explanations it helps a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top