Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: AMBIENT OBJECT ERROR !!


Message #1 by "Monty" <monty911@h...> on Fri, 15 Nov 2002 22:59:21 +0530
Pretty simple.

The AmbientProperties are... read only. Usually they are used
to set the properties of the control to be the same of the
container (like backColor). E.g.

  usercontrol.backCOlor = ambient.backColor

In your case you want to do the opposite: set the backColor of
the container. For that, you have to use the Parent property,
not the Ambient... But be careful, that your control can be
located in a container that does not have a backColor property
(like an Excel document). Do something like:

On Error Goto SomePlace '' always check for errors
if typename(parent) = "Form" then
  parent.backColor = lMyColor
endif


Marco


> Hi

I want to create an activeX ( user control ) in vb
The program contains 5 command buttons having most common BACK COLORS
(red,yellow,green,blue and pink)
what i want to do is .. when . i place the control in container form and 
run
the application ...
when the user clicks those buttons then the form color should change
according to the backcolor of command button  === without writeing any code
in the container app

I've spend 3 FULL hours for this and asked many people but just got one
answer (( USE THE AMBIENT OBJECT ))

  Return to Index