ChrisR has asked for the wisdom of the Perl Monks concerning the following question:
I tried $control->Enable(0) but the control still gets greyed out. I'm using activestate perl 5.8.7 and Win32::GUI 1.03 on win xp. Here's a brief example:
I also tried to set the onClick event to an empty sub which didn't work either#!c:\perl58\bin\wperl.exe -W use strict; use Win32::GUI; use Win32::API; our $mainform = Win32::GUI::Window->new( -name=>'main', -text=>'main', -width=>800,-height=>600, ) or die "window creation failed: $!\n"; our $test = $mainform->AddTextfield( -name=>'test', -text=>'test', -left=>200,-top=>200, -width=>100,-height=>20, ) or die "control creation failed: $!\n"; $test->Enable(0); $mainform->Show(); Win32::GUI::Dialog;
I'd really like to find a way to disable the functional aspects of the control without changing the way it looks.our $test = $mainform->AddTextfield( -name=>'test', -text=>'test', -left=>200,-top=>200, -width=>100,-height=>20, -onClick=>sub{}, ) or die "control creation failed: $!\n";
Thanks, Chris
Update
I found at least one fairly easy way that works:
Now if I can only figure out how to have multiple Hook()s per control to handle different messages...#!c:\perl58\bin\wperl.exe -w use strict; use warnings; use Win32::GUI(); # Constants use constant WM_NCHITTEST => 0x0084; use constant HTCAPTION => 2; our $mainform = Win32::GUI::Window->new( -name=>'main', -text=>'main', -width=>800,-height=>600, ) or die "window creation failed: $!\n"; our $test = $mainform->AddTextfield( -name=>'test', -text=>'test', -left=>200,-top=>200, -width=>100,-height=>20, ) or die "control creation failed: $!\n"; $test->Hook(WM_NCHITTEST,sub { $_[0]->Result(HTCAPTION); 0;}); $mainform->Show(); Win32::GUI::Dialog(); exit(0);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Disable Control in Win32::GUI
by BrowserUk (Patriarch) on Dec 19, 2005 at 21:41 UTC | |
by ChrisR (Hermit) on Dec 19, 2005 at 21:49 UTC | |
by BrowserUk (Patriarch) on Dec 19, 2005 at 22:04 UTC | |
by ChrisR (Hermit) on Dec 20, 2005 at 00:57 UTC | |
by BrowserUk (Patriarch) on Dec 20, 2005 at 01:33 UTC | |
|