Sign in to follow this  

win32 delete child window

This topic is 2009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a button in my C++ application. The button is a child of my main window. How do I delete the button, without deleting the window? DestroyWindow() doesn't seem to work on child windows.

The code for the button is right here:

[source lang="cpp"]hWndButton=CreateWindowEx(NULL,
"BUTTON",
"OK",
WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
50,
220,
100,
24,
hWnd,
(HMENU)IDC_MAIN_BUTTON,
GetModuleHandle(NULL),
NULL);[/source]

Share this post


Link to post
Share on other sites
[quote name='dantheman1337' timestamp='1339786793' post='4949629']
I solved it by deleting the parent window and making a new one every time I wanted to make a new button scheme.
[/quote]
This is overkill, isn't it? I'd consider it more of a stopgap hack until you can get the proper method working.

As has been said before, recheck DestroyWindow to make sure you were doing things right.

Share this post


Link to post
Share on other sites
I used the destroywindow command and my buttons would still exist.

DestoryWindow(hWndButton);

However, my application is a graphics/character modeler/animator. It takes literally half a second to close the window and open it with new GUI. I don't see a big problem at the moment. I'll try to use the DestroyWindow comman some more and see what I find.

Share this post


Link to post
Share on other sites
Are you sure that it didn't just look like the child wasn't getting deleted because nothing issued a repaint? Maybe you just needed to invalidate the parent ... DestroyWindow definitely works on child windows.

Share this post


Link to post
Share on other sites

This topic is 2009 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this