Solved

Unload an ActiveX EXE

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…

862 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

24 Experts available now in Live!

Get 1:1 Help Now