RVActions in DLL

General TRichView support forum. Please post your questions here
Post Reply
Stefan Hempel

RVActions in DLL

Post by Stefan Hempel »

Hello

I'm working with TRichView 1.9 and RVActions on C++ Builder 5.
I have a litte Form with a RichViewEdit and RVActions, assigned to the Control. Wenn i use this Form directly, everthing works fine.

But if I put this Form in a DLL, and call it there is a Problem :
The Windows runs and the RichViewEdit-Control works, but all RVActions doesn't. My own Actions works.

I have debugged the Problem to this Line, from the Example Handling for RVFontComboBox:

Code: Select all

    ...
    rvActionFontEx->UserInterface = false;
    rvActionFontEx->ValidProperties = TRVFontInfoMainProperties() << rvfimFontName;
    rvActionFontEx->Font->Name = FontName;

   // If Forms is called directly, Call of Execute works.
   // But isa Form called from a DLL, Call of Execute returns false.
    if (rvActionFontEx->Execute() == false) 
    {
      ShowMessage("DEBUG:CAN'T ASSIGN FONT");
      }
    rvActionFontEx->UserInterface = true;
    ...
The Prolem occurs, even when all Propertys and Codes for RV-Components are equal.

Can you give me a Solution for that? I can send you a Minimum Example Project to demonstrate.

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

Post by Sergey Tkachenko »

In a normal application, states of all actions (not only RichViewActions) are updated periodically when the application is idle. The Application object constantly calls UpdateTarget methods of all actions.
DLL does not do it.
There is a solution. It's a bit ugly, but it works. You can simulate this behavior using timer.

I am translating this code from Delphi just in my browser, so mistakes are possible:

Code: Select all

void __fastcall TMyForm::Timer1Timer(TObject* Sender);
{
   for (int i=0; i<ComponentCount; i++)
     if (Components[i]->InheritsFrom(__classid(TrvAction)))
       ((TrvAction*)(Components[i]))->UpdateTarget(RichViewEdit1);
}

// Assign this code to OnExecute of all RichViewActions on this form:
void __fastcall TMyForm::rvActionExecute(TObject* Sender);
{
   ((TAction*)Sender)->ExecuteTarget(RichViewEdit1);
}
Stefan Hempel

Post by Stefan Hempel »

Hello

thank you very much. Now it works.
But my own Actions works without that Patch...
Sergey Tkachenko
Site Admin
Posts: 17522
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Not all actions update their states in UpdateTarget/OnUpdate.
Post Reply