Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8229163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:42:23+00:00 2026-06-07T16:42:23+00:00

i have problem with Canvas DrawText , i got just first 4 chars from

  • 0

i have problem with Canvas DrawText , i got just first 4 chars from text i want to show .

as example i have text ‘offline’ it will show ‘offl’ .

what the wrong in this code .

the code

procedure TStatusCombo.Paint ;
var DrawRect : TRect ;
    StatusColor : TColor ;
    iTextWidth : Integer ;
    r : TRect ;
begin
DrawRect := ClientRect ;

//colors
Canvas.Brush.Style := bsClear ; //transparent background
Canvas.Brush.Color := Tcolor($4D4D4D) ;
Canvas.Pen.Color :=  Tcolor($4D4D4D)   ;

Canvas.RoundRect(DrawRect.Left , DrawRect.Top ,
            DrawRect.Right , DrawRect.Bottom , 15, 15);

//Drawing
//SetRect(DrawRect, DrawRect.Left+3, DrawRect.Top+3, DrawRect.Right-3, DrawRect.Bottom-3);

case ChatStatus of
  sNormal: StatusColor  :=   TColor($00FF78) ;
  sOnline: StatusColor  :=   TColor($00FF78) ;
  sBusy: StatusColor  :=   TColor($00FF78) ;
  sAway: StatusColor  :=   TColor($00FF78) ;
  sOffline:StatusColor  :=   TColor($00FF78) ;
end;
Canvas.Brush.Color := StatusColor ;

Canvas.RoundRect(DrawRect.Right - 20 , DrawRect.Top +4 ,
            DrawRect.Right -10  , DrawRect.Bottom -4  , 5, 5);


FCaption := FStatusText[ChatStatus];
Canvas.Brush.Style := bsClear ;
Canvas.Font.Color := clWhite ;


DrawText(Canvas.Handle,pchar(FCaption) ,sizeof(FCaption),DrawRect ,DT_VCENTER  or DT_CENTER or DT_SINGLELINE);




end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:42:26+00:00Added an answer on June 7, 2026 at 4:42 pm

    You have to use Length(FCaption) instead of SizeOf(FCaption).

    Indeed, Length(FCaption) is the length of the string FCaption, while SizeOf(FCaption) is the size of the variable FCaption. Since FCaption is a string, it is (technically) a pointer (to the actual characters), and a pointer is four bytes long (in 32-bit applications). Hence, you only got the first four characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with canvas i wanted to show some moving balls on
i have a problem with my script that use canvas. I want to move
I have a problem with the following code: protected void onDraw(Canvas canvas) { Paint
I have recently created a HTML5 canvas animation (also using Processing.js). The problem is
I have been playing about with canvas, but have stumbled across a problem. When
I have problem with show or hide form in Window Form Application. I start
I have problem with UIWebView delay when the load image from url. In my
I have problem to draw line on scaled and transformed image on canvas, well
I have small problem with retrieving the state of a canvas' visibility property. When
i have a problem with rotating a rectangle and place it on a canvas

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.