Solved

Unload an ActiveX EXE

Posted on 1999-01-28
4
389 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
[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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

688 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