Solved

Visual Basic calling DLL events

Posted on 2006-07-11
1
1,804 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

706 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

13 Experts available now in Live!

Get 1:1 Help Now