use strict; use Win32::GUI; use Win32::GUI::Grid; &buildarray; my ($Date, $Time, $Source, $Type, $Category, $EventID, $Username, $ComputerName, $Description, @data); my ($computer, $date, $time, $source, $type, $cat, $evt, $user, $det); my $rowset = ($#data + 2); # main Window my $Window = new Win32::GUI::Window ( -title => "Win32::GUI::Grid test 1", -pos => [100, 100], -size => [400, 400], -name => "Window", ) or die "new Window"; # Grid Window my $Grid = new Win32::GUI::Grid ( -parent => $Window, -name => "Grid", -pos => [0, 0], ) or die "new Grid"; # Init Grid $Grid->SetEditable(1); $Grid->SetRows($rowset); $Grid->SetColumns(9); $Grid->SetFixedRows(1); $Grid->SetFixedColumns(1); $Grid->OnEditCopy(); #### Change default background color of column 0 to blue #$Grid->SetDefCellBackColor(0,1, '#0000FF'); # Fill Grid my $color = "color"; # Set Headings $Grid->SetCellFormat('0', '0', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '0',"Computer"); $Grid->SetCellFormat('0', '1', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '1',"Date"); $Grid->SetCellFormat('0', '2', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '2',"Time"); $Grid->SetCellFormat('0', '3', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '3',"Source"); $Grid->SetCellFormat('0', '4', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '4',"Type"); $Grid->SetCellFormat('0', '5', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '5',"Category"); $Grid->SetCellFormat('0', '6', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '6',"Event"); $Grid->SetCellFormat('0', '7', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '7',"User"); $Grid->SetCellFormat('0', '8', DT_CENTER|DT_WORDBREAK); $Grid->SetCellText('0', '8',"Details"); my $row = 1; my $col; foreach my $line (@data){ s/\s+//g; foreach ($computer, $date, $time, $source, $type, $cat, $evt, $user, $det){ undef; } ($computer, $date, $time, $source, $type, $cat, $evt, $user, $det) = (split(/\|/, $line)); $Grid->SetCellText($row, '0',$computer); $Grid->SetCellText($row, '1',$date); $Grid->SetCellText($row, '2',$time); $Grid->SetCellText($row, '3',$source); $Grid->SetCellText($row, '4',$type); $Grid->SetCellText($row, '5',$cat); $Grid->SetCellText($row, '6',$evt); $Grid->SetCellText($row, '7',$user); $Grid->SetCellText($row, '8',$det); if($type =~ /Error/i){ for $col (0..$Grid->GetColumns()) { $Grid->SetCellBkColor($row,$col, '#FF0000'); } } elsif($type =~ /Warning/i){ for $col (0..$Grid->GetColumns()) { $Grid->SetCellBkColor($row,$col, '#FF8C00'); } } elsif($type =~ /Information/i){ for $col (0..$Grid->GetColumns()) { $Grid->SetCellBkColor($row,$col, '#EEEE00'); } } $row++; } $Grid->AutoSize(); # Event loop $Window->Show(); Win32::GUI::Dialog(); # Main window event handler sub Window_Terminate { return -1; } sub Window_Resize { my ($width, $height) = ($Window->GetClientRect)[2..3]; $Grid->Resize ($width, $height); } sub buildarray{ #open (FILEHANDLE, "$datafile"); #@data = ; #close (FILEHANDLE); push @data, "Computer1|Date1|Time1|Source1|Type1|Category1|Event1|User1|Details1"; push @data, "Computer2|Date2|Time2|Source2|Type2|Category2|Event2|User2|Details2"; push @data, "Computer3|Date3|Time3|Source3|Type3|Category3|Event3|User3|Details3"; push @data, "Computer4|Date4|Time4|Source4|Type4|Category4|Event4|User4|Details4"; push @data, "Computer5|Date5|Time5|Source5|Type5|Category5|Event5|User5|Details5"; push @data, "Computer6|Date6|Time6|Source6|Type6|Category6|Event6|User6|Details6"; push @data, "Computer7|Date7|Time7|Source7|Type7|Category7|Event7|User7|Details7"; push @data, "Computer8|Date8|Time8|Source8|Type8|Category8|Event8|User8|Details8"; push @data, "Computer9|Date9|Time9|Source9|Type9|Category9|Event9|User9|Details9"; push @data, "Computer10|Date10|Time10|Source10|Type10|Category10|Event10|User10|Details10"; push @data, "Computer11|Date11|Time11|Source11|Type11|Category11|Event11|User11|Details11"; push @data, "Computer12|Date12|Time12|Source12|Type12|Category12|Event12|User12|Details12"; push @data, "Computer13|Date13|Time13|Source13|Type13|Category13|Event13|User13|Details13"; push @data, "Computer14|Date14|Time14|Source14|Type14|Category14|Event14|User14|Details14"; push @data, "Computer15|Date15|Time15|Source15|Type15|Category15|Event15|User15|Details15"; push @data, "Computer16|Date16|Time16|Source16|Type16|Category16|Event16|User16|Details16"; push @data, "Computer17|Date17|Time17|Source17|Type17|Category17|Event17|User17|Details17"; push @data, "Computer18|Date18|Time18|Source18|Type18|Category18|Event18|User18|Details18" }