Destroying child window without parent WIN32 API
Question
Tuesday, January 28, 2014 6:40 PM
I have one problem . I am trying to destroy child window ,but it also destroys parent window, so application closes. I have such code
HWND cloneWin =FindWindowEx(hWnd, 0, szChildWin, 0); if (cloneWin) { MessageBox(NULL,"You are trying to create more than one child window\n Current child window will be destroyed", "Message", MB_OK|MB_ICONINFORMATION); DestroyWindow(cloneWin); }
Also I have tried SendMessage , PostQuitMessage. But nothing helps.
What is wrong ?
Thanks in advance .
All replies (2)
Tuesday, January 28, 2014 9:28 PM âś…Answered
If you want to close window, then use "CloseWindow", "DestroyWindow" will close all associated windows. Look at document.
Wednesday, January 29, 2014 5:16 AM
Hi,
According to your description, you want to destroy the child window without destroying its parent, or you just want to close the child window without closing its parent?
If you want to close it without closing its parent, please refer to link below.
How can I close a child window without closing the parent?
By the way, when you destroy the child window, please make sure you get the correct handle of the child window before using DestroyWindow method.
May
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.