TEdit and resizing

General TRichView support forum. Please post your questions here
Post Reply
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

TEdit and resizing

Post by BernhardRoos »

Is it possible that a TEdit control changes its size during the user is editing in this TEdit Field (like as MS Word).
How can I solve this?
Best wishes
Bernhard
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

You can assign this code to OnChange of TEdits:

Code: Select all

procedure TForm1.OnControlChange(Sender: TObject);
var txt: TEdit;
begin
  txt := (Sender as TEdit);
  Canvas.Font := txt.Font;
  txt.ClientWidth := Canvas.TextWidth(txt.Text)+6;
  RichViewEdit1.AdjustControlPlacement2(txt);
end;
(do not forget to reassign it in OnControlAction, after RVF loading).
There is one problem: AdjustControlPlacement2 does not update item resizer. It will be fixed in the next update.
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

Thanks for your answer.
Is there a similar function for TRichView because the user makes his inputs in a TRichView component (not in TRichViewEdit)
AdjustControlPlacement2 is only for TRichViewEdit.
Best wishes
Bernhard
BernhardRoos
Posts: 104
Joined: Mon Nov 26, 2007 1:49 pm

Post by BernhardRoos »

I've found something.
If I call Format it works.
Best wishes
Bernhard
Post Reply