Recent

Author Topic: Background Color  (Read 5938 times)

blondMammuth

  • New Member
  • *
  • Posts: 16
Background Color
« on: September 09, 2014, 02:00:01 pm »
Hallo All,

I want to change the background color of a canvas. Or does it belong to the panel? Can I only do it by drawing a big rect?

I also want to delete lines. I thought I'd assign the background color to the brush and so delete the line by redrawing it. Or is there a better solution?

When doing so, I came across this page:

http://wiki.lazarus.freepascal.org/Colors

A "clBackground" is mentioned there, but without any explanation. It also does not seem to work the way I would have hoped. How do I find out / change the current background color?

Any hint would be appreciated. Thanks!

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Background Color
« Reply #1 on: September 09, 2014, 03:17:21 pm »
Colour in GUI apps is a complex subject. There is no one-answer-fits-all reply to your questions, since details often depend on your OS and hardware.
OS widgets are drawn by the OS, and their colour may or may not be easily programmable. For instance, on Windows whatever you value you give Button1.Color it will keep its Windows theme colour.
For opaque controls that provide a canvas and a virtual Paint method (or an OnPaint event) you can paint custom backgrounds with the Canvas.Brush using FillRect() or copying a bitmap or other image to the Canvas.
Some OSs forbid painting outside the Paint procedure, so for cross-platform reasons you should avoid painting elsewhere, even if (as Windows allows) it is possible.
Setting the colour property of a control is the simplest place to start, and resort to custom painting only if the provided properties do not achieve the effect you want. TPanel is not an OS widget, so gives you more flexibility in altering its appearance in a cross-platform way.
Custom-drawn controls (such as the BGRAControls) can provide striking effects, even if they lack the look-and-feel of a 'standard' GUI interface.

 

TinyPortal © 2005-2018