Solved

Componet caption not refreshing properly

Posted on 2006-10-31
7
187 Views
Last Modified: 2010-04-05
Hi,

I need some helpw with this.  I have a new component (TCustomControl descendant).  The component has a Caption property declared as:

published
  property Caption;
..

end;

In the OnCreate method, I have the following code:

constructor TPAG_Label.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  TextCase := csUpperCase;
  AutoSize := false;
  Color := clWhite;
  BorderColor := clWhite;
  Alignment := taLeftJustify;
  Layout := tlTop;

  Caption := Name;
end;

In this instance, the caption of the component takes the name of the control (which is what I want).  However, if I now type some text into the caption property, or change the component name, the caption doesn't refresh at all.

Can someone give me some guidance please?

Thanks,

Pag.
0
Comment
Question by:PAG_Promax
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 17849165
Trying putting in these extra calls to update the label

constructor TPAG_Label.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  TextCase := csUpperCase;
  AutoSize := false;
  Color := clWhite;
  BorderColor := clWhite;
  Alignment := taLeftJustify;
  Layout := tlTop;

  Caption := Name;

  Refresh;
  Invalidate;
end;
0
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 17849178
in fact Ive just noticed that this is the create of your label.
Where are you "typing some text"?

Your create will only set the caption of the label once, as this is all you have told it to do.
You need to then tell it to update the caption of the label once you have changed the text.
0
 

Author Comment

by:PAG_Promax
ID: 17855234
Its in the Object Inspector.  If I change the caption to "this is something new", it wont refresh until I move the control or resize it, or change one of the other properties which refreshes the control.
0
Technology Partners: 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

by:PAG_Promax
ID: 17943794
Any thing else that can be added to this at all?
0
 
LVL 4

Expert Comment

by:Meldrachaun
ID: 17963567
Try adding this method to your component:


procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;


procedure TMyComponent.CMTextChanged(var Message: TMessage);
begin
  Invalidate;
end;
0
 
LVL 4

Accepted Solution

by:
Meldrachaun earned 125 total points
ID: 17984249
Actually, it should probably be

procedure TMyComponent.CMTextChanged(var Message: TMessage);
begin
  inherited;
  Invalidate;
end;
0
 

Author Comment

by:PAG_Promax
ID: 18033259
Thanks for that!
0

Featured Post

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Suggested Courses
Course of the Month7 days, 21 hours left to enroll

617 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