Resize window and large document

General TRichView support forum. Please post your questions here
Post Reply
jimbr32
Posts: 20
Joined: Thu Nov 09, 2006 10:01 pm

Resize window and large document

Post 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?
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Resize window and large document

Post 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
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Resize window and large document

Post by Sergey Tkachenko »

You can try to include/exclude rvstSkipformatting in RichViewEdit.RVData.State.
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Resize window and large document

Post 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
Post Reply