Recent

Author Topic: TLabel with border.  (Read 28179 times)

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
TLabel with border.
« on: June 07, 2011, 02:13:33 pm »
Hi.
Hi research lots of times in google how to put borders on a Label.
I need to know how to do it.
How I put borders on a Label?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabel with border.
« Reply #1 on: June 07, 2011, 02:28:44 pm »
I don't know if it is possible with TLabel.
But you can use TPanel. It has Caption and Borders. See screenshot.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: TLabel with border.
« Reply #2 on: June 07, 2011, 02:41:58 pm »
Or use a TLabel within a TShape.

1.0/2.6.0  XP SP3 & OS X 10.6.8

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TLabel with border.
« Reply #3 on: June 07, 2011, 03:44:20 pm »
Code: [Select]
Label1.Canvas.Rectangle(0,0,Label1.Width, Label1.Height);

You could put it on an OnPaint event of the form.

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: TLabel with border.
« Reply #4 on: June 07, 2011, 04:27:37 pm »
@typo
Strange, it works bad on Qt widgetset.
I have to use:
Code: [Select]
  with Label2 do
    Canvas.Rectangle(Left, Top, Left+Width, Top+Height);
to set correct position.
And when I close form it gives SIGSEGV in function
Code: [Select]
function TQtWidgetSet.IsValidGDIObject(const GDIObject: HGDIOBJ): Boolean;Maybe I will do bugreport.

There are also Canvas.Frame3D functions.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TLabel with border.
« Reply #5 on: June 07, 2011, 04:45:21 pm »
Quote
Maybe I will do bugreport.

Yes.

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: TLabel with border.
« Reply #6 on: June 07, 2011, 04:53:40 pm »
And I when I try create the event OnPaint by design he says Unable to create the new method. Please fix the error shown in the message window, whick is normally bellow the source editor.
The bug is in the unit Controls and is Error: [TFindDeclarationTool.FindCodeToolForUsedUnit] internal error: invalid UnitNameAtom .
Will I do bugreport?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: TLabel with border.
« Reply #7 on: June 07, 2011, 05:02:42 pm »
I think it is not a bug, this means that the compiler has found an error in your code. Try to fix it.

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: TLabel with border.
« Reply #8 on: June 07, 2011, 05:04:45 pm »
Until with an empty project it do error.

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: TLabel with border.
« Reply #9 on: June 07, 2011, 05:09:23 pm »
Don't think this is right anyway ...
Code: [Select]
with Label2 do
    Canvas.Rectangle(Left, Top, Left+Width, Top+Height);

You'ld be using the "left" and "top" position of the label on the form, not the canvas of the label, I assume.
1.0/2.6.0  XP SP3 & OS X 10.6.8

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: TLabel with border.
« Reply #10 on: June 07, 2011, 05:11:54 pm »
Canvas is a graphical class for Lazarus. Losts of components like forms have it.

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: TLabel with border.
« Reply #11 on: June 07, 2011, 05:16:36 pm »
I know, but if you use the "left" and "top" like that you won't see any rectangle around your label because the coordinates are all off:

Code: [Select]
  with Label2 do
    Canvas.Rectangle(Left, Top, Left+Width, Top+Height);

does not show a rectangle, but this one does (at least on my XP machine)

Code: [Select]
  with Label2 do
    Canvas.Rectangle(0, 0, Width, Height);
1.0/2.6.0  XP SP3 & OS X 10.6.8

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: TLabel with border.
« Reply #12 on: June 07, 2011, 05:27:43 pm »
Width and heigth are the properties of Label that indicate the size of the Label.
Left and Top indicate where the label is started draw.
So by sum Left more width you obtain the coordinate x of the left corner. By sum top with heigth you obtain the coordinate y of the left corner of the Label.

Arbee

  • Full Member
  • ***
  • Posts: 223
Re: TLabel with border.
« Reply #13 on: June 07, 2011, 05:31:44 pm »
Which is precisely why
Code: [Select]
with Label2 do
    Canvas.Rectangle(Left, Top, Left+Width, Top+Height);
does not work
and why
Code: [Select]
with Label2 do
    Canvas.Rectangle(0,0, Width, Height);
does.

See two screen shots:

1.0/2.6.0  XP SP3 & OS X 10.6.8

dicas3d

  • Jr. Member
  • **
  • Posts: 81
    • Site oficial do Lazarus Portugal
Re: TLabel with border.
« Reply #14 on: June 07, 2011, 06:56:27 pm »
This can work on your case:
Code: [Select]
with Label1 do [code]Canvas.Rectangle(left,top, Width, Height);.
But with me I can't see any Rectangle around My Label.
Code: [Select]
with Label1 do Canvas.Rectangle(0,0, Width, Height);[/code]

 

TinyPortal © 2005-2018