?
Solved

make my ActiveX control go away

Posted on 2000-03-31
10
Medium Priority
?
168 Views
Last Modified: 2010-05-18
I have two ActiveX controls written in VB6.  The first one knows how to do a couple things with an image.   The second one sits on top of the first control and knows how to create an email using CDO and send the image as an attachment.
What it DOESN'T know how to do is go away after I press the SEND button (does the email stuff.)

The function SEND does the email stuff then I try to use RaiseEvent Finished to make the email control go away.

like this

Private Sub cmdEmail_Click()
send "email"

RaiseEvent Finished   <------

End Sub

You can rightly assume I am not the world's greatest VB programmer.   I thought "Finished" was a standard VB thing that would shut down the control.
I have "Public Event Finished()" declared at the top of my control.

I DON'T have any code written for "Finished", I thought that was a facility of VB.   Maybe I'm wrong.

Please advise.

thanks in advance.


0
Comment
Question by:jnearing
[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
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 9

Expert Comment

by:samopal
ID: 2674159
You have to write some code to make this event works.

Sub UserControl2_Finished
' do what you want to do.
' But what do you want? VB doesn't have a method to delete existing control...

End sub

put this sub in usercontrol1 (image)
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2674233
In VB6, you can add controls at runtime.  So it makes sense that you can also remove them.

"HOWTO: Dynamically Add Controls to a Form with Visual Basic 6.0"
http://support.microsoft.com/support/kb/articles/Q190/6/70.ASP
0
 
LVL 9

Expert Comment

by:samopal
ID: 2674264
Erick, .Controls collection have only .Add method. But as for me, I cannot find a way to remove existing control. May be you know?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 14

Expert Comment

by:wsh2
ID: 2674276
After your SEND.. just do a: UserControl1.Visible = False

When you need it again.. do a:
UserControl1.Visible = True

Tada.. <smile>.

0
 
LVL 1

Expert Comment

by:ndb
ID: 2674761
Samopal:
Removing a control =
Set Text1(i) = Nothing
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2674784
ndb:
You can only remove a Control (or set it to Nothing) IF.. you had Dynamically added it first.. <smile>.
0
 
LVL 1

Expert Comment

by:ndb
ID: 2675793
I know that.
But jnearing can add it at runtime I suppose.
On the other had ... your solution of hiding the control is better I think.
0
 
LVL 14

Accepted Solution

by:
wsh2 earned 300 total points
ID: 2676136
ndb:
If I were you, right now I would just stick with using the Control's Visible property (as 99% of VB programs do). Dynamic Control creation requires implementing the Object Extender and then manually coding for each 'Created' Controls events, so that the appropriate action can be taken. Long story short, its a pain in the butt and is generally only used on the most severe of programming problems, if then. Anyhow, the choice is yours.. the Visible Property.. Dynamic Loading and Unloading of Controls (where the Set=Nothoing comments above will work).. or jsut pray for VB7 (don't hold your breath, tho).. <smile> and a <wink>.
0
 
LVL 1

Author Comment

by:jnearing
ID: 2687085
Hi guys,
   setting the control's VISIBLE property to false would be OK, but I have to do it from the parent control.

I'm trying to SETFOCUS back to the parent control to do that, but am not getting it yet.

It doesn't seem like that should be so hard, but we have put our best minds on it here.

thanks.
0
 
LVL 1

Author Comment

by:jnearing
ID: 2704065
I was able to get a handle to a 3rd party control on MY parent control, then set the focus to that.   After that I could set visible to FALSE on my control that I wanted to close.

thanks everyone.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses
Course of the Month9 days, 2 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