View Issue Details

IDProjectCategoryView StatusLast Update
0021790LazarusWidgetsetpublic2012-05-05 17:07
Reportercobines Assigned ToJesus Reyes  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWin32OSWindows XP 
Product Version1.1 (SVN) 
Summary0021790: Problems setting Width, Height for TCustomGrid if ScrollBars is auto
DescriptionThis is a regression after rev. 36804, bug 0021724. But I tried with some other controls TPanel, TScrollBox, TGroupBox, TMemo, TTreeView but they worked fine with/without scrollbars, so maybe it's a bug in the Grids.

The test it to run attached project and change size of the StringGrid by pressing buttons. The following are some combinations pressed after start:

a) 200 changes only Width
b) 500 doesn't change anything
c) 10 OK, 50 OK, 200 changes only Width
d) 10 OK, 50 OK, 500 nothing
e) 10 OK, 200 only Width, 500 only Width

Sometimes changing size with +, - buttons work when changing size with numbered buttons doesn't. For example:

f) start, press 200 few times, the size is 200x100 and not changing, press +, the size is 210x110
g) start, press 10, and then 500 a few times, the size is 500x10 and not changing, press +, the size is 510x20

When ScrollBars are set to ssBoth or ssNone the bug doesn't exist. When it is ssAutoHorizontal or ssAutoVertical the problems are only in one dimension (either Height or Width).
TagsNo tags attached.
Fixed in Revision36993
LazTarget-
WidgetsetWin32/Win64
Attached Files

Relationships

has duplicate 0021813 closedJesus Reyes TStringGrid "resists" re-sizing vertically 

Activities

2012-04-17 14:19

 

sgrid_widthheight.zip (2,507 bytes)

2012-04-22 12:43

 

disable_lmsize.diff (1,451 bytes)   
Index: lcl/grids.pas
===================================================================
--- lcl/grids.pas	(revision 36969)
+++ lcl/grids.pas	(working copy)
@@ -145,7 +145,7 @@
 
   TGridFlagsOption = (gfEditorUpdateLock, gfNeedsSelectActive, gfEditorTab,
     gfRevEditorTab, gfVisualChange, gfDefRowHeightChanged, gfColumnsLocked,
-    gfEditingDone, gfSizingStarted, gfPainting);
+    gfEditingDone, gfSizingStarted, gfPainting, gfUpdatingSize);
   TGridFlags = set of TGridFlagsOption;
 
   TSortOrder = (soAscending, soDescending);
@@ -4473,6 +4473,14 @@
     LM_HSCROLL, LM_VSCROLL:
       if csDesigning in ComponentState then
         exit;
+    {$IFDEF MSWINDOWS}
+    // Ignore LM_SIZE while another sizing is being processed.
+    // Windows sends WM_SIZE when showing/hiding scrollbars.
+    // Scrollbars can be shown/hidden when processing DoOnChangeBounds.
+    LM_SIZE:
+      if gfUpdatingSize in FGridFlags then
+        exit;
+    {$ENDIF}
   end;
   inherited WndProc(TheMessage);
 end;
@@ -6301,6 +6309,8 @@
 begin
   inherited DoOnChangeBounds;
 
+  FGridFlags := FGridFlags + [gfUpdatingSize];
+
   AVailSpace.x := ClientWidth - FGCache.MaxClientXY.x;
   AVailSpace.y := ClientHeight - FGCache.MaxClientXY.y;
   NewTopLeft := FTopLeft;
@@ -6329,6 +6339,8 @@
     DoTopLeftChange(True);
   end else
     VisualChange;
+
+  FGridFlags := FGridFlags - [gfUpdatingSize];
 end;
 
 procedure TCustomGrid.DoPasteFromClipboard;
disable_lmsize.diff (1,451 bytes)   

cobines

2012-04-22 12:48

reporter   ~0058875

Problem is while processing DoOnChangeBounds, with FWidth, FHeight already set, scrollbars can be shown/hidden and Windows sends WM_SIZE but with old Width, Height. If that is acceptable behavior from the widgetset then I attach patch to Grids.

Jesus Reyes

2012-04-24 07:18

developer   ~0058935

r36804 fixes a bug and I don't think it will be reverted, as it seems the grid is the only affected, I think it's ok to patch it, so the patch is applied, thank you.

Issue History

Date Modified Username Field Change
2012-04-17 14:19 cobines New Issue
2012-04-17 14:19 cobines File Added: sgrid_widthheight.zip
2012-04-17 14:19 cobines Widgetset => Win32/Win64
2012-04-17 14:27 Zeljan Rikalo Status new => assigned
2012-04-17 14:27 Zeljan Rikalo Assigned To => Jesus Reyes
2012-04-22 12:43 cobines File Added: disable_lmsize.diff
2012-04-22 12:48 cobines Note Added: 0058875
2012-04-24 07:18 Jesus Reyes Fixed in Revision => 36993
2012-04-24 07:18 Jesus Reyes LazTarget => -
2012-04-24 07:18 Jesus Reyes Status assigned => resolved
2012-04-24 07:18 Jesus Reyes Fixed in Version => 0.99.1 (SVN)
2012-04-24 07:18 Jesus Reyes Resolution open => fixed
2012-04-24 07:18 Jesus Reyes Note Added: 0058935
2012-04-25 05:31 Jesus Reyes Relationship added has duplicate 0021813
2012-05-05 17:07 cobines Status resolved => closed