views:

28

answers:

0

I have a dialogbox, to which i populate elements(labels) on activate event. I want to remove these elements(labels) when the window is being deactivated. something like:[its erroneous fragment of main code but explanatory]

my $wchRW = Win32::GUI::DialogBox->new(
-name   =>  "wchR",
-title  =>  "whed",
-left   =>  CW_USEDEFAULT,
-size   =>  [300, 130],
-parent =>  $mw,
);

$wchRW->AddGroupbox(
-name   =>  "wchR_gb",
-text   =>  "being watched",
-width  =>  $wchRW->ScaleWidth() - $padding,
-height =>  100,
-left   =>  $padding/2,
);

sub wchR_Activate {
my $wchtxt = "sample";
# lbleft, lbtop are calculated here
$wchRW->AddLabel(
            -name   =>  "wchR_lb0",
            -text   =>  $wchTxt,
            -left   =>  $lbLeft,
            -top    =>  $lbTop,
        );
}
sub gitni_wchR_Deactivate {
print "Here\n";
Win32::GUI::DestroyWindow($wchRW->wchR_lb0); #this is line n
}
#i have a button in main window $mw. 
#onclick of this button this dialogbox is shown.
#sub b1_Click { $wchRW->DoModal(); return 0; }

But the problem is, "Here" in deactivate is called many times and an exception is thrown thereafter [can't locate auto/wchR_.al in @INC .... line n]. Freezing the main window and only option is to end process through task-manager.

Please help me out. Why "here" is printed many times? How to remove element permanently? Thanks