Jump to content
  • Advertisement
Sign in to follow this  
dantheman1337

win32 delete child window

This topic is 2227 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
Advertisement
DestroyWindow() does work on child windows. You were probably doing something else wrong.

Share this post


Link to post
Share on other sites

I solved it by deleting the parent window and making a new one every time I wanted to make a new button scheme.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!