Solved

Visual Basic calling DLL events

Posted on 2006-07-11
1
1,805 Views
Last Modified: 2013-11-25
When I show a non-modal dialog events are being returned to the calling application from the activeX so everything seems to be working fine.

However when I show a modal dialog events are getting blocked and are not seen by the calling application.

Attached is an example of the problem. One is a sample ActiveX dll and the other is a demo app which is using that dll.

Problems:

In dubug mode (IDE) of ActiveX dll, the demo app is seeing the Clicked event, however the event does not get fired in complied version of Dll.

Clicked Event is fired on Clicking [OK] button of ActiveX dll dialog

Need to Solve:

Demo app must get the event when clicking on the ActiveX dll dialog [Ok] button in the compiled exe.

In DLL Project
Add a form (Dialog) containing two buttons

Option Explicit
Public Event Clicked()

Private Sub CancelButton_Click()
    Hide
End Sub

Private Sub OKButton_Click()
        RaiseEvent Clicked
End Sub

Add a Class (clsTest)

Dim WithEvents mDialog As Dialog
Public Event Clicked()
Public Sub Load()
    Set mDialog = New Dialog
    mDialog.Show vbModal
    Unload mDialog
    Set mDialog = Nothing
End Sub
Private Sub mDialog_Clicked()
    MsgBox "Anu Jain"
    RaiseEvent Clicked
    MsgBox "Anu Jain111"
End Sub

Compile and register the DLL.

Create VBProject

Add form containing on Button, include reference of registered DLL.

Dim WithEvents mDialog As ModalDialogTest.clsTest
Private Sub Command1_Click()
    Set mDialog = New ModalDialogTest.clsTest
    mDialog.Load
   
End Sub
Private Sub mDialog_Clicked()
    MsgBox ""
End Sub

0
Comment
Question by:amit1978
1 Comment
 
LVL 13

Accepted Solution

by:
jmundsack earned 450 total points
ID: 17082124
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now