Home > Archive > PERL Beginners > August 2004 > How to refresh a window using Win32::GUI
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to refresh a window using Win32::GUI
|
|
| omoore 2004-08-11, 3:57 pm |
| I am just learning Win32::GUI. I created a simple window with a
checkbox, a label, and a textfield. Initially, the label and textfield
are disabled. What should happen is they should become enabled if you
click the checkbox. I cannot figure out how to do this. As you can see
from the code below, I tried creating a Click event to set the
variable so that the label and textfield would be enabled, but
apparently, I have to redraw or refresh the window somehow. Can anyone
please help?
--------------Code follows-----------------------
use Win32::GUI;
$Display=1;
$main = Win32::GUI::DialogBox->new(
-name => 'Main',
-width => 250,
-height => 100,
);
$main->AddCheckbox(
-name => 'CheckBox1',
-width => 225,
-left => 10,
-top => 10,
-tabstop => 1,
-disabled => 0,
-visible => 1,
-text => 'Check this box to enable the next section');
$main->AddLabel(
-name => 'label1',
-left => 30,
-top => 30,
-disabled => "$Display",
-text => "Type something here");
$main->AddTextfield(
-name => 'textbox1',
-width => 175,
-height => 20,
-left => 28,
-top => 45,
-tabstop => 1,
-disabled => "$Display",
-visible => 1);
$main->Show();
Win32::GUI::Dialog();
sub CheckBox1_Click {
if($Display==1){
$Display=0}
else{$Display=1}
}
sub Main_Terminate {
-1;
}
| |
| omoore 2004-08-12, 3:59 pm |
| redneck13@hotmail.com (omoore) wrote in message news:<ac62fb69.0408111148.25bea683@posting.google.com>...
> I am just learning Win32::GUI. I created a simple window with a
> checkbox, a label, and a textfield. Initially, the label and textfield
> are disabled. What should happen is they should become enabled if you
> click the checkbox. I cannot figure out how to do this. As you can see
> from the code below, I tried creating a Click event to set the
> variable so that the label and textfield would be enabled, but
> apparently, I have to redraw or refresh the window somehow. Can anyone
> please help?
Nevermind, I figured it out. For those of you that may be curious,
the secret lies in assigning each of the objects to its own variable.
You can then apply the Enable and Disable methods to those variables.
This also negates the need for my original $Display variable.
Following is the code that did the trick.
use Win32::GUI;
$main = Win32::GUI::DialogBox->new(
-name => 'Main',
-width => 250,
-height => 100,
);
$checkbox1=$main->AddCheckbox(
-name => 'CheckBox1',
-width => 225,
-left => 10,
-top => 10,
-tabstop => 1,
-disabled => 0,
-visible => 1,
-text => 'Check this box to enable the next section');
$label1=$main->AddLabel(
-name => 'label1',
-left => 30,
-top => 30,
-disabled => 1,
-text => "Type something here");
$textbox1=$main->AddTextfield(
-name => 'textbox1',
-width => 175,
-height => 20,
-left => 28,
-top => 45,
-tabstop => 1,
-disabled => 1,
-visible => 1);
$main->Show();
Win32::GUI::Dialog();
sub CheckBox1_Click {
if($checkbox1->Checked()==1){
$label1->Enable();
$textbox1->Enable();
}
else{
$label1->Disable();
$textbox1->Disable();
}
}
sub Main_Terminate {
-1;
}
|
|
|
|
|