Somewhere in my app I have the statement RE.Lines.LoadFromStream(st) where RE is a TRichEdit control.
I have also set the event onResizeRequest that fires up on execution of the above statement but not every time although the event remains assigned.
The code is big and I can't cut a part of it to show it.
Can I add some command, for example RE.Perform(.....) that will force the control to execute the event (or even better not to use an event but a function that I will call whenever I want)?
It seems to be an implementation detail of rich edit control that the common controls library prevents generating EN_REQUESTRESIZE notification when the width or height of the control is zero.
To force EN_REQUESTRESIZE notification, send EM_REQUESTRESIZE message to rich edit control's window. This will generate the notification regardless of the control's size.
SendMessage(RE.Handle, EM_REQUESTRESIZE, 0, 0);
CRichEditCtrl from MFC has a dedicated method RequestResize for that. To mimic that you can implement a class helper:
uses
Vcl.ComCtrls, Winapi.RichEdit;
type
TCustomRichEditHelper = class helper for TCustomRichEdit
public
procedure RequestResize;
end;
procedure TCustomRichEditHelper.RequestResize;
begin
if HandleAllocated then
SendMessage(Handle, EM_REQUESTRESIZE, 0, 0);
end;
You can then call:
RE.RequestResize;