Create "OnUpdate"

<< Click to Display Table of Contents >>

Navigation:  Create a PDF Editor > Delphi Example >

Create "OnUpdate"

This event is used to check the state down/disabled of each action.

 

procedure TForm2.WPViewPDFWizard1ActionUpdate(Sender: TObject);

var action : TAction;

    ac : Integer;

    state : Integer;

begin

      if Sender is TAction then

      begin

         action := TAction(Sender);

         ac := action.Tag;

         if ac>1 then

         begin

           // Either the PDF is loaded or we have a global operation

           if PageControl1.ActivePage=nil then

           begin

              action.Enabled := (WPViewPDF1.Command(

 COMPDF_ACTION_READFLAGS, ac ) and 16)=16 ;

              action.Checked := false;

           end

           else

           begin

              state := pdf.CommandEx(COMPDF_ACTION_READSTATE, ac);

              // 1=Checked, 2=Disabled

              action.Enabled := (state and 2)=0 ;

              action.Checked := (state and 1)=1 ;

           end;

         end;

      end;

end;