Click here to Skip to main content
15,891,316 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to know how we can close a specific window using or not using windows API. I know how to get the windows handle(hWnd), so i think I can use it to do something. I use the winAPI's function DistroyWindow(IntPtr hWnd) but nothing happen. help me there!!!
Posted

Send (or post) a WM_CLOSE message to the window.
 
Share this answer
 
Comments
Olivier Levrey 21-Apr-11 8:03am    
My 5.
[no name] 21-Apr-11 8:48am    
well that doesn't work on seven or vista...thanks for posting
#realJSOP 21-Apr-11 9:06am    
Well, you're not doing it right, then. Windows is windows. Every Windows API function still works on Vista and Windows 7.
Sergey Alexandrovich Kryukov 21-Apr-11 14:35pm    
Correct, a 5. OP, do it right.
--SA
[no name] 25-Apr-11 5:27am    
ok...I've tried both and only the postMessage have work!!!
John is right.
Use SendMessage or PostMessage functions from WIN32 API with WM_CLOSE message.
 
Share this answer
 
Comments
[no name] 21-Apr-11 8:48am    
well that doesn't work on seven or vista...thanks for posting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900