Win32-GUI

 view release on metacpan or  search on metacpan

Win32-GUI_AxWindow/demos/InfoControl.pl  view on Meta::CPAN

    -vscroll  => 1,
    -onChange => \&loadInfo,
    -dropdownlist => 1,
) or die "new Combobox";

$mw->AddTreeView(
    -name        => 'TV',
    -top         => $mw->PROGID_Prompt->Height()+20,
    -width       => 180,
    -height      => $mw->ScaleHeight()-$mw->PROGID_Prompt->Height()-20,
    -rootlines   => 1,
    -lines       => 1,
    -buttons     => 1,
    -onNodeClick => \&dispInfo,
) or die "new TreeView";

Win32::GUI::AxWindow->new(
    -parent     => $mw,
    -control    => "Shell.Explorer",
    -name       => 'BW',
    -left       => $mw->TV->Left() + $mw->TV->Width()+5,
    -top        => $mw->PROGID_Prompt->Height()+20,
    -width      => $mw->ScaleWidth()-$mw->TV->Width()-5,
    -height     => $mw->ScaleHeight()-$mw->PROGID_Prompt->Height()-20,
    -addexstyle => WS_EX_CLIENTEDGE,
) or die "new AxWindow";

# Load a blank page
$mw->BW->CallMethod("Navigate", "about:blank");

$mw->Show();
$mw->Disable();

# Ref to list of controls
my $controls = getInstalledControls();
exit(0) if not defined $controls;  # Abort

#Populate combo selection
$mw->PROGID->Add(sort {lc $a cmp lc $b} @{$controls});

$mw->Enable();
$mw->BringWindowToTop();
Win32::GUI::Dialog();
$mw->Hide();
undef $mw;
exit(0);

sub mwResize {
    my $win = shift;
    my ($width, $height) = ($win->GetClientRect())[2..3];

    $win->TV->Height($height-$win->TV->Top());

    $win->BW->Width($width-$win->BW->Left());
    $win->BW->Height($height-$win->BW->Top());

    return 1;
}

sub loadInfo {
    Update_Treeview($mw->TV);
    return 1;
}

sub Update_Treeview {
    my $tv = shift;

    # reset information
    %INFO = ();
    $tv->DeleteAllItems();
    Display("");

    $INFO{progid} = $mw->PROGID->Text();
    $INFO{progid} =~ s/\s.*$//;

    # Determine if we can create the object:
    # This is pretty heavy handed, but I can't think of a better
    # way to prevent us falling back on Shell.Explorer if we can't
    # load the requested ActiveX object
    {
        my $oleobj;
        {
            local $SIG{__WARN__} = sub {};
            $oleobj = Win32::OLE->new($INFO{progid});
        }
        if (not defined $oleobj) {
            Display("<p style='color:red;'>ERROR creating $INFO{progid} (OLE)</p>");
            return 0;
        }
    }

    # Create invisible AxWindow control
    my $C = new Win32::GUI::AxWindow(
        -parent  => $mw,
        -name    => "Control",
        -control => $INFO{progid},
    );
    if (not defined $C) {
        Display("<p style='color:red;'>ERROR creating $INFO{progid} (Control)</p>");
        return 0;
    }

    # Get Property info
    foreach my $id ($C->EnumPropertyID()) {
        my %property = $C->GetPropertyInfo($id);
        $INFO{Properties}->{$property{-Name}} = \%property;
    }

    # Get Method info
    foreach my $id ($C->EnumMethodID()) {
        my %method = $C->GetMethodInfo($id);
        $INFO{Methods}->{$method{-Name}} = \%method;
    }

    # Get Event info

    foreach my $id ($C->EnumEventID()) {
        my %event = $C->GetEventInfo ($id);
        $INFO{Events}->{$event{-Name}} = \%event;
    }

    # Update the tree view

    # Insert the nodes
    for my $pnode_text qw(Properties Methods Events) {



( run in 0.820 second using v1.01-cache-2.11-cpan-13bb782fe5a )