Heres a working example of your code. It only took minor changes to get it
working. I've added comments where I made changes.
=cut
use Win32::GUI; # Binding to Win32 GUI
use Win32::GUI::Grid; # Binding to Win32 GUI Grid
#use Win32::GUI::Constants; # Windows constants
use integer;
my $TopWindow = new Win32::GUI::Window( # Create Main Window
-name => 'TopWindow',
-helpbox => 1,
-left => 30,
-hashelp => 1,
-height => 450,
-maxwidth => 565,
-minheight => 380,
-minwidth => 565,
-title => 'GUI Editor',
-top => 20,
-width => 570,
);
my $Grid = $TopWindow->AddGrid( # Create Grid object
-columns => 2,
-doublebuffer => 1,
-editable => 1,
# -enable => Enable
-fixedcolumns => 1,
-fixedrows => 1,
# -height => Heigth
-hscroll => 0,
# -left => Left position
-name => "Property Grid",
# -parent => $Editor::Win::TopWindow,
# -popstyle => 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;
my $TopWindow = new Win32::GUI::Window( # Create Main Window
-name => 'TopWindow',
-helpbox => 1,
-left => 30,
-hashelp => 1,
-height => 450,
-maxwidth => 565,
-minheight => 380,
-minwidth => 565,
-title => 'GUI Editor',
-top => 20,
-width => 570,
);
my $Grid = $TopWindow->AddGrid( # Create Grid object
-columns => 2,
-doublebuffer => 1,
-editable => 1,
# -enable => Enable
-fixedcolumns => 1,
-fixedrows => 1,
# -height => Heigth
-hscroll => 0,
# -left => Left position
-name => "Property Grid",
# -parent => $Editor::Win::TopWindow,
# -popstyle => Pop style
-pos => [0, 0 ],
# -pushstyle => Push style
-rows => 9,
# -size => [ 140, $TopWindow->Height()-43 ],
# -style => Default style
# -top => Top position
-visible => 1,
-vscroll => 0,
# -width => 140,
);
$Grid->SetCellText(0, 0, "Property" );
$Grid->SetCellText(0, 1, "Value" );
for my $row (1..$Grid->GetRows()) {
$Grid->SetCellText($row, 0, "Property $row " );
}
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>");
# }
}
my $row = 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) = ($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 => [0, 0 ],
# -pushstyle => Push style
-rows => 9,
# -size => [ 140, $TopWindow->Height()-43 ],
# -style => Default style
# -top => Top position
-visible => 1,
-vscroll => 0,
# -width => 140,
);
$Grid->SetCellText(0, 0, "Property" );
$Grid->SetCellText(0, 1, "Value" );
for my $row (1..$Grid->GetRows()) {
$Grid->SetCellText($row, 0, "Property $row " );
}
for my $row (1..4) {
# for my $col (0..$Grid->GetColumns()) {
$Grid->SetCellText($row, 1, "Cell : <$row, 1>");
# }
}
my $row = 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) = ($TopWindow->GetClientRect)[2..3];
$Grid->Resize ($width, $height);
$Grid->AutoSize(GVS_BOTH);
$Grid->ExpandLastColumn;
}
=end
Brian Millham
This message traveled at least 44,000 miles to reach you!
Creator of the DW6000 Monitor
http://www.millham.net/dw6000
[EMAIL PROTECTED]
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Arthur Schwarz
Sent: Thursday, October 12, 2006 12:35 PM
To: Brian Millham; [email protected]
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.
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):
GVIT_CHECK = Check Box
GVIT_DATE = Date control
GVIT_DATECAL = Date control with calendar control
GVIT_DEFAULT =
GVIT_COMBO = Combo Box
GVIT_LIST = List Box
GVIT_NUMERIC = Numeric control edit
GVIT_TIME = Time control
GVIT_URL = Url control
GVL_BOTH Both vertical and horizontal grid lines
GVL_NONE No grid lines.
GVL_HORZ Horizontal grid lines only.
GVL_VERT Vertical grid lines only.
GVNI_ABOVE = Search above initial cell
GVNI_ALL = Search all cells in the grid starting from the given
cell
GVNI_AREA = Search all cells below and to the right of the given
cell
GVNI_BELOW = Search below initial cell
GVNI_DROPHILITED = Search for drop highlighted cells
GVNI_FIXED = Search for fixed cells
GVNI_FOCUSED = Search for focus cell
GVNI_MODIFIED = Search for modified cells
GVNI_READONLY = Search for read-only cells
GVNI_SELECTED = Search for selected cells
GVNI_TOLEFT = Search to the left of the initial cell
GVNI_TORIGHT = Search to the right of the initial cell
GVS_BOTH Use fixed and non-fixed cells.
GVS_DATA Use only non-fixed cells.
GVS_DEFAULT Default.
GVS_HEADER Use only the fixed cells.
Brian Millham <[EMAIL PROTECTED]> wrote:
Hi Art,
You have it right. You just got caught by the 0 index. You are trying to
set the contents of cell , but you should be setting cell 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" ]);
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
[EMAIL PROTECTED]
---
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