marynella has asked for the wisdom of the Perl Monks concerning the following question:

Hi!

I'm working on a Perl application (for a Windows Server) with UI.

I need to add/remove comboboxes and checkboxes dinamically.

I used Win32::GUI ... but I haven't find (yet) methods for removing a combobox ... just for adding ...

Can somedoby help me?

Thanks!

  • Comment on remove a combobox from a win32::GUI::Window

Replies are listed 'Best First'.
Re: remove a combobox from a win32::GUI::Window
by meetraz (Hermit) on Jun 07, 2004 at 19:17 UTC
    Marynella,
    Once you add a checkbox, you can use the Show() and Hide() methods to... well, hide and show it. Here is some sample code to demonstrate:

    use strict; use Win32::GUI; my $Window = new Win32::GUI::Window( -name => "Window", -left => 100, -top => 100, -width => 150, -height => 150, -title => "checkbox test", ); $Window->AddCheckbox( -name => 'mycheckbox', -left => 10, -top => 10, -height => 15, -width => 15, ); $Window->AddButton( -text => 'Hide checkbox', -left => 10, -top => 35, -height => 30, -width => 100, -name => 'btnHide', ); $Window->AddButton( -text => 'Show checkbox', -left => 10, -top => 75, -height => 30, -width => 100, -name => 'btnShow', ); $Window->Show(); Win32::GUI::Dialog(); sub Window_Terminate { return -1; } sub btnShow_Click { $Window->mycheckbox->Show(); } sub btnHide_Click { $Window->mycheckbox->Hide(); }
    Update:
    If you really want to *remove* a checkbox or combobox, something like this might work:

    Win32::GUI::DestroyWindow($Window->{mycheckbox}{-handle}); delete $Window->{mycheckbox}; #use hashref syntax instead of autoload +ed methods

      Thanx for the answer ... I really want to 'remove' the checkboxes/label/comboboxes and add new ones ..... (the checkboxes and labels are added according to what was selected in one first combobox and when a checkbox is checked on/off I add/remove other comboboxes ... but this is the project logic)

      I used:

      Win32::GUI::DestroyWindow($Window->$name);

      where  $name is the name of the label/checkbox or combobox I want to remove.