?
Solved

Unload an ActiveX EXE

Posted on 1999-01-28
4
Medium Priority
?
391 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses
Course of the Month8 days, 16 hours left to enroll

764 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