VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Concepts of DLL Components

by Raghuraja.C (12 Submissions)
Category: Miscellaneous
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 14th June 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Concepts of DLL Components

Rate Concepts of DLL Components



--------------

1. DataBindingBehavior Property

Sets a value that determines if an object can be bound to a data source. Only available at design time.

Syntax : object.DataBindingBehavior [= number]

The DataBindingBehavior property syntax has these parts:

Part   Description 
object An object expression that evaluates to an object in the Applies To list. 
number An integer that specifies data binding behavior, as described in Settings. 

Settings

The settings for number are:

Constant Setting Description 
vbNone 0 (Default) The object can't be bound to a data source. 
vbSimpleBound 1 The object can be bound to a data source using simple binding. 
vbComplexBound 2 The object can be bound to a data source using complex binding. 


Remarks

Use the DataBindingBehavior property when you want an object to act as a consumer of data provided by objects. A data consumer may be either simple bound (binding to single fields) or complex bound (binding to a rowset).

When DataBindingBehavior is set to 1 (vbSimpleBound), the PropertyChanged event and the CanPropertyChange method are added to the object's procedures.
--------------
2. DataSourceBehavior Property
      
Sets a value that determines if an object can act as a source of data for other objects. May only be set at design time.

Syntax : object.DataSourceBehavior [= number]

The DataSourceBehavior property syntax has these parts:

Part Description 
object An object expression that evaluates to an object in the Applies To list. 
number An integer that specifies data source behavior, as described in Settings. 

Settings

The settings for number are:

Constant Setting Description 
vbNone 0 (Default) The object can't act as a data source. 
vbDataSource 1 The object can act as a data source. 

Remarks

Use the DataSourceBehavior property when you want an object to act as a source of data for other objects. When DataSourceBehavior is set to 1 (vbDataSource) or 2 (vbOLEDBProvider), the GetDataMember event is added to the object’s procedures.

DataSourceBehavior may only be set to 2 (vbOLEDBProvider) when the object is a public class. In this case, the OnDataConnection event is also added to the object's procedures.
-----------------
3. Instancing Property
      
Sets a value that specifies whether you can create instances of a public class outside a project, and if so, how it will behave. Not available at run time.

Settings

The Instancing property has these settings:

Setting Description 
1 (Default) Private. Other applications aren’t allowed access to type library information about the class, and cannot create instances of it. Private objects are only for use within your component. 
The Instancing property default varies depending on the project type. Private is the default only for class modules in Standard Exe projects.

When you insert a new class module into an ActiveX Exe project or an ActiveX DLL project, the default value of the Instancing property is MultiUse. When you insert a new class module into an ActiveX Control project, the default value of the Instancing property is PublicNotCreatable.
 
2 PublicNotCreatable. Other applications can use objects of this class only if your component creates the objects first. Other applications cannot use the CreateObject function or the New operator to create objects from the class. 
3 SingleUse. Allows other applications to create objects from the class, but every object of this class that a client creates starts a new instance of your component. Not allowed in ActiveX DLL projects. 
4 GlobalSingleUse. Similar to SingleUse, except that properties and methods of the class can be invoked as if they were simply global functions. Not allowed in ActiveX DLL projects. 
5 MultiUse. Allows other applications to create objects from the class. One instance of your component can provide any number of objects created in this fashion. 
6 GlobalMultiUse. Similar to MultiUse, with one addition: properties and methods of the class can be invoked as if they were simply global functions. It’s not necessary to explicitly create an instance of the class first, because one will automatically be created. 

Setting Applies to Project Type 
       ActiveX Exe ActiveX DLL ActiveX Control Std. Exe 
Private X X X X 
PublicNotCreatable X X X   
SingleUse X     
GlobalSingleUse X 
MultiUse X X 
GlobalMultiUse X X 

Remarks

The Instancing property applies to Class modules and was expanded in Visual Basic 5.0 to incorporate the functionality of the Visual Basic 4.0 Public property.

When a class is creatable, you can use any of the following techniques to create instances of the class from other applications: 

Use the CreateObject function, as in: 
Set MyInstance = CreateObject("MyProject.MyClass")

Use the Dim statement within the same project (or outside the project if the Public property is also set to True), as in: 
Dim MyInstance As New MyClass

The New keyword indicates that MyInstance is to be declared as a new instance of MyClass.

If the Public property is False, the setting of the Instancing property is ignored. You can always create instances of the class within the project that defines the class. If the Public property is True, the class is visible and therefore can be controlled by other applications once an instance of the class exists.

Note   The properties and methods of a GlobalMultiUse object are not part of the global name space of the component that provides the object. For example, within the project that contains the GlobalUtility class module, you must explicitly create an instance of GlobalUtility in order to use the object's properties and methods. Other limitations of global objects are listed in "Global Objects and Code Libraries," in "Building Code Components" in the Component Tools Guide.

---------------
4. MTSTransactionMode Property
      

Specifies the transactional behavior of a class. This property is only used by components running in the Microsoft Transaction Server, and has no effect if the component is run outside of the Transaction Server.

Syntax : object.MTSTransactionMode [= value]

The MTSTransactionMode property has these parts:

Part Description 
object An object expression that evaluates to an item in the Applies To list. 
value An integer or constant specifying the transactional behavior of a class. 


Settings

The settings for value are:

Constant Value Description 
NotAnMTSObject 0 (Default) The component doesn't support Microsoft Transaction Server. 
NoTransactions 1 Does not support transactions. This value indicates that the component's objects do not run within the scope of transactions. When a new object is created, its object context is created without a transaction, regardless of whether the client has a transaction. 
RequiresTransaction 2 This value indicates that the component's objects must execute within the scope of a transaction. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a transaction, MTS automatically creates a new transaction for the object. 
UsesTransaction 3 This value indicates that the component's objects can execute within the scope of their client's transactions. When a new object is created, its object context inherits the transaction from the context of the client. If the client does not have a transaction, the new context is also created without one. 
RequiresNewTransaction 4 This value indicates that the component's objects must execute within their own transactions. When a new object is created, MTS automatically creates a new transaction for the object, regardless of whether its client has a transaction. 


Remarks

The Microsoft Transaction Server uses the MTSTransactionMode property during object creation to determine whether the object should be created to execute within a transaction, and whether a transaction is required or optional.

Most MTS components are declared as either UsesTransactions or RequiresTransaction. These values allow an object to execute within the scope of its client's transaction. You can see the difference between these values when an object is created from a context that does not have a transaction. If the component's transaction attribute is UsesTransactions, the new object runs without a transaction. If it is declared as RequiresTransaction, MTS automatically initiates a transaction for the new object.

Declaring a component as RequiresNewTransaction is similar to using RequiresTransaction in that the component's objects are guaranteed to execute within transactions. However, when you declare the transaction attribute this way, an object never runs inside the scope of its client's transaction. Instead, the system always creates independent transactions for the new objects. For example, you can use this attribute for auditing components that record work done on behalf of another transaction regardless of whether the original transaction commits or aborts.
--------------
5. Persistable Property
      
Sets a value that determines if an object can save and restore data across instances. May only be set at design time.

Syntax : object.Persistable [= number]

The Persistable property syntax has these parts:

Part Description 
object An object expression that evaluates to an object in the Applies To list. 
number An integer that specifies persistence behavior, as described in Settings. 

Settings

The settings for number are:

Constant Setting Description 
vbNotPersistable 0 (Default) The object can't be persisted. 
vbPersistable 1 The object can be persisted. 


Remarks

The Persistable property is only available for classes that are public and creatable. When Persistable is set to vbPersistable, the following events are added to the class: InitProperties, ReadProperties, and WriteProperties. The PropertyChanged method is added to the class as well.



Download this snippet    Add to My Saved Code

Concepts of DLL Components Comments

No comments have been posted about Concepts of DLL Components. Why not be the first to post a comment about Concepts of DLL Components.

Post your comment

Subject:
Message:
0/1000 characters