From: marco h. <mar...@gm...> - 2007-02-13 17:52:31
|
Hello, I want to control the Scrollbar in a grid. The aim is to set the focus on a defined cell and to move the scrollbar so thats visible. I tried the following skript (modified script from the Win32::Gui::Grid) but the sequence my $Scroll = $Grid->ScaleHeight; $Grid->ScrollPos(0,$Scroll/2); doesn't work. Someone who knows why? Thanks, Marco use strict; use Win32::GUI(); use Win32::GUI::Grid; sub paintgrid { my $Grid =${$_[0]}; for my $row (0..$Grid->GetRows()) { for my $col (0..$Grid->GetColumns()) { if ($row == 0) { $Grid->SetCellText($row, $col,"Column : $col"); } elsif ($col == 0) { $Grid->SetCellText($row, $col, "Row : $row"); } else { $Grid->SetCellText($row, $col, "Cell : ($row,$col)"); } } } } # main Window my $Window = new Win32::GUI::Window ( -title => "Win32::GUI::Grid", -pos => [0, 0], -size => [500, 500], -name => "Window", ) or die "new Window"; # Grid Window my $Grid = $Window->AddGrid( -name => "Grid", -pos => [0, 40], -rows => 50, -columns => 10, -fixedrows => 1, -fixedcolumns => 1, -editable => 1, -vscroll => 1, -hscroll =>1, ) or die "new Grid"; # Fill Grid my $ref_Grid = \$Grid; paintgrid($ref_Grid); $Grid->SetFocusCell(3,30); #Set Cell Focus on Row 3, Column 30 # try to scroll to the middle my $Scroll = $Grid->ScaleHeight; $Grid->ScrollPos(0,$Scroll/2); # 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); } # Grid event handler sub Grid_Click { my ($col, $row) = @_; print "Click on Cell ($col, $row)\n"; } |