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; }