Page 1 of 1

RVActions in DLL

Posted: Tue Sep 20, 2005 3:40 pm
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

Posted: Wed Sep 21, 2005 6:45 pm
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);
}

Posted: Thu Sep 22, 2005 11:36 am
by Stefan Hempel
Hello

thank you very much. Now it works.
But my own Actions works without that Patch...

Posted: Mon Oct 10, 2005 6:20 pm
by Sergey Tkachenko
Not all actions update their states in UpdateTarget/OnUpdate.