Solved

Unload an ActiveX EXE

Posted on 1999-01-28
4
382 Views
Last Modified: 2010-05-18
Solved one problem, created another ;-)
Anyone know how to kill an ActiveX EXE control?

' This is how I load it
mcmnTest.ShowForm cfeModeless

'It's ActiveX EXE so you can't unload it like
Unload mcmnTest

'I tried putting this in Class module
Public Sub DoEndIt()
TestForm.Form_Terminate
End Sub

'And then this in the ActiveX TestForm
Public Sub Form_Terminate()
TestForm.Timer1.Enabled = False
Unload TestForm
End Sub

' And this in the Class Module.
' If you make it Public and call it, nothing happens
Private Sub Class_Terminate()
    On Local Error Resume Next
    Unload TestForm
    Set TestForm = Nothing
End Sub


But none of that works. I've read till I'm blue
in the face. The VB5 Online books arn't very clear,
and offer little help.  How hard could it be?
(I guess I shouldn't ask!).  Any Ideas?
0
Comment
Question by:jgore
  • 2
4 Comments
 
LVL 14

Expert Comment

by:waty
ID: 1471131
Did you tried to send a WM_Close message?
0
 
LVL 10

Accepted Solution

by:
caraf_g earned 0 total points
ID: 1471132
Public Sub DoEndIt()
'This ensures no spurious events will happen to interfere with
'the unload
TestForm.Timer1.Enabled = False
'Unloads the window
Unload TestForm
'Destroys the object reference.
Set TestForm = Nothing
End Sub

Then to get rid of the class:
objClassThing.DoEndIt
Set objClassThing = Nothing

All the best
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 1471133
PS -

Do not refer to your form in your ActiveX.exe by its name:

If you designed a form called Form1 in your ActiveX.exe you must have the following in your Class:

Private objForm1 As Form1

Then when you need to show the form

Set objForm1 = New Form1
objForm1.Show <modeless or modal, whatever>

In the answer, replace TestForm with objForm1 - see what I mean?

Sorry for not making this clear in original answer.
0
 

Author Comment

by:jgore
ID: 1471134
Thanks!
I understood about not using it's real name!
I've really got ahead of myself here, using ActiveX.
But I think I can make it work now.
However, where does this go:

Then to get rid of the class:
objClassThing.DoEndIt
Set objClassThing = Nothing

I think My Object Class is called XTimer.
So:
XTimer.DoEndIt
Set XTimer = Nothing

I assume this would go in the original Calling App, the Client right?
A way to turn it off and then kill the reference to it.
I'll try it and see what happens.
Thanks again!


0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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

759 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

18 Experts available now in Live!

Get 1:1 Help Now