Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Componet caption not refreshing properly

Posted on 2006-10-31
7
Medium Priority
?
191 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
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Screencast - Getting to Know the Pipeline

783 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