Multithreading capability (VBAMT) #2
Unanswered
WindowStations
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It looks like there may be some interesting possibilities within the VBA SDK, related to the patent for generating coclasses.
https://patents.google.com/patent/US6968538
The patent expires in 2023 I believe. Without any documentation, it's been hard to compile a working example.
Can anyone figure out how to create a public creatable class from the sample included in the SDK?
This is the only thing I could find on the subject:
Abstract
"Computer-implemented methods, systems and apparatus implement techniques for generating custom coclasses. A runtime environment includes a client application implementing an object model, which includes a hierarchy of object classes that can be instantiated in the client application. The object model includes class templates, each having an associated class type, and includes class functionality information—including required class functionality and elective class functionality—for custom classes that can be implemented in the client application. When a user requests the creation of a custom class of a specified type, a design-time environment is launched and class functionality information is retrieved for a class template associated with the type. A custom class is created, based on a class definition defining a class having the required class functionality and the specified elective class functionality. Objects belonging to the custom class can be instantiated from the runtime environment independent of the design-time environment."
BACKGROUND
"In traditional object-oriented programming environments, the incorporation of new functionality into an existing object model involved the hand generation of extensive quantities of software code specifically defining the implementation of the new functionality—e.g., one or more additional object classes encapsulating the desired functionality—and integrating that implementation into the existing object model. To do so typically required the application developer to assess user needs, evaluate the impact of any proposed change on hardware and software system components and implement changes at the source code level, using object-oriented programming languages such as C++. This process placed the extension of an existing object model squarely in the hands of the application developer, requiring a level of programming knowledge beyond the reach of many application users.
More recently, the introduction of integrated development environments that are directly embedded into a software application such as Microsoft's Visual Basic® for Applications (VBA) has simplified the process of application customization and extension for the end user. VBA includes both host and standalone project types that an end user can create. Host projects allow the end user to extend the object model of an application, but the extensions are limited to objects that are tightly coupled to the GUI instance of the application and the VBA IDE. As a result, such objects cannot be publicly created separate from the specific application instance. Also the mechanisms involved do not provide for easily adding new templated classes to the object model for extension by the end user and do not assist the user in integrating new instances into an instance of an existing object model.
VBA 6.x,, available from Microsoft Corporation, includes a multithreading capability (VBAMT) that allows the developer to create multithreaded projects, i.e., projects containing multiple threads that can execute concurrently. These projects are “standalone” in that the code that executes is not tightly coupled to the GUI instance of the application that hosts the VBA IDE. The process begins with a host application that registers one or more multithreading (“MT”) project types. Using these registered project types and an ActiveX VBA MT Designer, users of the application can create multithreaded projects, which are compiled and published as stand-alone DLLs.
A published MT project DLL can be used by other multithreaded host applications. To do so, a thread creates an instance of a VBA MT runtime object and an instance of a global application object associated with the MT project, against which the MT project executes code. The VBA MT runtime object is initialized through the IVbaMT interface, which loads all registered MT project DLLs. The collection of loaded MT project DLLs can be accessed through the IVbaMTDlls interface. Any number of threads can use an MT project DLL concurrently.
When a new MT project is created, a design instance of the MT Designer is created and associated with a logical group of threads. The user can then add classes, forms, and modules to the project. However, VBA MT provides that these classes are not publicly creatable outside of the VBA environment. Nor are these classes instances of the templated objects of an object model. The VBAMT capability provides no mechanisms to assist the end user with integrating a VBAMT project object into an enterprise wide application with a minimum of knowledge by the end user of the specifics of how to integrate into the enterprise environment.
VBA does allow the public creation of an ActiveX designer instance from a standalone project, but ActiveX designers require high-level programming skill and still do not provide the convenient object model integration support that a typical end user would require."
SUMMARY
"The invention provides methods, systems, and computer program products that provide the benefits of an application-embedded integrated development environment in designing object classes, but that allow users to instantiate and use objects of those classes outside of the development environment.
In general, in one aspect, the invention features methods, systems and computer programs implementing programming techniques for generating custom object classes. The techniques include providing a runtime environment including a client application implementing an object model, receiving in the client application a first user input including a custom class creation request specifying a class type for a custom class, in response to the first user input, launching a design-time environment for defining custom object classes, retrieving class functionality information for a class template associated with the specified class type, receiving in the design-time environment a second user input specifying a subset of the elective class functionality to be implemented in the custom class, and generating in the design-time environment a class definition defining a custom class having the required class functionality and the specified elective class functionality. The object model includes a hierarchy of object classes capable of being instantiated in the client application. The object model also includes one or more class templates. Each class template has an associated class type and includes class functionality information for a custom class that can be implemented in the client application. The class functionality information for each class template includes a set of required class functionality for the class type and a set of elective class functionality for the class type. Objects belonging to the custom class can be instantiated from the runtime environment independent of the design-time environment.
Particular implementations of the invention can include one or more of the following features. The class functionality information can include information identifying a set of mandatory interfaces defining the required class functionality for the associated class type and information identifying a set of elective interfaces defining the elective class functionality for the associated class type. After the class functionality information for the class template is retrieved, a list of the set of elective interfaces defining the elective class functionality can be displayed to the user. The second user input can include a user selection of one or more of the elective interfaces from the displayed list of elective interfaces. Generating the class definition can include aggregating a plurality of objects implementing the mandatory interfaces and the selected elective interfaces. Each of the elective interfaces can have a set of associated interface properties and interface methods, and a third user input can be received in the design-time environment including one or more code fragments further defining one or more of the interface properties and/or interface methods associated with at least one of the selected elective interfaces. Code skeletons can be generated for one or more of the interface properties and interface methods associated with the selected elective interfaces based on object metadata describing the specified elective interface that is associated with the interface property or interface method. Code skeletons can be displayed to the user. The design-time environment can include a graphical user interface. The runtime environment can be independent of the graphical user interface. An object of the custom class can be instantiated in the runtime environment. The class definition can be generated as a dynamic linked library. Instantiating the object can include calling the dynamic linked library in the runtime environment. The runtime environment can include a wrapper object operable to execute code in the dynamic linked library. The client application can be an automated process control program and the custom class can be a resource class for defining an apparatus driver for an apparatus coupled to the automated process control program. The client application can be an automated process control program and the custom class can be an action class for defining an action capable of being implemented by the automated process control program.
Advantages that can be seen in particular implementations of the invention include one or more of the following. The user can create and implement custom component object classes in a graphical design environment, while resulting instances of the custom class are decoupled from the graphical design environment. The custom class instances can be integrated into a larger object hierarchy that is separate from the graphical design environment. Decoupling the object model and services from a particular graphical design environment provides greater scalability, reuse, extensibility, and transactional isolation. In this conceptualization, a particular graphical user interface or application is just a “view” or “port” into the particular object model."
DETAILED DESCRIPTION
"The invention provides a computer-implemented process and computer program products for an end user to define component object classes (or “coclasses”) in a host graphical design environment and to instantiate those classes as objects suitable for merging into an existing object model that is separate from the graphical design environment (e.g., an object hierarchy implemented in a computer program application running in a process separate from the host design environment). As used in this specification, a “coclass” is a component class description that specifies the definition of that class—that is, the functionality that members of the class must possess—typically by specifying the interfaces that class members (instances) must implement. A component class is a class that can be instantiated by programming language independent means. Coclasses are generally implemented in DLLs or in executable files, each of which can contain one or more coclasses. As used in this specification, an “object” is a particular instance of a coclass. An object's functionality is defined by the interfaces specified for the corresponding coclass, which define the set of methods that control the object's operation. Although the disclosed implementation describes the integration into an existing object model of coclasses defined in the Visual Basic for Applications integrated development environment (“VBA IDE”) (available from Microsoft Corporation of Redmond, Wash. and Summit Software of Jonesville, N.Y.) the invention is equally applicable to other well-known programming environments, such as, e.g., a Java Virtual Machine or a variety of scripting languages."
Beta Was this translation helpful? Give feedback.
All reactions