Solved

ActiveX DLL

Posted on 2006-06-16
11
378 Views
Last Modified: 2010-05-18
Im creating an ActiveX dll as part of a larger project.  I have added many modules and forms from a previous program for simplicity.  

The problem is that I need the dll to raise an event when one of the forms raises an event and im not sure how to do that.
0
Comment
Question by:justchat_1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
11 Comments
 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 16926954
>> I have added many modules and forms from a previous program for simplicity

u added these files to dll project ?

>>I need the dll to raise an event when one of the forms raises an event

pls explain a little bit more
0
 
LVL 9

Author Comment

by:justchat_1
ID: 16927922
yes the forms have some controls that i need to use.  

Basically a form is parsing information and the dll needs to raise an event when certain information is parsed.  However im not sure how the form can raise the event on the dlls class module.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 16936351
Usually when you include forms inside of a DLL, you have to interact with it from the instantiated class, and so your class usually declares a form variable to work with, e.g.,


Dim WithEvents myForm As Form1

Public Sub ShowForm()
    If myForm Is Nothing Then Set myForm = New Form1
    myForm.Show
End Sub


Now, your form will raise events to your class module which you can, in turn, then raise an event to the client calling your DLL, e.g.,


Event FormClicked()


Private Sub myForm_Click()
    RaiseEvent FormClicked
End Sub
0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 14

Expert Comment

by:Shiju Sasidharan
ID: 16936394
Class1.cls
'------------------------------------------------
Event YourEvent1()
Event YourEvent2()

Public Function MyFunction1()
   
    RaiseEvent YourEvent1

End Function

Public Function MyFunction2()
   
    RaiseEvent YourEvent2

End Function
'------------------------------------------------

Form1.frm
'------------------------------------------------
Dim WithEvents obj As Class1

Private Sub Command1_Click()
Dim oTest As New Class1
    Set obj = oTest
    obj.MyFunction1
    obj.MyFunction2
End Sub

Private Sub obj_YourEvent1()
    MsgBox "Event Raised: YourEvent1"
End Sub

Private Sub obj_YourEvent2()
    MsgBox "Event Raised: YourEvent2"
End Sub
'------------------------------------------------
0
 
LVL 9

Author Comment

by:justchat_1
ID: 16937237
azrasound:
I tried that already the problem is the form interfaces with other modules in the project.  If its an object the modules are unable to pass information back to the form.

shijusn:
thought about that too... the problem is that the class is the main class for the dll and it needs to be instantiated by another program that uses the dll...
0
 
LVL 28

Accepted Solution

by:
AzraSound earned 500 total points
ID: 16937995
Well another option is to create a public variable for the form in a bas module and set your class form object to that variable, e.g.,

'in a bas module
Public GlobalForm As New Form1

'inside class module
Private WithEvents myForm As Form1

Private Sub Class_Initialize()
    Set myForm = GlobalForm
End Sub


Normally you would approach this from a more structured method, but since it sounds like these existing forms/modules are all intertwined as it is, this should be a simple fix.
0
 
LVL 9

Author Comment

by:justchat_1
ID: 16938805
looked good in a test program but im getting an "Object does not source automation events" when i try to compile in the real thing.

At line:
Private WithEvents myform As frmIMSniff
0
 
LVL 9

Author Comment

by:justchat_1
ID: 16938812
nevermind...I created a seperate public event and that solved it.

I just need to finish testing and then I will award points.
0
 
LVL 9

Author Comment

by:justchat_1
ID: 16938902
still having trouble:
when the modules reference the form can they use its name or do they need to use the object name?
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 16942431
The modules must reference the public/global variable of the form you created.
0
 
LVL 9

Author Comment

by:justchat_1
ID: 16947486
Great solution...I was able to finish the dll
thanks for all the help
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month5 days, 14 hours left to enroll

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question