[How to] How to use actions in DLL or ActiveX
Posted: Thu Nov 18, 2010 3:59 pm
Warning: using TRichView/ScaleRichView in DLL or ActiveX requires a special permission from us, see the license:
- in trial: ReadMe.chm | License
- in full version: Install.chm | License
In a normal application, a state of all actions (Enabled, Checked) is updated periodically when this application is idle.
In DLL or ActiveX, it does not happen.
The solution is creating a timer and calling UpdateTarget in OnTimer.
1) Example for TRichViewEdit.
This example assumes that all actions work with RichViewEdit1, and all of them are placed on rvActionsResource datamodule.
Place Timer1: TTimer on the form.
Assign Timer1.Interval = 300.
Timer1.OnTimer:
Create a new form's procedure:
In FormCreate, assign this procedure to OnExecute of all actions:
- in trial: ReadMe.chm | License
- in full version: Install.chm | License
In a normal application, a state of all actions (Enabled, Checked) is updated periodically when this application is idle.
In DLL or ActiveX, it does not happen.
The solution is creating a timer and calling UpdateTarget in OnTimer.
1) Example for TRichViewEdit.
This example assumes that all actions work with RichViewEdit1, and all of them are placed on rvActionsResource datamodule.
Place Timer1: TTimer on the form.
Assign Timer1.Interval = 300.
Timer1.OnTimer:
Code: Select all
procedure TForm3.Timer1Timer(Sender: TObject);
var i: Integer;
begin
for i := 0 to rvActionsResource.ComponentCount-1 do
if rvActionsResource.Components[i] is TAction then
TAction(rvActionsResource.Components[i]).UpdateTarget(RichViewEdit1);
end;
Code: Select all
procedure TForm3.DoActionsExecute(Sender: TObject);
begin
TAction(Sender).ExecuteTarget(RichViewEdit1);
end;
Code: Select all
for i := 0 to rvActionsResource.ComponentCount-1 do
if rvActionsResource.Components[i] is TAction then
TAction(rvActionsResource.Components[i]).OnExecute := DoActionsExecute;