CDK - function Close


function Close(AOwner: hwnd; ASaveSettings: Boolean):Boolean;

Declared in: svn\components\sharpcenter\uSharpCenterDllMethods.pas


Parameters

  • AOwner: hwnd: PChar (const)

This parameter contains the handle of the SharpCenter form

  • ASaveSettings: Boolean (const)

As the name suggests, this parameter contains whether there is anything to save, when the configuration is closed. You should only save a configuration, if the ASaveSettings is true

  • Result: Boolean

The Result parameter determines whether the Configuration can close, such as if there was an error while attempting to save the configuration. Returning True will allow SharpCenter to free the plugin.


Description

The close function is executed whenever the configuration is being closed. It is expected that within this section, the developer handles all save code, and this should be the sole place where any configuration data is saved. It is also advised that any objects created in the Open method, including forms and classes, are correctly freed, otherwise an Access Violation will occur.


Examples

Result := True;

// Validation
if Not(AClass.Validate) then Result := False

// Save
If Not(AClass.Save) then Result := False;

// If OK then free everything
IF Result then begin
  FreeAndNil(AForm);
  AForm.Close;

  FreeAndNil(AClass);
end;