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?
Usage of TrvActionsResource in the current TRichView version
-
- Posts: 130
- Joined: Fri Mar 04, 2011 3:44 am
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Usage of TrvActionsResource in the current TRichView version
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.
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.
-
- Posts: 130
- Joined: Fri Mar 04, 2011 3:44 am
Re: Usage of TrvActionsResource in the current TRichView version
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"?
Do you know when this new update will be available?
Is it worth waiting for it, before addressing the described "issue"?
-
- Site Admin
- Posts: 17520
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: Usage of TrvActionsResource in the current TRichView version
I'll try to release it tomorrow or in Friday.
Which issue do you mean?
Which issue do you mean?
-
- Posts: 130
- Joined: Fri Mar 04, 2011 3:44 am
Re: Usage of TrvActionsResource in the current TRichView version
No real issue, sorry. I just meant adjusting my project to the new version.