Figure 1. Importing the PacketX type library
Figure 2. Importing the PacketX control
Figure 3. PacketX on the Components Palette
stdafx.h file: #import "PacketX.dll" no_namespace, named_guids
import statement will force compiler to generate wrapper classes for ActiveX objects found in type library. Now you should be able to compile the following piece of code: // Initialize COM CoInitialize(NULL); // Create PacketX IPktXPacketXPtr pPktX; pPktX.CreateInstance(__uuidof(PacketX));
New option from File menu and take the following steps:
Step 1. Choose MFC AppWizard (.exe)
Step 2. Choose application type (dialog)
Step 3. Enable support for ActiveX controls
Step 4. Insert ActiveX control
CPktXDlg from the class list. Select IDC_PACKETXCTRL1 from control id’s list and click Add Variable button. After you have completed these steps you should see new CPkXPacketXCtrl item in class view:
Step 5. Add C++ wrapper class
Step 6. Add event handlers
WScript.CreateObject function to create the PacketX instance. The CreateObject function accepts the class prog id as the first parameter and prefix to event handler function as second parameter: '// Create PackeX instance Set oPktX = WScript.CreateObject("PktX.PacketX","PacketX_") ... Public Sub PacketX_OnPacket(ByRef oPacket) '// Process packet ... End Sub
Figure 1. Importing the PacketX type library
Figure 2. PacketX on the Component Palette
Components button to view/verify the selected package contains the PacketX control. Click OK to dismiss the window displaying the controls associated with a selected package. Click the Remove button to remove the package and controls from the Borland IDE. <object id=pktx style="display:none" classid="clsid:0276C5E0-FDDD-470D-957C-5A3E2438D7F5" codebase="http://www.beesync.com/files/PacketX.dll" viewastext> </object> <script language="vbscript" for="pktx" event="onpacket(byref opacket)"> <!-- 'Add your code here ... --></script> <script language="vbscript" for="pktx" event="onstatistics(byref ostats)"> <!-- 'Add your code here ... --></script>