From: Robert M. <rm...@po...> - 2006-10-24 20:09:39
|
Cutting your example down to what's necessary, you are forgetting about the non-client area of the window - child windows have that as well as top-level windows, it's just more obvious on top-level windows. #!perl -w use strict; use warnings; use Win32::GUI(); use Win32::GUI::Grid(); my $TopWindow = new Win32::GUI::Window ( -title => 'GUI Editor', -pos => [30,20], -size => [570,450], ); my $Grid = $TopWindow->AddGrid ( -name => "GRID", -columns => 2, -rows => 10, -fixedcolumns => 1, -fixedrows => 1, ); # "Virtual" dimensions are the required # client area. If we don't want scrollbars # we must take into account the non-client areas ... my $Width = $Grid->GetVirtualWidth(); my $Height = $Grid->GetVirtualHeight(); # Make the window too big, so that it doesn't # have scrollbars, as they would be included # in the non-client area $Grid->Resize($Width+20, $Height+20); # Calculate the required non-client sizes. # From Win32::GUI::Tutorial Part 1 my $ncw = $Grid->Width() - $Grid->ScaleWidth(); my $nch = $Grid->Height() - $Grid->ScaleHeight(); # and finally resize the window taking into # account the non-client areas $Grid->Resize($Width + $ncw, $Height + $nch); $TopWindow->Show(); Win32::GUI::Dialog(); __END__ Sorry about the rant yesterday. Regards, Rob. Arthur Schwarz wrote: > <snip - missing rant> > > use Win32::GUI; # Binding to Win32 GUI > use Win32::GUI::Grid; # Thin binding to Win32 GUI Grid > use integer; > my $TopWindow = new Win32::GUI::Window( # Create Main Window > -name => 'TopWindow', > -left => 30, > -height => 450, > -title => 'GUI Editor', > -top => 20, > -width => 570, > ); > my $Grid = $TopWindow->AddGrid( # Create Grid object > -columns => 2, > -fixedcolumns => 1, > -fixedrows => 1, > -name => "Property Grid", > -pos => [ 390, 0 ], > -rows => 10, > -visible => 1, > ); > my $Grid1= $TopWindow->AddGrid( # Create Grid object > -columns => 2, > -fixedcolumns => 1, > -fixedrows => 1, > -name => "Property Grid", > -pos => [ 100, 0 ], > -rows => 10, > -visible => 1, > ); > > $Grid->SetCellText(0, 0, "Property" ); > $Grid->SetCellText(0, 1, "Value" ); > > $Grid1->SetCellText(0, 0, "Property" ); > $Grid1->SetCellText(0, 1, "Value" ); > > print "\n"; > > my $TotalHeight = $Grid->GetRowHeight(0); > my $Height; > > print "Row = 0 Height = [ $TotalHeight, $TotalHeight ])\n"; > > for my $row (1..$Grid->GetRows()) { > $Grid->SetCellText($row, 0, "Property $row " ); > $Grid1->SetCellText($row,0, "Property $row " ); > } > > for my $row (1..4) { > my $col = 1; > $Grid->SetCellText($row, $col, "Cell : <$row, $col>"); > $Grid1->SetCellText($row,$col, "Cell : <$row, $col>"); > } > > my $row = 1; > > for my $CellType ( GVIT_NUMERIC, GVIT_DATE, GVIT_DATECAL, GVIT_TIME, GVIT_CHECK > , GVIT_COMBO, GVIT_LIST, GVIT_URL, GVIT_NUMERIC) { > $Height = $Grid->GetRowHeight($row); > $TotalHeight += $Height; > print "Row = $row Height = [ $Height, $TotalHeight ])\n"; > $Grid->SetCellType($row, 1, $CellType); > $Grid1->SetCellType($row++,1, $CellType); > } > > $Grid->SetCellCheck ( 5, 1, 1 ); > $Grid1->SetCellCheck ( 5, 1, 1 ); > > my $Width = $Grid->GetVirtualWidth(); #+20; > my $Height = $Grid->GetVirtualHeight(); #+10; > > $Grid->SetCellOptions( 6, 1, [ "Combo", "Box", "New" ]); > $Grid->SetCellOptions( 7, 1, [ "List", "Box", "New" ]); > $Grid->Resize($Width, $Height); > > $Grid1->SetCellOptions( 6, 1, [ "Combo", "Box", "New" ]); > $Grid1->SetCellOptions( 7, 1, [ "List", "Box", "New" ]); > $Grid1->Resize($Width+6, $Height+6); > > print "\n Actual Virtual W/O Bars\n"; > printf("Height %5d %7d %8d\n", $TotalHeight, $Grid->GetVirtualHeight, $Grid->GetVirtualHeight+6); > printf("Width %5d %7d %8d\n", $Grid->GetColumnWidth(0) + $Grid->GetColumnWidth(1) > , $Grid->GetVirtualWidth() > , $Grid->GetVirtualWidth()+6 ); > $TopWindow->Show(); # makes TopWindow visible > Win32::GUI::Dialog(); # Windows control loop > > > Robert May <rm...@po...> wrote: > Arthur Schwarz wrote: >> Grid (again). >> >> My grid has a cell with a list in it. I don't know if that's significant but: >> 1: The reported grid Width is too small and a horizontal scroll bar is presented, and >> 2: The reported grid height is too short and a vertical scroll bar is presented. >> >> The dimensions are: >> >> [virtual virtual + ] >> >> With W/o scroll bar >> [ 156 176 ] width >> [ 190 200 ] height > > [snip] > > > > Please take the time to post a *short*, but complete, example of the > problem that you are asking for help with. It is very time consuming to > put together example scripts to see if I can see the same behaviour, > especially if I don't have any detailed knowledge of the control that > you are talking about. Please read this if you haven't before: > http://www.catb.org/~esr/faqs/smart-questions.html > > > > That said, if you're trying to autosize the grid, then I doubt that it > takes into account any extra space required for any controls that may be > needed - but we'd have to read the documentation for the underlying Grid > Control, which on my previous forays I have discovered to be rather > sparse, leaving us only the underlying source code to unravel to work > out what is going on. > > Regards, > Rob. > > |