Solved

Visual Basic calling DLL events

Posted on 2006-07-11
1
1,810 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
[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
1 Comment
 
LVL 13

Accepted Solution

by:
jmundsack earned 450 total points
ID: 17082124
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
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…

729 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