Solved

Visual Basic calling DLL events

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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MsgBox 2 54
Why is "packages element is not declared"? 2 217
Prevent user closing word document opened with VB6 6 74
Macro Excel - Multiple If conditions 2 72
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

770 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