Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


TRect Trouble..

Posted on 2003-03-04
Medium Priority
Last Modified: 2012-05-04
Hi, I have recently finished making my first ever component called TExtLabel. It basically, so far, shows any text with a very accurate and neat border around it; at least I thought so.

After looking at the output a few times I noticed that the furthest left and furthest right pixel was being cut-off and made some characters look a little blocky. I have tried to fix the problem but everything I do will not work.

I have included full source and the DPK file here:

If anyone could maybe fix my source so that it shows the extra pixel on both left and right sides of the label I will award the points. :)

Thanks very much, Nat.
Question by:Krakken
  • 4
  • 2
LVL 34

Accepted Solution

Slick812 earned 400 total points
ID: 8067226
hello Krakken, I looked at your code, and it seems that you are trying to Draw outside the controls paint area, so I added some code to expand the area of the control on the auto size for text, but I really did not see the "Left side" pixel not there, so All I did was increase the Right side of the control so the DrawText for offset rect to Right will have something to draw on - - - -

(Code removed at the request of the questioner because it is the code of the questioner.  I have saved the code for future reference only in the event it comes up again

E-E Admin)

- - - - - - - - - - - - - - - - - - -
if you still have Left side problems, then you might adj that as well

Author Comment

ID: 8067568
Okay i'm trying that now :)
I adapted some of the code from someone else so thanks for commenting out the bits I didn't need. ;)

Author Comment

ID: 8067668
Yes the left pixel is still missing. Sorry it only shows on certain fonts.

I can't seem to fix this either.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 8067796
No matter, done it! Thanks!
LVL 34

Expert Comment

ID: 8068672
you may want to increase the amount that you add to the Controls width, I used 3 pixels but 4 or 5 pixels may be better??

also you may want to change

if (rctFla and DT_CALCRECT <> 0) and ((Length(Caption) = 0) or
  ShowAccelChar and (Caption[1] = '&') and (Length(Caption) = 1)) then sText := ' ';


if (rctFla and DT_CALCRECT <> 0) and ((Length(Caption) = 0) or
  ShowAccelChar and (Caption[1] = '&') and (Length(Caption) = 1)) then Exit;

since there is no text drawn with a Space

and leave out the sText altogether and just use Caption
DrawText(Canvas.Handle, PChar(Caption),

Author Comment

ID: 8068891
Thanks again! :)

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question