#!perl -w

use strict;

use Win32::GUI;

my $obMW;
my $obCW;

my $clW = new Win32::GUI::Class(-name => "NoFlicker", -style => 0);

$obMW = Win32::GUI::Window->new(
	-title    	=> "Hierarchical Controls",
	-class		=> $clW,
	-pos		=> [ 100, 100 ],
	-size     	=> [ 240, 250 ],
	-minsize    => [ 240, 250 ],
	-dialogui	=> 1,
	-pushstyle	=> WS_EX_CONTROLPARENT,
	-onResize	=> sub { $obCW->Move(0, $obMW->Height-200); 1 },
);

$obMW->AddButton(
	-name		=> "btParent",
	-text		=> "Button 1",
	-size		=> [ 70, 22 ],
	-pos		=> [ 20, 20 ],
	-tabstop	=> 1,
	-onClick	=> sub { $obMW->txParent->Text("Button 1");
						 $obCW->txChild->Text("Button 1");
						 $obCW->Enable($obCW->IsEnabled ? 0 : 1);
						 1;
					   },
);

$obMW->AddTextfield(
	-name		=> "txParent",
	-text		=> "Textfield 1",
	-size		=> [ 100, 22 ],
	-pos		=> [ 100, 22 ],
	-tabstop	=> 1,
);

$obCW = new Win32::GUI::Window(
  	-name		=> 'cw',
  	-parent		=> $obMW,
	-size		=> [ ($obMW->GetClientRect)[2], 100 ],
    -popstyle	=> Win32::GUI::WS_CAPTION | Win32::GUI::WS_SIZEBOX,
	-pushstyle	=> Win32::GUI::WS_CHILD | Win32::GUI::WS_CLIPCHILDREN,
);

$obMW->AddButton(
	-name		=> "btChild",
	-parent		=> $obCW,
	-text		=> "Button 2",
	-size		=> [ 70, 22 ],
	-pos		=> [ 20, 55 ],
	-tabstop	=> 1,
	-onClick	=> sub { $obMW->txParent->Text("Button 2");
						 $obCW->txChild->Text("Button 2");
						 $obMW->txParent->Enable($obMW->txParent->IsEnabled ? 0 : 1);
						 $obMW->btParent->Enable($obMW->btParent->IsEnabled ? 0 : 1);
						 1;
					   },
);

$obMW->AddTextfield(
	-name		=> "txChild",
	-parent		=> $obCW,
	-text		=> "Textfield 2",
	-size		=> [ 100, 22 ],
	-pos		=> [ 100, 55 ],
	-tabstop	=> 1,
);

$obMW->Show();
$obCW->Show();
Win32::GUI::Dialog();
undef $obMW;
