Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ActiveX User Control

Posted on 1999-09-30
21
Medium Priority
?
432 Views
Last Modified: 2013-11-13
How do I know when a User Control in VB switches from Design Time to Run Time?
0
Comment
Question by:aminerd
[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
21 Comments
 
LVL 32

Expert Comment

by:Erick37
ID: 2088966
If AmbientProperties.UserMode Then
  'In user mode
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2088981
Sorry, that should have read..
If UserControl.Ambient.UserMode Then
0
 
LVL 5

Author Comment

by:aminerd
ID: 2088988
I get a Variable not Declared error. I have tried using Ambient.UserMode but I get a Client Site not available error.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Author Comment

by:aminerd
ID: 2088995
Oh sorry, I didn't see your comment. But I still get an error when I use: UserControl.Ambient.UserMode. I don't know why, it is used in properties to tell if the control is in design or run time.
0
 
LVL 8

Expert Comment

by:vettranger
ID: 2089044
I use this in my usercontrol_show procedure.

If Ambient.UserMode = False Then
   'you are in design mode
Else
   'you are in runtime
End If

0
 
LVL 32

Expert Comment

by:Erick37
ID: 2089047
Hmm...that's odd
Do you have both the test project and the usercontrol project open in the same project group?
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089051
Here's a little more information on exactly what I want to do:
  I am creating a winsock control in my ActiveX control at runtime. The problem is that "runtime" for the activex control includes design time for the application it is in. I only want the winsock control created while the application is in run time. I have tried putting:
If UserControl.Ambient.UserMode Then in UserControl_Initialize but I get a "Client Site not Available" error. I need to get around this somehow.
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089057
Yes I do have the test project and the usercontrol open in the same project group. I will try recompiling my ActiveX and then creating a new project not inside the group.
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089060
I recompiled the ActiveX control and then used it in a different project. Same error.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2089064
You can't put it in the Initialize event because the control is not ready yet.
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089072
I recompiled the ActiveX control and then used it in a different project. Same error.
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089078
Ok, I also tried putting it into the show event and I got the same error again. I don't know where else I could put it. There is an event called AmbientChanged but as far as I can tell it doesn't get fired when you switch modes.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2089101
It should work in Show
It will also work in ReadProperties
Put a Debug.Print "Event name" in each event to track the order in which things are fired.
Also make sure your project is using the current usercontrol, not the compiled ocx.
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089107
Ok, I also tried putting it into the show event and I got the same error again. I don't know where else I could put it. There is an event called AmbientChanged but as far as I can tell it doesn't get fired when you switch modes.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2089127
If the WinSock control is to be created only during runtime, you can write a method to create it and set it up. Then it can only be called from the user program.
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089128
Thanks alot! That seems to work. I don't know why I was getting the error before. If you want to resubmit your answer I will give you the points :)
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089129
Thanks alot! That seems to work. I don't know why I was getting the error before. If you want to resubmit your answer I will give you the points :)
0
 
LVL 32

Accepted Solution

by:
Erick37 earned 200 total points
ID: 2089145
Glad it worked.
UserControl.Ambient.UserMode (but not in Initialize)
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089162
Thanks alot! That seems to work. I don't know why I was getting the error before. If you want to resubmit your answer I will give you the points :)
0
 
LVL 5

Author Comment

by:aminerd
ID: 2089165
Thanks alot Erick37!
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6859540
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
http://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

670 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