Recent

Author Topic: Customcontrol with scrollbars  (Read 4267 times)

erdesigns

  • Newbie
  • Posts: 2
Customcontrol with scrollbars
« on: July 27, 2021, 12:38:27 pm »
I am trying to rewrite some components i wrote for Delphi, and convert them for Lazarus. In delphi i know how to add scrollbars to a customcontrol, but i cant find anything on how to do this in Lazarus.
I dont want to use a scrollbox, i want to start with a TCustomControl and work from there. Is there anyone who can point me in the right direction? All i can find are solutions including a scrollbox - which is not what i want to use, as i will draw everything myself in the paint procedure.

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Customcontrol with scrollbars
« Reply #1 on: July 27, 2021, 05:35:12 pm »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

wp

  • Hero Member
  • *****
  • Posts: 11830
Re: Customcontrol with scrollbars
« Reply #2 on: July 27, 2021, 06:02:00 pm »
All i can find are solutions including a scrollbox - which is not what i want to use, as i will draw everything myself in the paint procedure.
What is the problem? Suppose your control is 1000x1000 pixels - within this area you can paint everything in the corresponding Paint method. When you put this control into a scrollbox of 500x500 pixels you automatically get the scrollbars. That's what a scrollbox is good for.

Look at attached demo with a large paintbox inside a smaller scrollbox

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: Customcontrol with scrollbars
« Reply #3 on: July 28, 2021, 03:26:24 am »
You don't give us enough info to help you better, like what problems you're finding, what are your requisites, etc. but there are several ways of doing what I think you want: making a composite control with internal TScrollBar(s) or TCDScrollbar(s), deriving your control from TScrollingWinControl or, probably better, TCDScrollableControl, etc.

Which of these to use depends quite a lot on what exactly you want to do and, since you're moving from Delphi, how you did it in Delphi.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

erdesigns

  • Newbie
  • Posts: 2
Re: Customcontrol with scrollbars
« Reply #4 on: July 29, 2021, 03:15:13 pm »
Well in Delphi i did it with SetScrollInfo(Handle, SB_VERT, SI, True); and procedure WndProc(var Message: TMessage); override;
but that seems to be very windows specific.

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Customcontrol with scrollbars
« Reply #5 on: July 29, 2021, 06:56:20 pm »
Hi!

Either you deliver us a crystall ball or some infos about your project and some code.

Winni
« Last Edit: July 29, 2021, 07:07:40 pm by winni »

 

TinyPortal © 2005-2018