Page 1 of 1

Resize window and large document

Posted: Wed May 29, 2019 10:25 pm
by jimbr32
Using RichViewEdit version 17.4, Delphi 10 Seattle

Some of our customers have reported that it is difficult to resize my application window when RichViewEdit controls contain fairly large documents (between 1 and 2 MB of text). Multiple documents are loaded on tabs in a page control. The window is slow to respond to the sizing.

I was wondering about handling WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE in my code to manually reformat richview controls after the window sizing has completed. I haven't been able to get it to work, I think it may be because TCustomRichView is invalidating when it receives WM_Size messages. If I set the RVData flag rvflPrinting in my EnterSizeMove message handler, it works perfectly, the procedure WMSize in TCustomRichView checks this flag before calling FullInvalidate. So setting the flag allows me to resize the window normally, then reformat in my ExitSizeMove message handler.

Is there some other way to handle this?

Re: Resize window and large document

Posted: Sun Sep 10, 2023 8:06 pm
by standay
jimbr32,

Curious if you ever solved this and if so, how? If setting the RVData flag rvflPrinting worked, do you have an example of how you did that?

I've run into this before with formatting components and I've basically locked the component while resizing and then unlocked it after. So far I have not found a good way to do this with my regular rve.

Thanks

Stan

Re: Resize window and large document

Posted: Mon Sep 11, 2023 9:04 am
by Sergey Tkachenko
You can try to include/exclude rvstSkipformatting in RichViewEdit.RVData.State.

Re: Resize window and large document

Posted: Mon Sep 11, 2023 11:53 am
by standay
Sergey Tkachenko wrote: Mon Sep 11, 2023 9:04 am You can try to include/exclude rvstSkipformatting in RichViewEdit.RVData.State.
Hi Sergey,

Yes, that seems to work. Here's what I did:

Code: Select all

  private
  FSizing: boolean;
  ...
  
procedure TForm1.WndProc(var Message: TMessage);  
const
  ResizeLock = 1000;
begin

  if Message.Msg = WM_SYSCOMMAND then
  begin

    //http://www.delphigroups.info/2/13/524188.html
    if (Message.WParam and $FFF0) = SC_SIZE then
    if rve.LineCount > ResizeLock then
    begin
      FSizing := true;
      LockWindowUpdate(MainPanel.Handle);
      rve.RVData.State := rve.RVData.State + [rvstSkipformatting];
    end;

  end;

  if Message.Msg = WM_EXITSIZEMOVE then
  begin
    
    if FSizing then
    begin
      FSizing := false;
      Screen.Cursor := crAppStart;
      rve.RVData.State := rve.RVData.State - [rvstSkipformatting];
      rve.ReformatAll;
      LockWindowUpdate(0);
      Screen.Cursor := crDefault;
    end;
    
  end;
I picked an arbitrary value of 1000 for ResizeLock to skip formatting. I'll probably just change this to a setting that turns "live formatting" on and off. I used FSizing to skip formatting only when the window is being sized, not moved.

This works. I don't load huge files that often but when I do, the delay with "live formatting" can be an issue.

Thanks Sergey, as usual a great help!

Stan