Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 30

Previous Page 29   Index   Next Page 31

Language Bindings
Page 30 of 750
Microsoft Visual Basic 6.0
The usage of DynaPDF with Visual Basic is essentially the same as with C or C++ except that the
exported DLL functions are encapsulated in the wrapper class CPDF to make the usage easier.
The instance pointer IPDF which is used by every DynaPDF function is hidden for the user in
Visual Basic. The instance pointer is controlled by the wrapper class so that you don't need to
create PDF instances manually.
To use DynaPDF with Visual Basic proceed as follows:
Add the file /include/Visual_Basic/DynapPDFInt.bas to your project (menu Project/Add
Module/Existing…).
Add the file /include/Visual_Basic/CPDF.cls to your project (menu Project/Add Class
Module/Existing…).
Add the file /include/Visual_Basic/IPDFCallback.cls to your project (menu Project/Add
Class Module/Existing…).
If you want to use the table class then add also the file
/include/Visual_Basic/CPDFTable.cls to your project (menu Project/Add Class
Module/Existing…).
Finally, make sure that the dynapdf.dll can be found by Visual Basic in debug mode; just
copy the DLL into Windows/System32 or into Windows/SysWow64 on a 64 bit system,
finished!
Note that Visual Basic supports the 32 bit dynapdf.dll only. If you work on a 64 bit OS then
copy the library into Windows/SysWow64. Yes, this is the right folder for 32 bit DLLs!
All DynaPDF functions are encapsulated in the wrapper class CPDF. This class makes sure that
the library can be used without limitations and programming is more comfortable since you can
work with a native VB class. You don't need to consider specific return values of the DLL, the
class converts special data types automatically to VB data types.
Exception handling in Visual Basic
The standard exception handling of DynaPDF uses a callback function to pass error messages
and warnings to the client application. However, in Visual Basic we use events instead. The
usage of events is quite easy and frees you from dealing with DynaPDF API function calls.
To enable the event support of the wrapper class CPDF declare a local instance variable as
follows:
Option Explicit
Private WithEvents FPDF As CPDF 'Enable event support
The instance variable FPDF is now listed in the left combo box of the VB code editor.
 

Previous topic: Microsoft Visual C++

Next topic: The DoEvents problem