Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ActiveX DLL

Posted on 2006-06-16
11
Medium Priority
?
387 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

877 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