Difference between revisions of "Ide/Creating new Project Items"

From wiki.visual-prolog.com

(New page: {{ideNavbar|Creating new Project Items}} === Creating a Project === '''How to Create a New Project?''' To create a new project you should activate the '''Project | New''' menu command. ...)
 
Line 23: Line 23:
To create a new package in a project you should select the IDE menu command '''File | New'''. In the left pane of the appeared '''Create Project Item''' dialog you should select '''Package'''. Then the dialog accepts the following shape:
To create a new package in a project you should select the IDE menu command '''File | New'''. In the left pane of the appeared '''Create Project Item''' dialog you should select '''Package'''. Then the dialog accepts the following shape:


[[Image:..\Images\How_NewPackage.png|center|frame|The '''New Package''' Dialog]]
[[Image:Ide_How_NewPackage.png|center|frame|The '''New Package''' Dialog]]


'''Name:'''
'''Name:'''
Line 94: Line 94:
To create a COM package providing the interface (wrapper) to some COM component, you should activate the '''File | New''' IDE command. Then in the left pane of the opened '''Create Project Item''' dialog you should select '''COM Package'''. Then the dialog accepts the following shape:
To create a COM package providing the interface (wrapper) to some COM component, you should activate the '''File | New''' IDE command. Then in the left pane of the opened '''Create Project Item''' dialog you should select '''COM Package'''. Then the dialog accepts the following shape:


[[Image:How_COMPackage.png|center|frame|Creating '''New COM Package''' Dialog]]
[[Image:Ide_How_COMPackage.png|center|frame|Creating '''New COM Package''' Dialog]]


After you fill in all required COM package settings, you can press the '''Create''' button. Then the IDE creates the package subdirectory, the package header file '''XML.ph''' for the above picture), and the package implementation file ('''XML.pack''' for the above picture). They appear in the project tree in the Project Window after the created package is compiled.
After you fill in all required COM package settings, you can press the '''Create''' button. Then the IDE creates the package subdirectory, the package header file '''XML.ph''' for the above picture), and the package implementation file ('''XML.pack''' for the above picture). They appear in the project tree in the Project Window after the created package is compiled.
Line 152: Line 152:
*:Words are separated by dots as in <span style="color:Purple">Word.Document.6</span>. (Blank spaces cannot be used.)
*:Words are separated by dots as in <span style="color:Purple">Word.Document.6</span>. (Blank spaces cannot be used.)
*:Then you '''MUST''' press the '''Load''' button to enforce the IDE to load COM information from the COM module registered with this '''PROGID'''.
*:Then you '''MUST''' press the '''Load''' button to enforce the IDE to load COM information from the COM module registered with this '''PROGID'''.
*:'''PROGID'''s are versioned programmatic identifiers. '''PROGID'''s present human-readable versions of class identifiers ([#CLSID CLSID]) used to identify COM components. '''PROGID''' is a registry entry that can be associated with [#CLSID CLSID]. Like [#CLSID CLSID], '''PROGID''' identifies a COM component but with less precision because it is not guaranteed to be globally unique. The ''<vp>Version</vp>'' portion is optional but strongly recommended. Using <span class="code-span">''Version''</span>, even if there is only one version of the <span>'''PROGID'''</span>, helps to avoid conflicts. It enables different versions of a component coexist without overwriting <span>'''PROGID'''</span>s. If you do not specify a version for a <span>'''PROGID'''</span>, the default <span class="code-span">''Version = 1''</span>.
*:'''PROGID'''s are versioned programmatic identifiers. '''PROGID'''s present human-readable versions of class identifiers ([#CLSID CLSID]) used to identify COM components. '''PROGID''' is a registry entry that can be associated with [#CLSID CLSID]. Like [#CLSID CLSID], '''PROGID''' identifies a COM component but with less precision because it is not guaranteed to be globally unique. The ''<vp>Version</vp>'' portion is optional but strongly recommended. Using ''<vp>Version</vp>'', even if there is only one version of the '''PROGID''', helps to avoid conflicts. It enables different versions of a component coexist without overwriting '''PROGID'''s. If you do not specify a version for a '''PROGID''', the default ''<vp>Version</vp>'' <vp>= 1</vp>.
*:How to find '''PROGID''' entries in the registry is described in the [#CLSID CLSID].


How to find <span>'''PROGID'''</span> entries in the registry is described in the [#CLSID CLSID].
*'''IID'''
 
*:When this option is checked ON, then in the edit control you should specify the '''IID''' of the COM component interface that you wish to import.
IID
*:'''IID''' is a universally unique identifier (UUID) that uniquely identifies a particular COM interface. '''IID''' should be specified as a string of hexadecimal numbers with the following format:
 
*:<vipbnf>{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}</vipbnf>
When this option is checked ON, then in the edit control you should specify the <span>'''IID'''</span> of the COM component interface that you wish to import.
*:Then you '''MUST''' press the '''Load''' button to enforce the IDE to load COM information from the COM module that embeds the interface with the specified '''IID'''.
 
*:Really you can specify an <span>'''IID'''</span> registered to any interface embedded into the same COM module that embeds the interface you wish to import. (Later you will be able to specify the required COM component (or interface) in the list box in the [#Import_Group_Box '''Import'''] group box.)
<span>'''IID'''</span> is a universally unique identifier (UUID) that uniquely identifies a particular COM interface. <span>'''IID'''</span> should be specified as a string of hexadecimal numbers with the following format:
*:In the system registry database you can find all registered '''IID'''s under:
 
*:'''<vipbnf>HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface</vipbnf>'''
 
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
 
Then you <span>'''MUST'''</span> press the <span>'''Load'''</span> button to enforce the IDE to load COM information from the COM module that embeds the interface with the specified <span>'''IID'''</span>.
 
Really you can specify an <span>'''IID'''</span> registered to any interface embedded into the same COM module that embeds the interface you wish to import. (Later you will be able to specify the required COM component (or interface) in the list box in the [#Import_Group_Box '''Import'''] group box.)
 
In the system registry database you can find all registered <span>'''I'''</span><span>'''ID'''</span>s under:
 
 
<span>'''HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface'''</span>


=== Import: <span style="font-weight: normal">Group Box</span> ===
=== Import: <span style="font-weight: normal">Group Box</span> ===

Revision as of 11:15, 21 February 2013

IDE

Creating a Project

How to Create a New Project?

To create a new project you should activate the Project | New menu command. Then in the opened Project Settings dialog you should type in or select the desired project settings and press the Create button. The new project with the default parameters correspondent to your settings will be created.

Creating a New Package

Overview

The basic units of code organization accepted in Visual Prolog v.7 are packages. We use packages in Visual Prolog to organize and structuring things. The use of packages ensures homogeneity in structuring principles among different projects. Packages define the standard for tool structuring, they ease sharing source code among projects.

By default, the IDE organizes projects into packages. When you create a new package in a project, the IDE creates:

  • The subdirectory into which the package files will be placed.
  • The package header file (i.e. NewPackage.ph that describes the public view of the package. The package header file should be inserted by #include directives in all other packages that use the package. The package header file contains the list of public interfaces, the list of public classes, and some #requires directives.
    Names declared in public interfaces and classes are seen outside the package in all places where the package header file is included. #requires directives are used to guaranty that all packages required to use the package are included into the project.
  • The package implementation file (i.e. NewPackage.pack) produces a Visual Prolog compilation unit which is added to a set of project modules.

How to Create a New Package?

To create a new package in a project you should select the IDE menu command File | New. In the left pane of the appeared Create Project Item dialog you should select Package. Then the dialog accepts the following shape:

The New Package Dialog

Name:

In the Name edit control you should type in the name of the package being created (NewPackage in the picture).

Parent Directory

In the Parent Directory field you should type in or select (using the Browse button) the parent directory for the package. The package will be placed into the subdirectory of this parent directory. By default, when you activate this dialog, Parent Directory displays the directory selected in the project tree. If this directory is one of project subdirectories, then its path is displayed relatively to the project root directory.

In this Parent Directory the IDE creates a new subdirectory with the name correspondent to the specified package name. The package will be placed into this subdirectory.

After you fill in all required settings for the package, you can press the Create button. Then the IDE creates the package subdirectory, the package header file NewPackage.ph, and the package implementation file NewPackage.pack. (They will appear in the project tree in the Project Window after the created package is compiled.)

Packages

The concept of packages is used for grouping together several linked interfaces and classes. Packages can play a role of some class library. Packages can be used in your program instead of direct placing all these interfaces and classes into your program.

The package is a collection of several grouped together interfaces and classes. The package provides some common name to all these interfaces and classes. Each declaration or implementation of each interface or class from a package is placed in a separate file. Each filename (of these files) coincides with the name of a class or an interface that is declared or implemented in this file. All package files are stored in the same separate package directory. (If a package contains sub-packages, then they are placed in subdirectories of the package directory.)

Except for files with declarations and implementations of interfaces and classes, each package contains two special files: the package header (.PH) and the package implementation (.PACK) files.

  • The package header file provides declarations of all names exported from the package. Therefore, the package header file should be inserted by the #include directive in each other package that uses some names exported from this package.
  • The package implementation file provides code implementing the package classes which can be compiled into an object file. The package implementation file should be included only once into a project that uses this package.

So using the concept of packages we can create sets of linked interfaces and classes grouped into packages. Once created package can be included (and used) in several programs without copying package sources into each project. The example of such set of packages is our [..\..\pfc\pfcOverview.htm Visual Prolog Foundation Classes] (PFC).

Package Header Files

The package header file provides external view of the package.

  • It provides #include directives for all files containing declarations of all interfaces (.i) and all classes (.cl files) exported from the package (public interfaces and classes).
  • It contains #include directives for package header (.ph files) files of all packages publicly used by the package. Since these package header files provide declarations of all public names declared in them; therefore, all public names declared in these packages are also publicly visible from the package.
  • It contains some #requires directives. #requires directives define packages whose implementations (compiled code) have to  be accessible in order to use the package.

So the package header file provides declarations of all names exported from the package. Not only of exported names declared in the package itself, but also of all names declared in other packages that are included in the package header file.

A package header file should be inserted by #include directives in all places where the public names exported from the package should be visible.

A package header file does not produce any compiled code, but it is used while compilation to declare names exported from the package.

Usually a package header file has the PackageName.ph name.

Package Implementation Files

The package implementation file provides code implementing classes declared in the package. Compilation of the package implementation file generates object file that provides real implementations of classes declared in the package.

  • It contains the #include directive for the package header file.
  • It provides #include directives for package header files of external packages privately used by the package implementation. These header files provide declarations of all external names used in the package implementation (.pro) files.
  • It provides #include directives for files containing interfaces (.i files) privately used by the package implementation. These interfaces are only used inside the package implementation and are not seen externally.
  • It provides #include directives for files containing declarations of classes (.cl files) privately used by the package implementation. These classes are only used inside the package implementation and are not seen externally.
  • It provides #include directives for all files with class implementations (.pro files) that provides Prolog code implementing all classes declared the package.

Usually a package implementation file has the PackageName.pack name.

Creating a COM Package

How to Import an Existing COM Component

Terminology Used in COM

The Component Object Model (COM) is a way for software components to communicate with each other. It is a binary standard that allows any two components to communicate regardless of what machine they are running on (as long as the machines are connected), what operating systems the machines are running (as long as they support COM), and what language the components are written in. COM provides location transparency: it does not matter whether components are in DLLs or in EXEs. COM components are binary units of code that include packaging and registration code and that create COM objects. Each COM component, in the COM programming model, is a programming structure encapsulating both data and functionality. It is defined and allocated as a single unit and the only public access to the COM data and functionality is through the programming interfaces.

Each COM is simply a program module: a DLL or an EXE file. It can contain one or more COM components. (In Microsoft MSDN terminology componentsare coclasses.) Each component knows about several interfaces. (In MSDN terminology - each component can support several interfaces.) Each component supports the default interface iUnknown. Using the iUnknown::queryInterface/2-> predicate from the iUnknown interface, one can retrieve references to all interfaces known to a component. Each interface can provide several predicates (methods).

The main aim of importing a COM component into your project is using predicates defined in this COM component. Therefore, the COM package generated for an imported COM component has to provide some wrapper (glue code) to methods implemented in the COM component. That is, the generated COM package must provide declarations of correspondent interfaces, predicates, and domains.

How to Create a New COM Package

To create a COM package providing the interface (wrapper) to some COM component, you should activate the File | New IDE command. Then in the left pane of the opened Create Project Item dialog you should select COM Package. Then the dialog accepts the following shape:

Creating New COM Package Dialog

After you fill in all required COM package settings, you can press the Create button. Then the IDE creates the package subdirectory, the package header file XML.ph for the above picture), and the package implementation file (XML.pack for the above picture). They appear in the project tree in the Project Window after the created package is compiled.

Options:

Name:

In the Name edit control you should type in the name (xml on the picture) of the COM package (wrapping package) being created.

Parent Directory

In the Parent Directory you should type in or select (using the Browse button) the parent directory for the package. The package will be placed into the subdirectory of this parent directory. If you specify a non-existing name, then this directory will be created. By default, Parent Directory displays the directory selected in the project tree when you activate this dialog. If this directory is one of the project subdirectories, then its path is displayed relatively to the project root directory. If Parent Directory is empty, than it is equal to the project root directory.

In the Parent Directory the IDE creates the new subdirectory with the name correspondent to the specified package name. (It is XML for the above picture.). The package will be placed into this subdirectory.

Source Group Box

Controls in this group box are used to specify a COM module (DLL or EXE) from which a component should be imported. It contains the following controls:

  • Type Library
    When this option is checked ON, then in the edit control you should specify a file that contains the type library describing the COM component.
    Press the Load button to activate the Load Type Library File dialog using which you can find and insert the name of the type library file into the edit control.
    Attention! Notice that you HAVE to press the Load button to enforce the IDE to load the COM information from the specified type library even if you directly type in the type library filename into the edit control.
    If a COM client (our program importing COM server components) needs using COM server predicates, then the client application must have information about predicates in COM server components. Predicates often return values and accept parameters. The COM client requires declarations of all these predicates (and domains) in order to use them. This information can be made known in several ways. The Microsoft recommended way is to create a type library. (Remember that type libraries do not provide Prolog declarations.) Type library information can be stored in files with the following filename extensions: .TLB (type library itself), .OLB (multiple type libraries or foreign object libraries), .DLL (COM DLLs can embed type library resources), .EXE (COM EXEs can embed type library resources), .OCX (ActiveX controls).
  • TypeLib ID
    When this option is checked ON, then in the edit control you should specify the TypeLib ID of the type library for the COM component that you wish to import. The TypeLib ID is a universally unique identifier (UUID) under which the type library is registered in the Windows system registry. (See [#CLSID CLSID] for more information.) The TypeLib ID should be specified as a string of hexadecimal numbers with the following format:
    {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    Then you MUST press the Load button to enforce the IDE to load COM information from the type library registered with this TypeLib ID.
    In the system registry database you can find all registered TypeLib IDs under:
    HKEY_CLASSES_ROOT\TypeLib = {TypeLib ID}
  • CLSID
    When this option is checked ON, then in the edit control you should specify the CLSID of the COM component that you wish to import. The CLSID should be specified as a string of hexadecimal numbers with the following format:
    {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    Then you MUST press the Load button to enforce the IDE to load COM information from the COM module that embeds the COM component with the specified CLSID.
    Note. Really a COM module can embed several COM components. If you wish to import one of these COM components, then you can specify a CLSID registered to any COM component in this COM module. (Later you will be able to specify the required COM component (or interface) in the list box in the [#Import_Group_Box Import] group box.)
    In MSDN terminology, CLSID is a class identifier. In the Visual Prolog PFC terminology (see the COM package description in the PFC) CLSID is a COM component identifier.
    CLSID is a universally unique identifier (UUID) that identifies the type of a COM component. Each COM component has its CLSID in the Windows system registry database so that it can be loaded and used by other applications. For example, a spreadsheet can create worksheet components, chart components, and macrosheet components. Each of these components has its own CLSID that uniquely identifies this component to the system. That is, if your COM module (COM server or COM container) allows linking to its embedded components, then you need to register the special CLSID for each COM component embedded into the COM module.
    The CLSID is stored in the Windows registry database under the following registry key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID = {CLSID}
    The CLSID is a 128-bit number (in the hexadecimal format) within a pair of curly braces. Typically, CLSIDs (and other UUID values) are represented as strings of hexadecimal numbers with the following format:
    {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    For example,
    {4208fb66-e22a-11d1-a7d7-00a0c982c00d}
    You can use the UUIDGEN.exe tool to create a new UUID.
    When you find a CLSID you can find the associated PROGID under the following registry sub-key:
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{CLSID}\ProgID = <programatic identifier>
    See the [#PROGID PROGID] options description below.
    Universally unique identifier (UUID)
    The universally unique identifier (UUID) is also known as the globally unique identifier (GUID). The UUID, or GUID, is a unique, 128-bit value used to identify objects. Objects can be OLE servers, interfaces, client objects, etc. Beginning from this moment objects will be identified with UUIDs.
  • PROGID
    When this option is checked ON. In the edit control you should specify the PROGID of the COM module from which you wish to import the COM component. The PROGID should be specified as a string of the following format:
    <Program>.<Component>.<Version>
    Words are separated by dots as in Word.Document.6. (Blank spaces cannot be used.)
    Then you MUST press the Load button to enforce the IDE to load COM information from the COM module registered with this PROGID.
    PROGIDs are versioned programmatic identifiers. PROGIDs present human-readable versions of class identifiers ([#CLSID CLSID]) used to identify COM components. PROGID is a registry entry that can be associated with [#CLSID CLSID]. Like [#CLSID CLSID], PROGID identifies a COM component but with less precision because it is not guaranteed to be globally unique. The Version portion is optional but strongly recommended. Using Version, even if there is only one version of the PROGID, helps to avoid conflicts. It enables different versions of a component coexist without overwriting PROGIDs. If you do not specify a version for a PROGID, the default Version = 1.
    How to find PROGID entries in the registry is described in the [#CLSID CLSID].
  • IID
    When this option is checked ON, then in the edit control you should specify the IID of the COM component interface that you wish to import.
    IID is a universally unique identifier (UUID) that uniquely identifies a particular COM interface. IID should be specified as a string of hexadecimal numbers with the following format:
    {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
    Then you MUST press the Load button to enforce the IDE to load COM information from the COM module that embeds the interface with the specified IID.
    Really you can specify an IID registered to any interface embedded into the same COM module that embeds the interface you wish to import. (Later you will be able to specify the required COM component (or interface) in the list box in the [#Import_Group_Box Import] group box.)
    In the system registry database you can find all registered IIDs under:
    HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Interface

Import: Group Box

Controls in this group box are used to specify a COM component or a COM interface which should be imported. It contains the following controls:

Components:
Interfaces:

These radio buttons specify whether Components or Interfaces should be imported.

After you specify a correct COM module name/identifier and press the Load button, the information about COM components and interfaces embedded into this COM module is loaded into the IDE. Then lists of these embedded COM components and interfaces appear in the list box in the right pane of the Import: group box.

When the Interfaces is checked ON, then the list of names of embedded interfaces is displayed. In this list you can select one or several interfaces that should be imported into the COM package being created.

When the Components is checked ON, then the list of names of embedded components is displayed. In this list you can select one or several components that should be imported into the COM package being created.

To select several items you can:

  • Press and hold Shift then press Up Arrow, Down Arrow, Page Up, Page Down, Home, and End.
  • Press and hold Shift then press the left mouse button on the first and then on the last item (all items between them will be selected).
  • Press and hold Ctrl then press the left mouse button on several items (all pointed items will be selected).

As ActiveX

Checking ON this option you can specify that the components selected in the Components list box should be imported as ActiveX controls.

This check box is enabled only when the Components radio button is switched ON.

Interpret " short* "  as "string"

When it is checked ON. All elements declared in a C type library as pointers to the short type (short*) will be declared as belonging to the string domain in the Prolog interface.

Otherwise, the default declaration as a compound domain with the single alternative and one 16-bit argument is applied. Such domain is treated as a pointer to a 16-bit element.



Creating a Interface

Creating a Class

Creating a Text File

Creating a Resources