Create ActiveX instance at runtime 
Author Message
 Create ActiveX instance at runtime

How do i create an instance of an ActiveX Component at runtime?
Like x=new compname



Sat, 27 May 2000 03:00:00 GMT  
 Create ActiveX instance at runtime



Quote:
> How do i create an instance of an ActiveX Component at runtime?
> Like x=new compname

First of all, the component has to be properly registered in the
system registry.  Then you have to open your controls dialog
under the tools menu, and click the checkbox for it.  

Once that's done you have one instance available for use.   You
can create additional instances of it with the New operator, i.e.

Global or
Public or
Private or
Dim x As New CompName

depending on the scope you want the object variable to have

jdm



Sat, 27 May 2000 03:00:00 GMT  
 Create ActiveX instance at runtime

Did not work i tried ...

Public MyImage(100) As Image
'-- Image1 is an image on the Formwindow
  'Set MyImage(MyImageCount) = Image1
  'Set MyImage(MyImageCount) = New Image1
  Set MyImage(MyImageCount).Picture = LoadPicture(MyTrim(stri))

Tried all variants, Please help again !

Quote:


>> How do i create an instance of an ActiveX Component at runtime?
>> Like x=new compname
>First of all, the component has to be properly registered in the
>system registry.  Then you have to open your controls dialog
>under the tools menu, and click the checkbox for it.  
>Once that's done you have one instance available for use.   You
>can create additional instances of it with the New operator, i.e.
>Global or
>Public or
>Private or
>Dim x As New CompName
>depending on the scope you want the object variable to have
>jdm



Sun, 28 May 2000 03:00:00 GMT  
 Create ActiveX instance at runtime



Quote:

> Did not work i tried ...

> Public MyImage(100) As Image
> '-- Image1 is an image on the Formwindow
>   'Set MyImage(MyImageCount) = Image1
>   'Set MyImage(MyImageCount) = New Image1
>   Set MyImage(MyImageCount).Picture = LoadPicture(MyTrim(stri))

What you have to do in the above example is:
Public MyImage(100) As Image

   Load MyImage(ImageCount)
   MyImage(ImageCount).Picture = LoadPicture(picfile)

You have to use Load, because you are declaring it as an array.

Don't use the Set command to assign properties.  It is only
used to assign an object variable to an object.

Also remember that if you create two object variables, and
set one equal to the other, they will both point to the same
object.  

If you do like this:
  Public MyImage as New Image
  Public MyImag2 as Image

  Set MyImag2 = MyImage

Then MyImag2 points to the same object as MyImage

To have two independent instances of the same
type of object, you have to use the New keyword
on both.

  Public MyImage as New Image
  Public MyImag2 as New Image

Then, to copy the properties of one to another, you
have to do it one at a time.  You can't use
  Set MyImag2 = MyImage
because it redirects MyImag2's pointer to MyImage
and you no longer have two independent objects.

And you can't do this:
  MyImag2 = MyImage
because VB won't let you.

What you have to do is:
  MyImag2.Picture = MyImage.Picture
  MyImag2.Border = MyImage.Border
  . . .etc.

until all the properties you want
to copy are copied.

jdm



Sun, 28 May 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. creating activeX instances at runtime outside a form ?

2. Locating instance of ActiveX Designer at runtime

3. Having ActiveX with Event on ActiveX created at runtime: HOW

4. create an instance of a windows form at runtime

5. Creating a new global instance at runtime

6. Creating instances of controls at runtime

7. Creating a new instance of a control at runtime

8. Creating a new instance of MSMasked during runtime

9. Creating a new instance of the ActiveX control

10. create 2nd instance of ActiveX control at run-time

11. Creating Winsock instance in ActiveX .dll

12. Creating instance of a control in an ActiveX DLL

 

 
Powered by phpBB® Forum Software