Adding the Execute Method

From RAD Studio
Jump to: navigation, search

Go Up to Creating the Component Interface


The final part of the component interface is a way to open the dialog box and return a result when it closes. As with the common dialog box components, you use a boolean function called Execute that returns True if the user clicks OK, or False if the user cancels the dialog box.

The declaration for the Execute method always looks like this:

Delphi:

type
  TMyWrapper = class(TComponent)
  public
    function Execute: Boolean;
  end;

C++:

class PACKAGE TMyWrapper : public TComponent
{
public:
  bool __fastcall Execute();
};

The minimum implementation for Execute needs to construct the dialog box form, show it as a modal dialog box, and return either True or False, depending on the return value from ShowModal.