Usage of TrvActionsResource in the current TRichView version

General TRichView support forum. Please post your questions here
Post Reply
Alexander_Dober
Posts: 122
Joined: Fri Mar 04, 2011 3:44 am

Usage of TrvActionsResource in the current TRichView version

Post by Alexander_Dober » Mon Sep 23, 2019 2:40 pm

So far I've been adding the unit "dmActionsAlpha" to the uses clause in some units of my project and then using "MyrvActionsResource: TrvActionsResource" to access the image lists or actions from this DataMadoule like "MyToolBar.Images := MyrvActionsResource.ilNormal" or "MyRVActionUndo := MyrvActionsResource.rvActionUndo1" etc. in my own DataModule for TRichView related stuff. The toolbar consists some additional buttons / controls beyond the RVActions and is being created at runtime, which was the main reason for this approach, I believe, and as far as I remember, I did it based on the advice from this forum.

In the current TRichView version the unit "dmActionsAlpha" seems not to exist anymore. "TrvActionsResource" is declared in "dmActions", while there are no "ilNormal" and "ilDisabled" image lists there. Those do exist in "dmActionsImages1.pas" or "dmActionsImages2.pas".

Has the whole approach for such a use case changed? I couldn't find anything in the documentation etc.

Should I just add dmActions and dmActionsImages1 to uses clause and then change my code to
rvActionsImages1 := TrvActionsImages1.Create(nil);
MyToolBar.Images := rvActionsImages1.ilNormal;
MyToolBar.DisabledImages := rvActionsImages1.ilDisabled;

while keeping

MyrvActionsResource := TrvActionsResource.Create(nil);
MyRVActionUndo := MyrvActionsResource.rvActionUndo1;

etc. or am I missing something basic?

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

Re: Usage of TrvActionsResource in the current TRichView version

Post by Sergey Tkachenko » Mon Sep 23, 2019 6:01 pm

RichViewActions have two alternative datamodules with images: dmActionsImages1.pas and dmActionsImages2.pas.
They contain only TImageList controls, without actions.
These units may be used as they are, you can include them in your project.

As for the actions, I suggest to create actions themselves on the form that uses them, instead of a datamodule.

This approach is used in all our demo projects for new versions of Delphi.

It has advantages:
- you can assign events and properties of actions on a form without changing the standard unit;
- you can create multiple forms with actions that work only on these forms (you need to use actions' Control or ControlPanel property to link the action to the specific editor)
- you can add your own additional actions working with controls on this form.

You can open RichViewActions\Demos\DelphiUnicode\ActionTest project, copy TActionList (and may be other components) and then paste on a form in your project.

As for dmActions.pas, do not use it. It is used only at design-time to define default values (such as Captions) for actions. It is also used in projects for older versions of Delphi (that do not support semitransparent images), but only to re-use existing unit.
Indexes of images in dmActions are different than in dmActionsImages1 and dmActionsImages2, so if you assign an image list from dmActionsImages1 to ActionList from dmActions, images of actions will be wrong.

PS: in the next update, there will be additional datamodules containing virtual image lists and image collections (for RAD Studio 10.3). Indexes in virtual image lists will be the same as in the existing image lists, so transition to them will be simple.

Alexander_Dober
Posts: 122
Joined: Fri Mar 04, 2011 3:44 am

Re: Usage of TrvActionsResource in the current TRichView version

Post by Alexander_Dober » Wed Sep 25, 2019 3:02 pm

Thank you for the detailed explanation!

Do you know when this new update will be available?
Is it worth waiting for it, before addressing the described "issue"?

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

Re: Usage of TrvActionsResource in the current TRichView version

Post by Sergey Tkachenko » Wed Sep 25, 2019 4:32 pm

I'll try to release it tomorrow or in Friday.
Which issue do you mean?

Alexander_Dober
Posts: 122
Joined: Fri Mar 04, 2011 3:44 am

Re: Usage of TrvActionsResource in the current TRichView version

Post by Alexander_Dober » Thu Sep 26, 2019 10:57 am

No real issue, sorry. I just meant adjusting my project to the new version.

Post Reply