Recent

Author Topic: [Solved] Line drawn is immediately deleted  (Read 2147 times)

nikel

  • Full Member
  • ***
  • Posts: 240
[Solved] Line drawn is immediately deleted
« on: January 04, 2025, 02:01:48 pm »
Hello, I'm trying to draw a line under my radio button. I couldn't make it work. To test, when I draw a line and set the it's parent to form, and run it, the line is immediately deleted. Here's my code so far:
Code: Pascal  [Select][+][-]
  1. FPanels[I].Canvas.Pen.Color:=clWhite;
  2. FPanels[I].Canvas.Pen.Width:=3;
  3. FPanels[I].Canvas.Line(0, 23, 25, 23);

How can I draw a line under my radio button?
« Last Edit: January 04, 2025, 02:26:07 pm by nikel »

cdbc

  • Hero Member
  • *****
  • Posts: 1950
    • http://www.cdbc.dk
Re: Line drawn is immediately deleted
« Reply #1 on: January 04, 2025, 02:10:16 pm »
Hi
I told you already!!!
Use the 'OnPaint' event of the 'TPanel' it's concerning, otherwise the painting won't stay!
Hrmpf - /b

edit: Your job is to find a way, to make all the panels use the same event-handler... So you don't need 100 different, but equivalent OnPaint-handlers...
« Last Edit: January 04, 2025, 02:18:02 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

VisualLab

  • Hero Member
  • *****
  • Posts: 639
Re: [Solved] Line drawn is immediately deleted
« Reply #2 on: January 04, 2025, 06:09:48 pm »
I'm not sure if you mean a window with several panels on which radio buttons are placed, but it can be done as in the screenshot. I'm attaching a project made in Lazarus. Of course, what I gave in the example is just one way to solve the task.

 

TinyPortal © 2005-2018