Well, in my main application I need dynamically destroy/create controls. But I 
was told to not use DestroyWindow, because Win32::GUI "correctly" destroys 
control when it goes out of scope. I decided to check how Win32::GUI destroys 
controls when they are out of scope and wrote an example below. I do not need 
workaround (I already have one), I need a confirmation if it is a bug or not 
(if not, then why the behavior is so strange?). Try to comment one of 
$main->AddLabel in Label_Click and everything will be ok. This is very strange 
behavior, I think.

It seems the program hangs in infinite loop invoking 
Win32::GUI::WindowProps::FETCH but I'm not yet digged deep enough to be 100% 
sure...

-----Original Message-----
From: "Ilya BANDORIN" <ilya.bando...@socgen.com>
To: "perl-win32-gui-users" <perl-win32-gui-users@lists.sourceforge.net>
Date: Thu, 24 Dec 2009 18:53:36 +0300
Subject: Re: [perl-win32-gui-users] label is not visible after recreating
inevent

> Probably because the control named "Label" is alredy defined in main code. 
> Why do you try to create it once more?
> You should just modify its properties (text), something like this:
> 
> $main->Label->Text(rand());
> 
> 
> 
> -----Original Message-----
> From: Andrey [mailto:war...@mail.ru] 
> Sent: Thursday, December 24, 2009 6:07 PM
> To: perl-win32-gui-users
> Subject: [perl-win32-gui-users] label is not visible after recreating inevent
> 
> 
> While researching memory leak in Win32::GUI I found out strange behavior of 
> control.
> 
> Here is an example:
> 
> =====================
> use strict; 
> use Win32::GUI(); 
> 
> my $main = Win32::GUI::Window->new(-name => 'Main', -text => 'Perl', -width 
> => 200, -height => 200);
> 
> $main->AddLabel(-name => "Label", -text => "Hello, world", -left => 20, -top 
> => 20, -notify => 1);
> 
> sub Label_Click 
> { 
>   { # "visibility" block
>     $main->AddLabel(-name => "Label", -text => rand(), -left => 20, -top => 
> 20, -notify => 1); 
>     $main->AddLabel(-name => "Label", -text => rand(), -left => 20, -top => 
> 20, -notify => 1); 
>   }
>   $main->AddLabel(-name => "Label", -text => rand(), -left => 20, -top => 20, 
> -notify => 1); 
> } 
> 
> $main->Show(); Win32::GUI::Dialog(); 
> 
> sub Main_Terminate { -1; }
> =======================
> 
> When you click on "Hello, world" label it just disappears.
> If you comment any of "$main->AddLabel" lines then everything will be OK.
> Why label disappears?
> 
> Perl version: 5.10.1 build 1006
> Win32::GUI version: 1.06
> 
> 
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev 
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev 
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
> 

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to