|
|
|
An ActiveX DLL doesn't have direct access to the environment of the calling EXE. For example, the App and Printer objects in the DLL don't correspond to the objects with the same name in the main application, therefore if you want to print something from the DLL using the same settings as the main app you must explicitly pass the Printer object from the main application. A similar reasoning applies to other global VB objects, such as the Forms collection.
Instead of explicitly passing the Printer, Forms, and App objects from the main app to the DLL, you can just pass it the hidden Global VB object. This object is actually the parent of the above-mentioned objects (and others as well, such as the Clipboard and the Screen objects). This code invokes a method in the DLL that receives the reference to the global object of the main app: |
Here's is the code in the Functions class module of the MyDLL component that receives the reference to the Global object. Note that the argument can't be declared using a specific object type, because this object is private to the VB library and Visual Basic won't let you pass it across project boundaries. Interestingly, the global object is a vtable-only object, and therefore doesn't support IDispatch, so the receiving parameter must be declared using IUnknown: ' in the Functions module of the MyDLL ActiveX DLL project |
Let's see now how you can enumerate all the forms in the main app from within the DLL: |
For more information see: MSKB Article Q138069.
|
|
|
|
Submitted By :
Nayan Patel
(Member Since : 5/26/2004 12:23:06 PM)
|
|
|
Job Description :
He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting. |
View all (893) submissions by this author
(Birth Date : 7/14/1981 ) |
|
|