A SERVICE OF

logo

{
Init(parent, title);
button1 = new TButton(this, ID_BUTTON1, "Show",
10, 10, 75, 25, FALSE);
button2 = new TButton(this, ID_BUTTON2, "Hide",
95, 10, 75, 25, FALSE);
button3 = new TButton(this, ID_BUTTON3, "Transfer",
180, 10, 75, 25, FALSE);
button3->DisableAutoCreate();
}
The call to DisableAutoCreate in the constructor prevents the Transfer button
from being displayed when TT stWindow is created. The conditional tests ine
the EvButton1 and EvButton2 functions work by testing the validity of the
HWindow data member of the button3 interface object; if the Transfer button
is already being displayed, EvButton1 doesn’t try to display it again, and
EvButton2 doesn’t try to destroy the Transfer button if it isn’t being
displayed.
Destroying a parent window also destroys all of its child windows. Y u doo
Destroying
not need to explicitly destroy child windows or delete child window
windows
interface objects. The same is true for the CanClose mechanism; CanClose for
a parent window calls CanClose for all its children. The parent’ CanCloses
returns TRUE only if all its children return TRUE for CanClose.
When you destroy an object’ interface element, it enables automatics
creation for all of its children, regardless of whether automatic creation was
on or off before. This way when you create the parent, all the children are,
restored in the state they were in before their parent was destroyed. Y uo
can use this to destroy an interface element, and then re-create it in the
same state it was in when you destroyed it.
T prevent this, you must explicitly turn off automatic creation for anyo
child objects you don’t want to have created automatically.
When automatic creation is enabled for a child interface object before its
Automatic
parent is created, the child is automatically created at the same time the
creation
parent is created. This is true for all the parent object’ children.s
T explicitly exclude a child window from the automatic create-and-showo
mechanism, call the DisableAutoCreate member function in the child object’s
constructor T explicitly add a child window (such as a dialog box, which. o
would normally be excluded) to the automatic create-and-show
mechanism, call the EnableAutoCreate member function in the child object’s
constructor.
Chapter 4, Interface objects
139