Kadmos.com

  Home | Products | Download | Purchase | Support | Language

Google
Search site:

Products
DXFReader ActiveX Control
 • DXF Files Overview
 • Distribution
 • Installation
 • Quick Start
 • Control Summary
 • Download
 • Buy now!
 • DXFReader Reference
 • DXFPlot Reference

IXF ActiveX Control

Postel ActiveX Control

Tech Support
OnLine Support
Phone Support
Sample Code
Registered Users
FAQ
References
Kadmos
Contact Kadmos
Environment
Customer List
Newsletter
Download
ActiveX Controls
Updates
Purchase
Price List
International Resellers
Our Guarantee
Shipment Options
Payment Options
Shopping Cart
    Installation DXFReader ActiveX Control - Installation

Installation

To install DXFReader run DXFReaderSetup.exe on the CD-ROM or on the folder where you've downloaded and expanded the file DXFREADER.ZIP.

The following files will be installed into your Windows\System32 directory only if their version number is higher:

DXFReader.ocx This file contains the 32-bit OCX version of ActiveX control.
DXFReader.chm
Contains control's Html Help.

The following files will be installed into the program directory specified during installation:

DXFReaderManual.pdf Contains control's user manual.
Sample A directory containing the control's samples source code (VB, VC++, Delphi and Visual Studio.NET/2005/2008) and executables.

Note: To remove DXFReader from your system use Add/Remove Programs from the Windows Control Panel or select Uninstall DXFReader ActiveX Control in the start menu folder.

Installing DXFReader in Visual Studio .NET/2005/2008

Unlike the Toolbox in Visual Basic 6.0, which retains customizations for a single project, the Visual Studio .NET Toolbox retains customizations for the entire development environment. When you load the DXFReader ActiveX Control in the Toolbox, as described below, it is available in any Windows Form designer, regardless of the language.

  1. Open a Windows Form in a Visual Basic .NET or Visual C# .NET project.
  2. Right click anywhere in the Toolbox and select Customize Toolbox. If the Toolbox is not visible, first select View»Toolbox.
  3. From the COM Components list, select the ActiveX controls that you want in the project. You will find DXFReader ActiveX Control, starting with DXFREADERlib, in the list. Unlike Visual Basic 6.0, Visual Studio .NET lists each COM component rather than OCX. So you need to select DXFREADERlib.Plot and DXFREADERlib.DXFReader (see picture below).



  4. Click OK. Visual Studio .NET loads the selected controls on the currently selected tab of the Toolbox.

Browsing Properties

Place DXFReader ActiveX Control on the Windows Form and explore its properties (View»Properties Window). You might notice that several properties have been added or changed, including the default name of the control. Visual Studio .NET prefixes all ActiveX controls with Ax (in Visual Basic .NET) or ax (in Visual C# .NET). For example, when you drop the first instance of a DXFReader on a Visual Basic 6.0 form, Visual Basic 6.0 names that control DXFReader1. When you drop the first instance of a DXFReader ActiveX Control in Visual Studio .NET, Visual Basic .NET names the control AxDXFReader1.

Browsing Generated Code

Open the code editor, and examine the code that Visual Studio .NET automatically generated. In both Visual Basic .NET and Visual C# .NET, the code generated contains a call to InitializeComponent() to initialize properties on the Windows Form and controls, a call to Dispose() for resource cleanup, and declaration of and reference to the instance of the graph you placed on the form.

Changes to the Visual Basic Language

Microsoft made many changes to its Visual Basic language to add object-oriented features and make it more like other .NET languages. This section describes programming changes you will encounter, specifically with respect to default properties and the Item method, as you develop applications with DXFReader ActiveX Control in Visual Basic .NET or Visual C# .NET.

Default Properties

Unlike Visual Basic 6.0, Visual Basic .NET does not support default properties, which are the most commonly used properties of the control. For example, you might use the following Visual Basic 6.0 syntax to set the value of DXFReader file name:

DXFReader1 = "MyFile.dxf"


In Visual Studio .NET, you must modify the code to explicitly name the property. In this example, explicitly name the Value property:

'Visual Basic .NET
AxDXFReader1.FileName = "MyFile.dxf"


'Visual C# .NET
axDXFReader1.FileName = "MyFile.dxf";


Item Method

You can retrieve an item from a collection in Visual Basic 6.0 without explicitly stating the Item method, as demonstrated in the following example:

'Visual Basic 6.0: Retrieving an Item in a Collection
DXFReader1.Entities(1).EntityType = "LINE"

In Visual Studio .NET, you must explicitly use the Item method when you retrieve items from a collection, as shown in the following examples:

'Visual Basic .NET: Retrieving an Item in a Collection
AxDXFReader1.Entities.Item(1).EntityType = "LINE"

'Visual C# .NET: Retrieving an Item in a Collection

object ind;
ind = 1;
DXFReaderLayer Layer;
Layer = (DXFReaderLayer)axDXFReader1.Layers.Item(ref ind);
MessageBox.Show("Layer # 1 name: " + Layer.LayerName, "", MessageBoxButtons.OK, MessageBoxIcon.Information);

Collection objects implement the IEnumerable interface, so you can iterate through items in a collection using For Each just as you can in Visual Basic 6.0. The following examples show how to iterate through a collection of Entities objects on DXFReader:

'Visual Basic .NET: Iterating through a Collection

Dim Entity As DXFReaderEntity

For Each Entity In .Entities
   MsgBox(Entity.EntityType)
Next Entity

'Visual C# .NET: Iterating through a Collection

foreach (DXFReaderEntity Entity in axDXFReader1.Entities)
   MessageBox.Show(Entity.EntityType, "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);

Event Handling

Microsoft implemented a new event model in Visual Studio .NET. In this event model, an object generates an event in response to some action or change in state, such as a mouse click or x number of points being acquired. The object that generates the event is called the event sender. Another object, called the event receiver, handles the event and responds by executing an event handler, which processes the event. However, the event sender needs a pointer to the event receiver. The .NET Framework refers to this pointer as a delegate. A delegate is a class that holds a reference to a method.

Installing DXFReader in Visual Basic

To install and use DXFReader in Visual Basic there are slight differences between these processes in Visual Basic 5 and Visual Basic 6, but they are largely superficial.

The figures that follow show dialogs and screens used to install DXFReader in Visual Basic 5/6.

In Visual Basic 5/6, select the Components command from the Project menu. It will present the dialog shown in figure below.
Check the box next to the control you want to use and click the OK button. In the figure below the control "Kadmos DXF Reader" has been selected.



If the control does not appear in the list, click the Browse button and locate the DXFReader control's .OCX file. Select the file and click OK.

At this point Visual Basic will add entries to your system registry so the control will be listed in the future.

After you have selected the control, it will appear in the toolbox along with Visual Basic's controls as showed in the figure below.



Installing DXFReader in Visual C++

Despite its name, MS Visual C++ is not as visually oriented as Visual Basic. A Visual C++ program manages controls by building a class that represents the control. Class methods provide access to the control's properties, events and methods. The all process can be divided into five steps:

1 - Registering DXFReader in the system registry

Before Visual C++ can use a custom control, it must be registered in the system registry. If you installed DXFReader using the setup utility, the installation program provides to register it in the right way. DXFReader can also be registered with the RegSvr32.exe application provided with Visual C++. For example, the following code registers DXFReader located in the C:\WINDOWS\SYSTEM directory:

regsvr32 c:\windows\system\dxfreader.ocx

It is possible to use RegSvr32.exe to remove DXFReader's entries from the system registry with the /u flag, for example:

regsvr32 /u c:\windows\system\dxfreader.ocx

2 - Providing support for ActiveX

To create a MS Visual C++ project that support ActiveX controls, select the New command from the File menu. On the resulting dialog's Projects tab, select the MFC AppWizard (exe) option. Fill in the project name and location and click the OK Button.
Follow the AppWizard's instructions and select, for example, a dialog-based application. The AppWizard's second step will show a checkbox that determines whether the application will support ActiveX controls. Make sure the box is checked and continue through the AppWizard.

3 - Creating the Control

To insert an instance of DXFReader in the project, select the Resource View tab. Locate the resource that should contain the control and double-click on it to open it. Press the right mouse button over the resource to make the context menu shown in the following figure appear.

Select the Insert ActiveX Control command, and the dialog shown in the following figure will appear.

If DXFReader has been correctly registered by its installation program, or manually with the RegSvr32 application, it should appear in the dialog's list of controls with the name DXFREADERlib.DXFReader. Pick it and click on the OK button. At this point MS Visual C++ will add DXFReader to the project. If you want to add an instance of the DXFPlot control, simply pick DXFREADERlib.DXFPlot.

4 - Creating Event Handlers

Once DXFReader is added to the project you can provide support for control's events. Press the right mouse button over the control and select the Events... command from the context menu. The following figure will appear.

Select an event, for example MouseDown and click the Add Handler button. Enter the name you want to give the event handler function in the resulting input box. For example the control's MouseDown event will be handled by a member function named OnMouseDownDxfreader1.
After you have created the event handler function, you can use the Class View to locate and examine the function. Alternatively, you can select the event handler in the Events dialog and click the Edit Existing button.
The following code shows the function created to handle the DXFReader's MouseDown event. The call to ZoomSpotIn method was added manually.

void CDXFReaderTestDlg::OnMouseDownDxfreader1(short FAR* Button, short FAR* Shift, float FAR* x, float FAR* y)
{

   m_DXFReader.ZoomSpotIn (*x,*y);


}

5 - Supporting Control Properties

The simplest way to access DXFReader's properties in code is to package the control in a wrapper class. This class will provide member functions that manipulate the control itself.
Start by pressing the right mouse button over the control and selecting the ClassWizard command from the context menu. On the resulting dialog, pick the Member Variables tab. Select on the control's ID (IDC_DXFREADER1) and click the Add Variable button.
At this point MS Visual C++ will notify you that it has not yet build a wrapper class for the control as shown in the figure below.

Click the OK button to acknowledge the message, and ClassWizard will create the wrapper class.
ClassWizard will then present a dialog allowing you to select the classes you want created. DXFReader has the Font, Picture and Collection properties. Because they are objects, ClassWizard includes an option for creating a wrapper class for them as well for the main control.

For each of the classes you want created, select the class and enter a name, header file, and implementation file for that class. When you are finished, click the Ok button and ClassWizard will create the appropriate classes.

At this point ClassWizard is finally ready to create a variable representing the custom control. Enter the variable name in the dialog shown in the figure below and click the OK button.

ClassWizard will add a new variable to the project to hold the class instance representing DXFReader. The program can use this variable to manipulate the object and thus the control it represents.
The DXFReader's wrapper class will include public functions corresponding to the properties and methods exposed by the control. For each property, ClassWizard creates two functions: the name of the one starts with "Get" and the name of the other starts with "Set".

The following code will set the PlotRotation property of DXFReader to 1 (dr90) and then plot the drawing 90° rotated:

void CDXFReaderTestDlg::OnOk2()

{
   m_DXFReader.SetPlotRotation (1);
   m_DXFReader.Plot();
}

To use the collections of Entities, Layers, etc you have to include the respective objects' header files, auto generated by ClassWizard, in the main dxfreader.cpp file.
For example, if you need to reference the Entities collection, add the following statements:

#include "stdafx.h"
#include "dxfreader.h"

// Dispatch interfaces referenced by this interface

#include "_Collection.h" To be added manually
#include "DXFReaderEntity.h" To be added manually
#include "Picture.h"
#include "Font.h"

Installing DXFReader in Delphi

To use DXFReader in Delphi, select the Import ActiveX Control... from the Component menu. On the resulting dialog select Kadmos DXF Reader and click the Install... button.


The dialog shown in the following figure will appear:


You can select to insert the control into the existing package to into a new package and then click the OK button.
Delphi will generate a file ...\DelphiDir\Imports\DXFREADERlib_TLB.pas, which contains a wrapper class for DXFReader.ocx as well as the interface definitions. At this point DXFReader can be dragged and dropped to a form from the ActiveX tab but, with the auto generated TLB file, the method calls will not work. To workaround the problem use the ID binding instead of VBTable binding in the TLB file using the correct DXFREADERlib_TLB.pas file.

Registering DXFReader

Registering DXFReader is a very simple task. After purchasing the registration code invoke the about method clicking on the ellipses near the word "About" in the properties window (see figure below).

Next click on the Register... button in the About Box. It will show a dialog window for typing in the registration code.

Alternatively, you can click the Register... button on the control's properties window that appears pressing the right mouse button over the control and selecting the Properties command from the context menu.

All licensed customers receive unlimited technical support, free upgrades within the major version, discounts on upgrades and are entitled to download free code samples and programs from our Registered Users Area.

Copyright © 2008 Kadmos.com - All rights reserved. Privacy Policy