- 论坛徽章:
- 0
|
- #!/usr/bin/perl
- #********************
- #*Written by freewind31 *
- #*May 7, 2012 Beijing *
- #********************
- use strict;
- use warnings;
- use Cwd;
- use Win32::GUI qw( MB_ICONINFORMATION MB_OK );
- use Win32::GUI::AxWindow;
- use Win32::OLE;
- my $font = Win32::GUI::Font->new(
- -name => "Times New Roman", #字体名称
- -size => 12, #字体大小
- );
- #主窗口
- my $Window = new Win32::GUI::Window (
- -title => "163",
- -pos => [0, 0],
- -size => [1280, 1024],
- -name => "Window",
- ) or die "new Window";
- #添加tab控件,以提高空间利用率
- $Window->AddTabStrip(
- -name => "tbTab",
- -left => 0,
- -top => 0,
- -width => 1280,
- -height => 1000,
- );
- #添加第一个tab页面
- $Window->tbTab->InsertItem(
- -name=> "163",
- -text => " 163 ",
- -font => $font, # Font对象
- -height => 20,
- );
- # Create AxWindow with a webbrowser
- my $Control1 = new Win32::GUI::AxWindow (
- -parent => $Window->tbTab,
- -name => "Control1",
- -pos => [20, 50],
- -size => [1240, 900],
- -control => "Shell.Explorer.2",
- ) or die "new Control";
- # Navigate to 163
- $Control1->CallMethod("Navigate", 'http://mail.163.com/');
- $Window->tbTab->AddCombobox(
- -name => "BCB1",
- -dropdownlist => 1,
- -left => 20,
- -top => 20,
- -height => 30,
- -width => 1240,
- -font => $font, # Font对象
- -onChange => sub { $Control1->CallMethod("Navigate", $_[0]->Text()); },
- -tabstop => 1,
- );
- $Window->tbTab->BCB1->Add('http://mail.163.com/', 'http://mail.126.com/');
- $Window->tbTab->BCB1->SetCurSel(0);
- #添加第二个tab页面
- $Window->tbTab->InsertItem(
- -name=> "126",
- -text => " 126 ",
- -font => $font, # Font对象
- -height => 20,
- );
- # Create AxWindow with a webbrowser
- my $Control2 = new Win32::GUI::AxWindow (
- -parent => $Window->tbTab,
- -name => "Control2",
- -pos => [20, 50],
- -size => [1240, 900],
- -control => "Shell.Explorer.2",
- ) or die "new Control";
- # Navigate to 126
- $Control2->CallMethod("Navigate", 'http://mail.126.com/');
- $Window->tbTab->AddCombobox(
- -name => "BCB2",
- -dropdownlist => 1,
- -left => 20,
- -top => 20,
- -height => 30,
- -width => 1240,
- -font => $font, # Font对象
- -onChange => sub { $Control2->CallMethod("Navigate", $_[0]->Text()); },
- -tabstop => 1,
- );
- $Window->tbTab->BCB2->Add('http://mail.163.com/', 'http://mail.126.com/');
- $Window->tbTab->BCB2->SetCurSel(0);
- #各个tab页面之间切换
- sub tbTab_Click
- {
- my $current_tab = $Window->tbTab->SelectedItem();
- my ($key, $refs, $tabid);
-
- foreach $key (keys %{$Window->tbTab}) {
- # Skip these items - what remains should be just widgets.
- next if (grep(/^${key}$/,qw(-handle -name -type)));
- #next if (grep(/^${key}$/,qw(-handle)));
- $refs = $Window->tbTab->{$key};
-
- if ($refs eq "0")
- {
- next;
- }
- $tabid = substr($refs->{-name},-1);
- if ($current_tab == ($tabid-1))
- {
- $refs->Show();
- }
- else
- {
- $refs->Hide();
- }
- }
- }
- # Event loop
- $Window->Center();
- $Window->Show();
- tbTab_Click(); # Initialize display of first tab (only).
- Win32::GUI::Dialog();
- sub Window_Terminate
- {
- $Control1->Release();
- $Control2->Release();
- return -1;
- }
- sub Window_Resize
- {
- if (defined $Window) {
- #$Window->tbTab->Resize($Window->ScaleWidth()-20,$Window->ScaleHeight()-20);
- #($width, $height) = ($Window->GetClientRect)[2..3];
- #$Control->Move (10, 40);
- #$Control->Resize ($width-50, $height-50);
- }
- }
复制代码 |
|