Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

It is for a genius

Status
Not open for further replies.

javierbalk

Programmer
Feb 27, 2002
22
0
0
AR
Hi, what I need is to get the Forms collection of the client application that uses my Usercontrol ActiveX (OCX).

I mean, when a program uses my OCX, I want to get the reference to the Forms collection of that program from the UserControl.

I developed an ActiveX that doesn't require code, but now (in my new version), I have to tell the developers that they have to add a line of code in the Form_Load event:

Set myControl.Forms = Forms

It bothers me a lot, any idea?

I really think that it is practically impossible, but who knows...

My OCX is in the site and the new version (beta) that I am talking about is in
Thanks,

Javier
 
I am still not sure what it is you are looking for ? Do you want a list of all the forms that are used in the application - and retrieve it from your ActiveX, or does the ActiveX on each form need to report the fact hat code needs to be added to it's parent form ?

Graham
 

I am just guessing, but if your activeX control has a container property or you could add a control that has it you could reference it like so (Add a command button to a form.)

[tt]

Private Sub Command1_Click()
Print Command1.Container.Name
Print Command1.Container.hWnd
End Sub

[/tt]

I Hope This Helps. Good Luck
 
Well, I see that what I said was not understood.
I will explain it better now.

Every VB program has a Forms collection, this collection is called Forms.

For example, you can do something with one or all the forms with it.
A sample code for changing the BackColor of all the forms (all the forms that are loaded in that moment)

Dim F as Form

For Each F in Forms
F.BackColor = vbBlue
Next

But this collection, "Forms" is accessible only within the program.

I have an ActiveX control that needs the Forms collection of the client application, the client application is the one that uses my ActiceX UserControl.

I need this because I have to do something with all the forms and not only in the one where it it placed.
To have a reference to the form where the UserControl is placed is very easy:

Dim ThisForm as Form

Set ThisForm = Parent

But what about the other forms?...

The Hwnd does not help me, I already have the Hwnd of all the forms, I get them with some API calls, but in order to access the form object, and make something with the forms via VB code I need the reference to each one.

You can see what I am talking about if you see my ActiveX, you can download it from
You will see that I have to tell the users that they have to put the line of code:

Set Skinner1.Forms = Forms

and that is what I don't like!

I will give you a free license key for my product if you can tell me (if there is one) a solution for this.

By the way, my product is component that automates the skinning in VB 6 programs.

I hope I was more clear now,

Javier
 
Parent property ... followed to the app should place you in the application instancing your control. Form there, the forms collection should be available.

I have some reservations re the approach you APPEAR to taking, as it SEEMS like you will go trough the machiniations on every occassion of instancing the (your) control. You should (carefully) consider the implications of the approach to avoid repeatedly executing the code. I think the more common approach is to have OCXs registered and use the regisrty version be checked. When the control is updated, the registry version value changes and changes are triggered from here.


MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Hello:

I did not undestand what you mean with
"I think the more common approach is to have OCXs registered and use the regisrty version be checked. When the control is updated, the registry version value changes and changes are triggered from here."

About your suggestion, there is not such a property:
App.Parent or Parent.APP

And Forms is not a member of App either. I mean, you can't access Forms with App.Forms

Javier
 
Control.Parent should "point" to the form / subform. Assuming that it points to a form.

e.g.

? Me("cmdBioStart").Name
cmdBioStart

? Me("cmdBioStart").Parent.Name
frmMain

See VB Help "Parent Property" and NUMEROUS related entries. I do seem to have overstepped a bit, as it (in this reference at least) only applies to control objects (not the forms). However each instance of it's appearance on each form should be detectable, rendering the necessity of enumerating the forms collection un-necssary?

Again, I do not fully understand the concern, as 'publishing' the revised OCX should be somewhat automatic. It (the revised OCX) cannot appear in any "Compiled" apps unless / untill they (compiled apps) are revised / re-compiled. Since the rev level of the control should be different, the programmer must change the program and thus be aware of the new control. "Publishing" the documentation would naturally include the appropiate instructions. Isn't that the point of object orientation?

I just do not understand HOW you are revising the control w/o the registration process becomming necessary.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
I think we are talking about different things.
What I am asking has nothing to do with publishing, documentation, registering and so.

I know very well the Parent property, it gives a reference to the form where the UserControl is located.

But I need all the forms, not only this one.

I will be as clear as I can: I need the forms collection of the client application.

I can do that telling the user to write:
Set MyControl.Forms = Forms
in his app.

In my UserControl I have a Property:

Public Property Set Forms (nForms as Collection)
Set nForms = Forms
End Sub

In this way I have what I need (the reference to the forms collection) in the variable nForms
Well, what I am asking is how to avoid this line of code.

I want to retrieve the reference to the forms collection of the client app automatically (from my code). How?

I need that because I have to do something in the other forms too, not only the Parent form (The Parent form: the form where the control is located).

Javier
 
I have been doing some research with the object browser.

Forms is a member of Global.
Global is a class of the library VB.

So this code:

Dim a

Set a = VB.Global.Forms

is the same that

Dim a

Set a = Forms

Now, can I get a reference to the Global class of the Client app?

Can I do something with VB? something like

Set nForms = VB([Client app]).Global.Forms

Any idea?

Javier
 
For MichaelRed:

I have read your comments again (with more time) and I understood now what you meant with your comments.
Yes, you are right, if I make changes to the product and a customer want to upgrade to the new version, he has to re-compile his program(s).
But I am working in a new version, so I want to change what I was asking here.

This thing happend with all components, if you upgrade to a new version you have to re-compile the program.

Javier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top