Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Display a caption with a rectangle around the field


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 2 - Last Post: Sep 6, 2016 1:00 PM Last Post By: Donald Bossen
Donald Bossen

Posts: 81
Registered: 2/3/02
Display a caption with a rectangle around the field  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 8, 2016 1:27 PM
How would you Create a rectangle around a tcaption on the form black letters with a black square around the letters.
This will cause a red rectangle on the Screen.
FldTest.Canvas.Brush.Color := clred;
FldTest.Canvas.Rectangle(FldTest.Canvas.ClipRect);
Thanks
Donald S. Bossen
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Display a caption with a rectangle around the field  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Jun 8, 2016 2:06 PM   in response to: Donald Bossen in response to: Donald Bossen
Donald wrote:

How would you Create a rectangle around a tcaption on the form black
letters with a black square around the letters.
This will cause a red rectangle on the Screen.
FldTest.Canvas.Brush.Color := clred;
FldTest.Canvas.Rectangle(FldTest.Canvas.ClipRect);

Use TCanvas.TextRect() to draw the text within the bounds of a rect, and
then use TCanvas.Rectangle() to draw the border around the text.

http://docwiki.embarcadero.com/Libraries/en/Vcl.Graphics.TCanvas.TextRect

Use TextRect to write a string **within a limited rectangular region**. Any
portions of the string that fall outside the rectangle passed in the Rect
parameter are clipped and don't appear.

http://docwiki.embarcadero.com/Libraries/en/Vcl.Graphics.TCanvas.Rectangle

Use Rectangle to draw a rectangle **using Pen and fill it with Brush**

Set the Canvas.Font.Color to clBlack, the Canvas.Pen.Color to clBlack, and
the Canvas.Brush.Style to bsClear.

r := Rect(...); // desired coordinates
FldTest.Canvas.Font.Color := clBlack;
FldTest.Canvas.Pen.Color := clBlack;
FldTest.Canvas.Brush.Style := bsClear;
FldTest.Canvas.TextRect(r, ...); // desired text and attributes
FldTest.Canvas.Rectangle(r);


--
Remy Lebeau (TeamB)
Donald Bossen

Posts: 81
Registered: 2/3/02
Re: Display a caption with a rectangle around the field  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 6, 2016 1:00 PM   in response to: Donald Bossen in response to: Donald Bossen
Good Answer
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02