View Issue Details

IDProjectCategoryView StatusLast Update
0036046LazarusLCLpublic2020-04-16 23:53
ReporterSerge Anvarov Assigned Towp  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformWindowsOSWindows 
Product Version2.0.4 
Summary0036046: TTrackBar. Patch. For large ranges (Max - Min) and TickStyle = tsAuto (default) windows hang
DescriptionWindows tries to draw all these ticks, causing itself to hang (don't answer for very long).
The decision is made as in Delphi: with a large range cancels auto drawing ticks.

Steps To ReproduceIn new empty application put TTrackBar on form and add:
procedure TForm1.FormCreate(Sender: TObject);
begin
  TrackBar1.Max := MaxInt;
end;
Additional InformationSee https://forum.lazarus.freepascal.org/index.php/topic,46606.msg332560.html#msg332560
TagsNo tags attached.
Fixed in Revision62125
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Serge Anvarov

2019-09-04 19:31

reporter  

TrackBar.LargeRange.diff (1,091 bytes)   
Index: lcl/interfaces/win32/win32wscomctrls.pp
===================================================================
--- lcl/interfaces/win32/win32wscomctrls.pp	(revision 61813)
+++ lcl/interfaces/win32/win32wscomctrls.pp	(working copy)
@@ -969,6 +969,7 @@
 var
   wHandle: HWND;
   NewStyle: integer;
+  LTicksStyle: DWORD;
 const
   StyleMask = TBS_AUTOTICKS or TBS_NOTICKS or TBS_VERT or TBS_TOP or TBS_BOTH or
     TBS_ENABLESELRANGE or TBS_REVERSED;
@@ -982,7 +983,10 @@
   begin
     { cache handle }
     wHandle := Handle;
-    NewStyle := TickStyleStyle[TickStyle] or OrientationStyle[Orientation] or
+    LTicksStyle := TickStyleStyle[TickStyle];
+    if (Max - Min) > 10000 then // 10000 - for Delphi compatibility
+      LTicksStyle := 0; // Skip draw ticks to avoid hanging
+    NewStyle := LTicksStyle or OrientationStyle[Orientation] or
                 TickMarksStyle[TickMarks] or SelRangeStyle[ShowSelRange] or ReversedStyle[Reversed];
     UpdateWindowStyle(wHandle, NewStyle, StyleMask);
     Windows.SendMessage(wHandle, TBM_SETRANGEMAX, Windows.WPARAM(True), Max);
TrackBar.LargeRange.diff (1,091 bytes)   

Juha Manninen

2019-10-20 17:46

developer   ~0118730

Wp, you apparently know this issue best. You can apply or reject the patch or commit an improved one.

wp

2019-10-26 19:20

developer   ~0118859

Applied with modifications
- increased the limit above which ticks are hidden, maybe can go even higher...
- added a define for Win64 because Win32 is not affected.

Please test and close if ok.

Serge Anvarov

2019-11-01 20:46

reporter   ~0118957

Not in release yet

wp

2019-11-01 22:08

developer   ~0118965

Last edited: 2019-11-02 12:00

View 2 revisions

Yes. I did not request backporting because I fixed the issue very closely to the release date and there was not enough time to get feedback. Anyway, it is a minor issue which affects only a minority of use cases.

BTW: Still there is no feedback...

Serge Anvarov

2020-04-16 23:53

reporter   ~0122181

Applied Lazarus 2.0.8

Issue History

Date Modified Username Field Change
2019-09-04 19:31 Serge Anvarov New Issue
2019-09-04 19:31 Serge Anvarov File Added: TrackBar.LargeRange.diff
2019-10-20 17:44 Juha Manninen Assigned To => wp
2019-10-20 17:44 Juha Manninen Status new => assigned
2019-10-20 17:46 Juha Manninen Note Added: 0118730
2019-10-26 19:20 wp Status assigned => resolved
2019-10-26 19:20 wp Resolution open => fixed
2019-10-26 19:20 wp Fixed in Revision => 62125
2019-10-26 19:20 wp LazTarget => -
2019-10-26 19:20 wp Widgetset Win32/Win64 => Win32/Win64
2019-10-26 19:20 wp Note Added: 0118859
2019-11-01 20:46 Serge Anvarov Note Added: 0118957
2019-11-01 22:08 wp Note Added: 0118965
2019-11-02 12:00 wp Note Edited: 0118965 View Revisions
2020-04-16 23:53 Serge Anvarov Status resolved => closed
2020-04-16 23:53 Serge Anvarov Note Added: 0122181