# This script demonstrates the DateTime Widget's use
# by Eric Hansen October 2002 - eri...@ch...
use Win32::GUI;
$W = new Win32::GUI::Window(
-name => "Window",
-text => "Demonstrate DateTime Control",
-width => 275,
-height => 250,
-left => 50,
-top => 50,
-style => ws_sysmenu,
);
$MyDateTime = new Win32::GUI::DateTime($W,
-name => "MyDateTime",
-width => 150,
-height => 25,
-left => 50,
-top => 50,
);
$MyDateTime->SetDate(15,8,2002); # set initially to Aug 15,2002
$Refresh = $W->AddButton(-name => "Refresh",
-text => "Refresh",
-left => 125,
-top => 100,
-height => 25,
-width => 73,
);
$Exit = $W->AddButton(-name => "Exit",
-text => "Exit",
-left => 125,
-top => 150,
-height => 25,
-width => 73,
);
$Status = $W->AddStatusBar(
-name => "Status",
-text => "Please select a new date and click Refresh BTN",
);
$W->Show();
$W->BringWindowToTop();
Win32::GUI::Dialog();
sub Refresh_Click {
my($da,$mo,$year)=$MyDateTime->GetDate();
$da=sprintf("%02d",$da); # pad with leading zeroes to 2 digits
$mo=sprintf("%02d",$mo); # pad with leading zeroes to 2 digits
$year=sprintf("%04d",$year);# pad with leading zeroes to 4 digits
$Status->Text("$mo/$da/$year");
}
sub Exit_Click {
my $SelectedDate = $Status->Text();
if ($SelectedDate eq "Please select a new date and click Refresh BTN"
|| $SelectedDate eq "08/15/2002") {
Win32::GUI::MessageBox($W,
"Please select a new date and click Refresh BTN\nThen you can
EXIT",
"Demonstrate DateTime Control - Error",16,);
return 1;
} else {
return -1;
}
}
# End Script
|