# Eric Hansen, ITSi, Dallas, TX July 1999
# ChangeColor.pl - change color on the fly 
use Win32::GUI;

# Hide the Dos Window 
($DOShwnd, $DOShinstance) = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($DOShwnd);

$Font = new Win32::GUI::Font(
    -name => "Courier New",
    -size => 12,
    -weight => 700,
    -height => -14,
);

$SFont = new Win32::GUI::Font(
    -name => "Courier New",
    -size => 8,
    -weight => 700,
    -height => -11,
);

$W = new Win32::GUI::DialogBox (
    -title    => "Change Color On The Fly",
    -left     => 100, 
    -top      => 20, 
    -width    => 250, 
    -height   => 250,
    -font     => $Font,
    -name     => "Window",
);
 
$ColorBtn = $W->AddButton(-name => "ColorBtn",
                      -font => $SFont,
                      -text  => "Color", 
                      -left => 145, 
                      -top => 100,
                      -height => 25, 
                      -width => 50 );
$ColorBtn->SetFocus();

$ColorTxt = $W->AddTextfield(-name => "ColorTxt",
                      -text  => "255", 
                      -font => $Font,
                      -readonly => 1,
                      -foreground => 255,  # start with basic red
                      -left => 65, 
                      -top => 100, 
                      -height => 20,
                      -width => 75 );

$W->Show; 
Win32::GUI::Dialog();

sub ColorBtn_Click {
   my $color = Win32::GUI::ChooseColor(-owner => $W);
   if ($color) {
        $ColorTxt->Change(-foreground => $color, -text => $color);
   }
}

Window_Terminate {
    Win32::GUI::Show($DOShwnd);
    return -1;
}

# End Script
