Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

How to refresh a window using Win32::GUI
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;
}

Report this thread to moderator Post Follow-up to this message
Old Post
omoore
08-11-04 08:57 PM


Re: How to refresh a window using Win32::GUI
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;
}

Report this thread to moderator Post Follow-up to this message
Old Post
omoore
08-12-04 08:59 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:37 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.