In a previous post I dynamically created 10 superclassed Edit boxes, now I'm implementing a CANCEL button. I've come up with this piece of code - which could be turned into a loop :-
invoke DestroyWindow, hwndEdit
invoke DestroyWindow, hwndEdit+4
invoke DestroyWindow, hwndEdit+8
invoke DestroyWindow, hwndEdit+12
invoke DestroyWindow, hwndEdit+16
invoke DestroyWindow, hwndEdit+20
invoke DestroyWindow, hwndEdit+24
invoke DestroyWindow, hwndEdit+28
invoke DestroyWindow, hwndEdit+32
invoke DestroyWindow, hwndEdit+36
This works, but is this the correct way to do it or is there an easier way?
This way looks pretty easy but a more fun way is to take a hammer to the hard drive. That way you can put your mind at rest it *guarentees* no more will be created!
Destroying the parent will destroy all childs...
Nordwind is right:
MSDN: (http://msdn.microsoft.com/en-us/library/ms632682%28VS.85%29.aspx) If the specified window is a parent or owner window, DestroyWindow automatically destroys the associated child or owned windows when it destroys the parent or owner window.
mov esi, offset hwndEdit
.Repeat
lodsd
test eax, eax
.Break .if Zero?
invoke DestroyWindow, eax
.Until 0
This will do the job in case you want to re-create the controls, but make sure you left an empty slot.
Thanks jj, that's a nice piece of code :8) I am just destroying the controls which could be recreated once again, so that code is perfect for my needs & is a lot more elegant than mine.