Recent

Author Topic: [SOLVED] TScrollBox doesn't scroll TImage child  (Read 5359 times)

tofdesbois

  • Newbie
  • Posts: 2
[SOLVED] TScrollBox doesn't scroll TImage child
« on: April 03, 2017, 04:17:34 pm »
Hello,
I tested this in Lazarus 1.6.4 and in CodeTyphon 5.8. Version : Win32 on Windows 10.
In a simple example, I put a TScrollBox, and in it a Tbutton and a TImage (with a Picture to see what appends).
And 2 buttons outside the Scrollbox, to scroll it, and 2 labels to control :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.ButtonUpClick(Sender: TObject);
  2. begin
  3.   ScrollBox1.ScrollBy(0, 100);
  4.   ScrollBox1.Repaint; // to avoid shadow images
  5.   Label1.Caption := IntToStr(Image1.Top);
  6.   Label2.Caption := IntToStr(ButtonTest.Top);
  7. end;
  8.  
The test button scrolls correctly, but the image doesn't move.
Does someone know why ? Is it a bug ?
Thanks.
« Last Edit: April 04, 2017, 12:41:32 pm by tofdesbois »

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: TScrollBox doesn't scroll TImage child
« Reply #1 on: April 04, 2017, 10:54:34 am »
...Win32 on Windows 10.
In a simple example, I put a TScrollBox, and in it a Tbutton and a TImage
...
The test button scrolls correctly, but the image doesn't move.
Does someone know why ? Is it a bug ?
No. TButton is a windowed control, but TImage is not. Therefore, Windows.ScrollWindowEx does not scrolls it (there is no window to receive messages about changing the position).
Put the TImage on a windowed item such as a TPanel

tofdesbois

  • Newbie
  • Posts: 2
Re: TScrollBox doesn't scroll TImage child
« Reply #2 on: April 04, 2017, 12:40:36 pm »
Ok, thank you.
It's for a migration from Delphi 6. It's working in Delphi. Is TImage windowed in Delphi ?

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: TScrollBox doesn't scroll TImage child
« Reply #3 on: April 04, 2017, 04:16:42 pm »
It's working in Delphi. Is TImage windowed in Delphi ?
Also not a windowed control. But Delphi makes some additional adjustments of the controls after scrolling, Lazarus no.
Here in Lazarus:
Code: Pascal  [Select][+][-]
  1. procedure TScrollingWinControl.ScrollBy(DeltaX, DeltaY: Integer);
  2. begin
  3.   ScrollBy_WS(DeltaX, DeltaY);
  4. end;
  5. ...
  6. procedure TWinControl.ScrollBy_WS(DeltaX, DeltaY: Integer);
  7. begin
  8.   if HandleAllocated then
  9.     TWSWinControlClass(WidgetSetClass).ScrollBy(Self, DeltaX, DeltaY)
  10.   else
  11.     raise Exception.Create('TWinControl.ScrollBy_WS: Handle not allocated');
  12. end;
  13. ...
  14. class procedure TWin32WSWinControl.ScrollBy(const AWinControl: TWinControl;
  15.   DeltaX, DeltaY: integer);
  16. begin
  17.   if AWinControl.HandleAllocated then
  18.     ScrollWindowEx(AWinControl.Handle, DeltaX, DeltaY, nil, nil, 0, nil,
  19.       SW_INVALIDATE or SW_ERASE or SW_SCROLLCHILDREN);
  20. end;
Here in Delphi:

[DELETED BY ADMIN ]
« Last Edit: April 04, 2017, 09:18:21 pm by Martin_fr »

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: [SOLVED] TScrollBox doesn't scroll TImage child
« Reply #4 on: April 04, 2017, 04:56:58 pm »
It's a bug. Please report to mantis. I remember Juha changed ScrollBy implementation.

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: [SOLVED] TScrollBox doesn't scroll TImage child
« Reply #5 on: April 04, 2017, 05:16:15 pm »
Report to mantis = create a bug report on mantis.freepascal.org.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: TScrollBox doesn't scroll TImage child
« Reply #6 on: April 04, 2017, 09:20:19 pm »
[DELETED BY ADMIN ]

The above post was modified by forum admin.

Please do not copy and publish code from Delphi. (Or other copyrighted sources)

Please also do not copy the Delphi code (or anything based on it / modified) to our bugtracker.

You should report the bug.
But the fixing must be done by a person who has not looked at the Delphi sources.
« Last Edit: April 04, 2017, 09:26:17 pm by Martin_fr »

 

TinyPortal © 2005-2018