SharpCenter Plugin Reference

Open: function(const APluginID:Pchar; owner: hwnd): hwnd;
This method should be used for plugin initialisation, such as creating the form, and then assigning this to the owner handle. The PluginID variable will be used to pass IDs between configurations, such as passing the ThemeID to the ThemeInfo configuration. You can then initialise the form based on this PluginID, by loading the xml associated with it.

// Create Form
if Not(Assigned(AForm)) then 
  AForm := TForm.Create(nil);

// Assign form to owner handle
AForm.ParentWindow := owner;
AForm.Left := 0;
AForm.Top := 0;
AForm.BorderStyle := bsNone;
AForm.Show;

// Create supporting classes, and load ui
AClass := TClass.Create;
AClass.PluginID := APluginID;
AClass.Load;

// Return the new form handle
Result:= AForm.Handle;

Close: function(AOwner: hwnd; ASaveSettings: Boolean): boolean;
This method should be used, for when the plugin is closed. Everything that was created in the initialisation must be destroyed, otherwise an AV will occur. If ASaveSettings is True, this means that SharpCenter has triggered the plugin to save, and all save processing must be handled. The Result is also important, as it defines whether SharpCenter frees the plugin, this if useful for form validation.

Result := True;

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

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

  FreeAndNil(AClass);
end;

OpenEdit: function(AOwner:Hwnd; AEditMode:TSCE_EDITMODE):Hwnd;
This method is used for inline editing. Inline editing is a feature that was added for consistency, and ease of use for other developers creating configurations. The idea is, this replaces any extra form needed for editing an item, the only thing the developer needs to define, is a handle to an edit window/panel. Everything else is handled via SharpCenter. The AEditMode constant, defines whether the item is being Added, Edited or Deleted. Again the AOwner must be passed to the Result.

// Create Form
if Not(Assigned(AEditForm)) then 
  AEditForm := TForm.Create(nil);

// Assign form to owner handle
AEditForm.ParentWindow := owner;
AEditForm.Left := 0;
AEditForm.Top := 0;
AEditForm.BorderStyle := bsNone;
AEditForm.Show;

// Initialise UI based on the edit mode
AClass.InitUI(AEditMode, AEditForm);

Result := AEditForm.Handle;

CloseEdit: function(AOwner: Hwnd; AEditMode:TSCE_EDITMODE; ASave:Boolean): boolean;
This method should be used when the inline edit is closed. Everything that was created in the initialisation must be destroyed, otherwise an AV will occur. If ASave is True, you must save to the class, depending on the edit mode which is defined. Its important to note that you should never save to a file, edits within inline edit, should be saved to a class. Validation should also occur at this stage.

Result := True;

// Validation
if Not(AClass.ValidateEdit) then Begin
  Result := False;
  AClass.InitValidateUi(AEditForm);
  Exit;
End;

// Define whether we add/edit or delete the item
if AClass.Save(AEditMode) then Begin
  FreeAndNil(AEditForm);
  AEditForm.Close;
end;

AddTabs: procedure(var ATabs:TPluginTabItemList);
This method defines configuration tabs. This was created to improve consistency, and provides the developer with a consistent tab design. All that is required by the developer is to add items to this list. If the method is not exported within the dll, there will be no tabs added to the configuration.