A simple class looks like this:
DEFINE CLASS ChmImport as Custom FUNCTION Activate(loHelpForm) *** Reference to the Help Builder Project object *** (Class wwHelp) loHelp = loHelpForm.oHelp *** Currently active topic loTopic = loHelp.oTopic MESSAGEBOX("Hello from the FoxPro Addin" + CHR(13) + CHR(13) +; "Form Caption: " + loHelpForm.Caption + CHR(13) +; "Project: " + loHelp.cProjectName + CHR(13) +; "File: " + loHelp.cFileName + CHR(13) +; "Active Topic: " + loTopic.Topic) IF !ISNULL(loTopic ) *** Update the active topic loTopic.Body = TIME() + CHR(13) + loTopic.Body loHelp.SaveTopic() loHelpForm.Refresh() ENDIF RETURN .T. ENDFUNC ENDDEFINE
To specify a PRG file in the Add-in manager:
Functionally there's not much difference between the PRG interface - the main difference is that the mainline of your APP/EXE file must load all related classes and and procedures.
*** Must load any classes that your add in might need! *** Make sure to include the PRG/VCX that contains your addin class!!!! SET PROCEDURE TO AddinTest ADDITIVE *** Load any other libraries you might need SET PROCEDURE TO wwLocaleInfo Additive *** NOTE: These classes will load into Help Builder *** so if you're using common West Wind classes *** like wwAPI,wwUtils, wwConfig, wwIPStuff *** they will already be loaded *** TIP: You can also use an add-in as a class loader *** for your templates! Any class or UDF() that *** is loaded will also be visible in the topic *** templates at render time! DEFINE CLASS AddInTest as Custom FUNCTION Activate(loHelpForm) MESSAGEBOX("hello from an EXE" + CHR(13) + ; loHelpForm.Caption) *** Create a class contained in your EXE oCustom = CREATEOBJECT("wwLocaleInfo") *** Call a form contained in your EXE DO FORM AddinTest ENDFUNC ENDDEFINE
To install your EXE/APP add-in the add-in manager:
The following code demonstrates:
loHelp = loHelpForm.oHelp loTopic = loHelpForm.oHelp.oTopic lcTitle = loHelpForm.oHelp.oTopic.Title
Note that your addin can be called at any time, so there's no guarantee that a project is open or a topic active, so you should ensure to check for NULL on the Topic before using it and checking the project properties to get state information about the content you are currently accessing.
In addition any of Help Builders global functions are accessible.