Here=92s a working example of your code. It only took minor changes to =
get it
working. I've added comments where I made changes.
=3Dcut
use Win32::GUI; # Binding to Win32 GUI
use Win32::GUI::Grid; # Binding to Win32 GUI Grid
#use Win32::GUI::Constants; # Windows constants
use integer;
=20
my $TopWindow =3D new Win32::GUI::Window( # Create Main Window
-name =3D> 'TopWindow',
-helpbox =3D> 1,
-left =3D> 30,
-hashelp =3D> 1,
-height =3D> 450,
-maxwidth =3D> 565,
-minheight =3D> 380,
-minwidth =3D> 565,
-title =3D> 'GUI Editor',
-top =3D> 20,
-width =3D> 570,
);
=20
my $Grid =3D $TopWindow->AddGrid( # Create Grid object
-columns =3D> 2,
-doublebuffer =3D> 1,
-editable =3D> 1,
# -enable =3D> Enable
-fixedcolumns =3D> 1,
-fixedrows =3D> 1,
# -height =3D> Heigth
-hscroll =3D> 0,
# -left =3D> Left position
-name =3D> "Property Grid",
# -parent =3D> $Editor::Win::TopWindow,
# -popstyle =3D> Pop style
# The original example had the grid way off to the right. This was =
causing
use Win32::GUI; # Binding to Win32 GUI
use Win32::GUI::Grid; # Binding to Win32 GUI Grid
#use Win32::GUI::Constants; # Windows constants
use integer;
=20
my $TopWindow =3D new Win32::GUI::Window( # Create Main Window
-name =3D> 'TopWindow',
-helpbox =3D> 1,
-left =3D> 30,
-hashelp =3D> 1,
-height =3D> 450,
-maxwidth =3D> 565,
-minheight =3D> 380,
-minwidth =3D> 565,
-title =3D> 'GUI Editor',
-top =3D> 20,
-width =3D> 570,
);
=20
my $Grid =3D $TopWindow->AddGrid( # Create Grid object
-columns =3D> 2,
-doublebuffer =3D> 1,
-editable =3D> 1,
# -enable =3D> Enable
-fixedcolumns =3D> 1,
-fixedrows =3D> 1,
# -height =3D> Heigth
-hscroll =3D> 0,
# -left =3D> Left position
-name =3D> "Property Grid",
# -parent =3D> $Editor::Win::TopWindow,
# -popstyle =3D> Pop style
-pos =3D> [0, 0 ],
# -pushstyle =3D> Push style
-rows =3D> 9,
# -size =3D> [ 140, $TopWindow->Height()-43 ],
# -style =3D> Default style
# -top =3D> Top position
-visible =3D> 1,
-vscroll =3D> 0,
# -width =3D> 140,
);
=20
$Grid->SetCellText(0, 0, "Property" );
$Grid->SetCellText(0, 1, "Value" );
=20
for my $row (1..$Grid->GetRows()) {
$Grid->SetCellText($row, 0, "Property $row " );
}
=20
for my $row (1..4) {
# I removed the loop, since it wasn't needed for this example
# for my $col (0..$Grid->GetColumns()) {
$Grid->SetCellText($row, 1, "Cell : <$row, 1>");
# }
}
=20
my $row =3D 1;
for my $CellType (GVIT_NUMERIC, GVIT_DATE, GVIT_DATECAL, GVIT_TIME,
GVIT_CHECK, GVIT_COMBO, GVIT_LIST, GVIT_URL) {
# Changed the column from 2 to 1, since the column is 0 indexed
$Grid->SetCellType($row++, 1, $CellType);
}
# Changed the column from 2 to 1
$Grid->SetCellOptions( 5, 1, 1 ); # button?
$Grid->SetCellOptions( 6, 1, [ "Combo", "Box" ]);
$Grid->SetCellOptions( 7, 1, [ "List", "Box" ]);
# Moved the AutoSize method to TopWindow_Resize
# $Grid->AutoSize();
$TopWindow->Show(); # makes TopWindow =
visible
Win32::GUI::Dialog(); # Windows control loop
# Added TopWindow_Resize so that the grid would be resized when
# the window is resized.
sub TopWindow_Resize {
my ($width, $height) =3D ($TopWindow->GetClientRect)[2..3];
$Grid->Resize ($width, $height);
$Grid->AutoSize(GVS_BOTH);
$Grid->ExpandLastColumn;
}# the grid to be cut off, not showing the dropdown arrow for the =
list/combo
# boxes
-pos =3D> [0, 0 ],
# -pushstyle =3D> Push style
-rows =3D> 9,
# -size =3D> [ 140, $TopWindow->Height()-43 ],
# -style =3D> Default style
# -top =3D> Top position
-visible =3D> 1,
-vscroll =3D> 0,
# -width =3D> 140,
);
=20
$Grid->SetCellText(0, 0, "Property" );
$Grid->SetCellText(0, 1, "Value" );
=20
for my $row (1..$Grid->GetRows()) {
$Grid->SetCellText($row, 0, "Property $row " );
}
=20
for my $row (1..4) {
# for my $col (0..$Grid->GetColumns()) {
$Grid->SetCellText($row, 1, "Cell : <$row, 1>");
# }
}
=20
my $row =3D 1;
for my $CellType (GVIT_NUMERIC, GVIT_DATE, GVIT_DATECAL, GVIT_TIME,
GVIT_CHECK, GVIT_COMBO, GVIT_LIST, GVIT_URL) {
$Grid->SetCellType($row++, 1, $CellType);
}
$Grid->SetCellOptions( 5, 1, 1 ); # button?
$Grid->SetCellOptions( 6, 1, [ "Combo", "Box" ]);
$Grid->SetCellOptions( 7, 1, [ "List", "Box" ]);
# $Grid->AutoSize();
$TopWindow->Show(); # makes TopWindow =
visible
Win32::GUI::Dialog(); # Windows control loop
sub TopWindow_Resize {
my ($width, $height) =3D ($TopWindow->GetClientRect)[2..3];
$Grid->Resize ($width, $height);
$Grid->AutoSize(GVS_BOTH);
$Grid->ExpandLastColumn;
}
=3Dend
Brian Millham
This message traveled at least 44,000 miles to reach you!
Creator of the DW6000 Monitor
http://www.millham.net/dw6000
bmillham@...
-----Original Message-----
From: perl-win32-gui-users-bounces@...
[mailto:perl-win32-gui-users-bounces@...] On Behalf Of
Arthur Schwarz
Sent: Thursday, October 12, 2006 12:35 PM
To: Brian Millham; perl-win32-gui-users@...
Subject: Re: [perl-win32-gui-users] Grid questions
Thanks. I tried it and was able to get a check box displayed and I am
working on getting the List and Combo box. Any suggestions on what, =
where ,
how, how much, or when would be a great help.
=A0
As a separate note to Robert May, it appears that the following =
constants
are missing from Win32::GUI::Constants (or I am missing the point):
=A0 GVIT_CHECK=A0=A0 =3D Check Box
=A0 GVIT_DATE=A0=A0=A0 =3D Date control
=A0 GVIT_DATECAL =3D Date control with calendar control
=A0 GVIT_DEFAULT =3D=20
=A0 GVIT_COMBO=A0=A0 =3D Combo Box
=A0 GVIT_LIST=A0=A0=A0 =3D List Box
=A0 GVIT_NUMERIC =3D Numeric control edit
=A0 GVIT_TIME=A0=A0=A0 =3D Time control
=A0 GVIT_URL=A0=A0=A0=A0 =3D Url control
=A0
=A0 GVL_BOTH Both vertical and horizontal grid lines
=A0 GVL_NONE No grid lines.
=A0 GVL_HORZ Horizontal grid lines only.
=A0 GVL_VERT Vertical grid lines only.
=A0
=A0 GVNI_ABOVE=A0=A0=A0=A0=A0=A0 =3D Search above initial cell
=A0 GVNI_ALL=A0=A0=A0=A0=A0=A0=A0=A0 =3D Search all cells in the =
grid=A0starting from the given
cell
=A0 GVNI_AREA=A0=A0=A0=A0=A0=A0=A0 =3D Search all cells below and to =
the=A0right of the given
cell
=A0 GVNI_BELOW=A0=A0=A0=A0=A0=A0 =3D Search below initial cell
=A0 GVNI_DROPHILITED =3D Search for drop highlighted cells
=A0 GVNI_FIXED=A0=A0=A0=A0=A0=A0 =3D Search for fixed cells
=A0 GVNI_FOCUSED=A0=A0=A0=A0 =3D Search for focus cell
=A0 GVNI_MODIFIED=A0=A0=A0 =3D Search for modified cells
=A0 GVNI_READONLY=A0=A0=A0 =3D Search for read-only cells
=A0 GVNI_SELECTED=A0=A0=A0 =3D Search for selected cells
=A0 GVNI_TOLEFT=A0=A0=A0=A0=A0 =3D Search to the left of the =
initial=A0cell
=A0 GVNI_TORIGHT=A0=A0=A0=A0 =3D Search to the right of the initial cell
=A0
=A0 GVS_BOTH Use fixed and non-fixed cells.
=A0 GVS_DATA Use only non-fixed cells.
=A0 GVS_DEFAULT Default.
=A0 GVS_HEADER Use only the fixed cells.
Brian Millham <bmillham@...> wrote:=20
Hi Art,
You have it right.=A0 You just got caught by the 0 index.=A0 You are =
trying to
set the contents of cell , but you should be setting cell 1.
=A0
=A0 for my $CellType (GVIT_NUMERIC, GVIT_DATE, GVIT_DATECAL, GVIT_TIME,
GVIT_CHECK, GVIT_COMBO, GVIT_LIST, GVIT_URL) {
=A0=A0=A0=A0 $Grid->SetCellType($row++, 1, $CellType);
=A0 }
=A0 $Grid->SetCellOptions( 5, 1, 1 );=A0 # button?
=A0 $Grid->SetCellOptions( 6, 1, [ "Combo", "Box" ]);
=A0 $Grid->SetCellOptions( 7, 1, [ "List", "Box" ]);
I changed the above lines, and your sample worked for me.
Brian Millham
This message traveled at least 44,000 miles to reach you!
Creator of the DW6000 Monitor
http://www.millham.net/dw6000
bmillham@...
---
avast! Antivirus: Inbound message clean.
Virus Database (VPS): 0641-3, 10/12/2006
Tested on: 10/12/2006 5:04:51 PM
avast! is copyright (c) 2000-2006 ALWIL Software.
http://www.avast.com
---
avast! Antivirus: Outbound message clean.
Virus Database (VPS): 0641-3, 10/12/2006
Tested on: 10/12/2006 8:04:30 PM
avast! is copyright (c) 2000-2006 ALWIL Software.
http://www.avast.com
|