Delete HWND Object

I have a situation where when I receive a message, I have to remove the window only from hWnd. Although this should be possible, since it CreateWindowExcreates an object by returning an HWND, I should be able to delete it.

Note: hWnd lies on some other process.

+5
source share
2 answers

The correct way is to send the WM_CLOSE message to the appropriate window, or simply call DestroyWindow , which will send the WM_DESTROY message to the window.

A thread cannot use DestroyWindow to destroy a window created by another thread.

The difference between WM_CLOSE and WM_DESTROY:

WM_CLOSE , WM_CLOSE DestroyWindow, .

, WM_CLOSE , "", WM_DESTROY, . , WM_DESTROY.

HWND , !

, , WM_CLOSE.

+6

a WM_CLOSE SendMessage.

+3

All Articles