
"David Turner" <dkturner@telkomsa.net> wrote in message news:30062.165.165.239.17.1078414261.squirrel@webmail.telkomsa.net...
Hi
Thorsten Ottosen wrote:
Why can't window::container be like
window::contain( const button& b ) { b.set_owner( this ); add(b ); }
button::set_owner( window* w ) { owner_->remove( this ); owner_ = w; }
It's not always that simple.
Ok, I should have stated it was pseudo code.
In particular, on the Win32 architecture, changing ownership amounts to
DestroyWindow(hwnd); hwnd = CreateWindow(TEXT("BUTTON"), label.c_str(), WS_CHILD, 0, 0, new_owner->get_hwnd(), 0);
yeah, I hate the win32 API.
and from that point on things start to get complicated. So I neatly avoided said complications by drawing a line and saying, "on this side, widgets don't change owners".
Still, you could let set_owner() be called only once and throw something if its done twice. br Thorsten