Recent

Author Topic: Possible Bug in TTrackbar (win7-x64)?  (Read 1367 times)

wp

  • Hero Member
  • *****
  • Posts: 6662
Re: Possible Bug in TTrackbar (win7-x64)?
« Reply #30 on: September 04, 2019, 08:47:10 pm »
I think it is more logical to restrain the Frequency to the width of the control?

so if the range value exceeds the control's width in pixels it should automatically adjust the frequency for a proper fit.

 I just ran some test here and it does not effect any code that I can see, it actually works perfectly because I still get my graph bar even with high values.

 So basically this..

  If TrackBar.Width < Range / Frequency Then Frequency := Range / TrackBar.Width;

 To me that is a better choice because at least you still get a tick bar and it does not flood the message que with notifications when updating the ticks

 Can you please put in a Option in the properties to select which way to adjust the conditions  for
large values?
Again, as I already said, the Frequency is not the problem. The problem is Max. You can select any Frequency and the system will hang once Max is too large.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

ASerge

  • Hero Member
  • *****
  • Posts: 1433
Re: Possible Bug in TTrackbar (win7-x64)?
« Reply #31 on: September 04, 2019, 08:56:26 pm »
Code: Pascal  [Select]
  1. trackbar.Min        := 0;
  2. trackbar.Max        := 50000;
  3. trackbar.Frequency  := 5000;
we have 10 intervals (= 50000/5000) - this means: 11 ticks. And this is what is displayed by the LCL Trackbar. But with your patch there are no more ticks because Max is > 10000.
I tried to use (Max - Min) div Frequency, but... with Max = MaxInt and Frequency = MaxInt div 10000 limit does not work, and Windows hangs again (not as long, only 2-3 minutes). Delphi avoids this by re-creating the window.
Yes, it's need to find another solution.

jamie

  • Hero Member
  • *****
  • Posts: 2262
Re: Possible Bug in TTrackbar (win7-x64)?
« Reply #32 on: September 04, 2019, 08:57:29 pm »
I set the max to MaxInt and a freq scale down, it works ..

 I understand the problem in the OS of it updating too many times due to the max but what happens if some coder wants that high value?  Yes I know you can kill the tick bar but then you lose the looks..

 Do as you please, I 'll use a different control if need be, I only have one app that uses a large scale value via that control but I think I may have set the freq without knowing why....

Number 1 at blue screen app creations!

winni

  • Hero Member
  • *****
  • Posts: 719
Re: Possible Bug in TTrackbar (win7-x64)?
« Reply #33 on: September 04, 2019, 09:18:13 pm »
Yes, the problem are high values of max.

But the elapsed time is not independend of the frequency:

Trackbar1.max := maxint shr 6;

Frequency := max;              43 seconds
Frequency := max div 10;   45 seconds
Frdequency := 1;                 73 seconds

Winni

winni

  • Hero Member
  • *****
  • Posts: 719
Re: Possible Bug in TTrackbar (win7-x64)?
« Reply #34 on: September 04, 2019, 09:32:33 pm »
Some c# guys detected the same problem with the trackbar and 64 bit:

https://stackoverflow.com/questions/15209736/system-windows-forms-trackbar-memory-use-with-a-large-maximum-value

And they have some new infos:

_________snip________
 You can survive that in design mode by assigning the properties in the right order. But it is
compounded by a flaw in the TrackBar class wrapper, it assigns the Maximum property before the TickFrequency property when it initializes the native control at runtime. So for a brief moment it still has a gazillion ticks. Well, it is not brief when it is 2 billion of them, like I unwittingly tried.
______snap__________

Winni

jamie

  • Hero Member
  • *****
  • Posts: 2262
Re: Possible Bug in TTrackbar (win7-x64)?
« Reply #35 on: September 04, 2019, 09:42:42 pm »
I set the control at 10M and Freq at 50K, it works perfectly

We are not talking about a small margin of Freq here, we are talking about scaling it down to near the width of the control and that is a large scale down..

 Your scale of 10 is nothing.

 Please try this

 Freq := MaxInt div TrackBar.Width;

 Of course you only want to do this where values far exceed the size of the control DIV by the current freq value, its then you want to force a new Freq scale.
 
 P.S.

  MS must be aware of this issue because I just moved this to a Win10 PC recent update and with MaxInt there is no tick marks regardless of freq scaling.

 But still at 200M the ticks to show and it slows if I don't use proper scaling of FREQ.
I just think the FREQ should be scaled automatically when MAX exceeds far beyond what can be drawn on the screen for the scale..
Number 1 at blue screen app creations!