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]
win32 delete child window
I solved it by deleting the parent window and making a new one every time I wanted to make a new button scheme.
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement