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 dialo +gbox 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


In reply to remove elements win32 gui by teoma

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.