TRichView at runtime on an hidden/minimized Form

General TRichView support forum. Please post your questions here
Post Reply
Salamander
Posts: 6
Joined: Tue Dec 01, 2009 3:18 am

TRichView at runtime on an hidden/minimized Form

Post by Salamander »

Hi all,
I'm creating a TRichView/TRVStyle at runtime, then I added some RTF, then I call Format, finally I Save it to RTF.
I coded these little piece of code grabbing infos from help and this forum.
NOTE: Form1 is minimized.

This is my code:

Code: Select all

  TRichView *RV=NULL;
  TRVStyle *RVS=NULL;
  RV=new TRichView((void *)NULL);
  RVS=new TRVStyle(NULL);
  RV->Visible=false;
  RV->Parent=Form1;
  RV->Style=RVS;
  RV->RTFReadProperties->TextStyleMode=rvrsAddIfNeeded;
  RV->RTFReadProperties->ParaStyleMode=rvrsAddIfNeeded;
  for(int i=0;i<3;i++) {
    int ItemNo=RV->ItemCount;
    TMemoryStream *Str=new TMemoryStream;
    Str->LoadFromFile(IntToStr(i)+".rtf");
    RV->LoadRTFFromStream(Str);
    delete Str;
    if(ItemNo>0) {
      RV->PageBreaksBeforeItems[ItemNo]=true;
    }
  }
  RV->Format();
  RV->SaveRTF("output.rtf", false);
  delete RVS;
  delete RV;
This code seems don't work, but I don't know why, but I'm sure I make something wrong.

In this case on the Format method, an EStackOverflow appears.

So I tried also to change:

Code: Select all

RV=new TRichViewEdit((void *)NULL);
to

Code: Select all

RV=new TRichViewEdit((TComponent *)NULL);
and in this case on the Format method hangs.
(If Form1 is not minimized, it works).

How could I solve this issue?
Is possible to use TRichView in a sort of non-visual component to merge more than one RTF document in 1 RTF?
Thanks for any help.

Sal
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What version of TRichView and C++Builder do you use?
Salamander
Posts: 6
Joined: Tue Dec 01, 2009 3:18 am

Post by Salamander »

Hi,
Borland C++ Builder 6
Inside the ReadMe.txt of the trial package I downloaded (rvpkgcb6.zip), there's written: RichView Package 11.1.1.

Thanks
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Change the code for creating RV to
RV=new TRichView((TComponent*)NULL);
In my tests, it helped.
Salamander
Posts: 6
Joined: Tue Dec 01, 2009 3:18 am

Post by Salamander »

Well,
I already tried the TComponent casting for the NULL.
But it still hang if the main form is minimized to tray.

As you requested, this is the Flags value just after the new:
rvflUseJumps
rvflTrim
rvflRoot
rvflCanUseCustomPPI
rvflCanProcessGetText

in all the cases immediately after I created a new TRichView.

How can I avoid this problem?
Thanks for trying.

NOTE: In the first post I wrote that I changed: RV=new TRichViewEdit((void *)NULL); to RV=new TRichViewEdit((TComponent *)NULL); but I would say TRichView.
Anyway, I tried also with TRichViewEdit.
Salamander
Posts: 6
Joined: Tue Dec 01, 2009 3:18 am

Post by Salamander »

I'm sorry to write again, but:
I'm running the small code I wrote in the first post inside a separate Thread.
Could be that the problem?
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

What if you assign a hidden (not the main form) as a parent?

Another option: you can create TRVReportHelper instead, and use it RVReportHelper->RichView instead of RV. In this case, you do not need a parent form at all.
But instead of RV->Format() you need to call RVReportHelper->Init() providing some Canvas.
Salamander
Posts: 6
Joined: Tue Dec 01, 2009 3:18 am

Post by Salamander »

Could you privide little code to do that using TRVPrintHelper, please?
Mayge just changing the first snip of code I wrote.

I tried also assigning as parent an hidden form (not the main form) and it still hang on RV->Format().

I tried also to remove the Format method and SaveRTF seem to works fine. But I don't think that is the right way to do that.

Thanks
Sergey Tkachenko
Site Admin
Posts: 17569
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I am afraid that the problem can be really in a thread. Try executing this code in the main process.

RTF saving requires formatting in RTF contains tables. Otherwise, Format() is not necessary.
Salamander
Posts: 6
Joined: Tue Dec 01, 2009 3:18 am

Post by Salamander »

Ok, many thanks.
I never had tables in these RTF so I choose to avoid Format method.
Now I continue to test with my needs.

After that I'll try also to do that in the main thread and I'll keep you informed.
Post Reply