Solved

Unload an ActiveX EXE

Posted on 1999-01-28
4
386 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
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…

830 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