Methods
All most all the functions that are exported by ter32.dll are also exposed by the ActiveX control. Please refer to the 'Application Interface Functions' chapter for the list of DLL functions and ActiveX methods. There are a few DLL functions which are not exposed as ActiveX methods. We have noted them in the comment section in function description.
In the programming environments (such as VisualBasic and Delphi) where you can use DLL functions as easily as the ActiveX methods, we would recommend that you use the DLL functions. The DLL functions are slightly faster than ActiveX methods and they can accept complex data types. However, you can use ActiveX methods if for some reason if you prefer ActiveX methods over DLL functions. You can also use a mix of methods and functions.
In the VisualBasic environment, the DLL functions are declared in ter.bas file. Once you include ter.bas file in your project you can call any API as simple function calls. Most API need the control window handle as the first argument. This would be TOC1.hWnd for a control named TOC1.
An example of calling an API function:
Call SetTerCharStyle(TOC1.hWnd, BOLD, TRUE, TRUE)
String output from an API function: Certain API such as GetFontInfo return a string output. A string variable in VB must must be assigned spaces before passing an output string variable to an API function:
Dim typeface as string
Dim pointsize as long
Dim style as long
Typeface = space$(50) ' allocate space before calling the API
Call GetFontInfo(TOC1.hWnd, typeface, pointsize, style)
An example of calling an ActiveX method:
The method name in the toc30.ocx will be the same as the API function names. The parameter and return values are also the same, with one exception. The methods do not need to be passed the first parameter (window handle). This is because the control already knows the window handle.
Dim typeface as string
Dim pointsize as long
Dim style as long
Call TOC1.GetFontInfo(typeface, pointsize, style)
Please note that in the TOC1.GetFontInfo method, we are omitting the window handle (the first parameter). All other parameters are the same.