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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual class from a form?

Status
Not open for further replies.

bironman

Programmer
Jul 27, 1999
29
0
0
EC
I have a form with methods and propperties that I want to use in the rest of the forms of my application. Can I create a *visual class* from this form?<br>
<br>
I'm new in VB6. With VFP (and other OOP languages) this task can be done quickly and efficiently.<br>
<br>
Using Dim frmOne As New frmClass doesn't work 'cos I need instantiate the form object at *design time*.<br>
<br>
TIA
 
maybe I did'nt understand....for a procedure, function or any other to be visible by other forms in the app. they must be declared as public...<br>
<br>
public sub yourproc()<br>
'your code<br>
end sub<br>
<br>
or <br>
<br>
public function(your var)<br>
<br>
end function<br>
<br>

 
No.<br>
<br>
What I want is to INSTANTIATE a form in design time.<br>
I want a form INHERIT methods and properties from a form class in order to do all forms work the same way.<br>
Other way is cut and paste code into new forms. This is what I'm doing right now. Obviously this is not efficient.<br>
<br>
(To VFPers: I can do this task by selecting the form and doing "Save as class..." and instantiating new forms from this class)<br>
<br>
(excuse my bad english)<br>

 
you can do this by creating multiple instances of the same form...yes...I have done this with mdi creating multiple instances of the child form.<br>
<br>
Am I on the right track here?<br>
<br>
A great book for learning this is called<br>
<br>
Visual Basic Programmer's Library published by Jamsa Press
 
Maybe I need a book for learning english ;-)<br>
<br>
Positran, you do that at run-time (I think). I want to do it at design-time, so I can modify some controls of each form class' instances. Yes, I mean polimorphysm.<br>
<br>
The model form have some methods and properties that must be common for all forms, but each form instance have different controls within them.<br>
<br>
I wonder it's so easy to do it in VFP and other OOP languages. I'm getting the conclussion that this can't be done in VB and I will have to cut and paste code in new forms and re-write *each form code* everytime I define a change in the forms behaviour's logics.<br>

 
you could start a new form. Design it the way you want to adding the controls and setting the properties. Use the save as to save it as say...."frmTemplate." Then you can add frmTemplate to the project as often as you want...but you can only have one instance of the form with that name. So you will need to save the original frmTemplate as something else...say "frmMain". Now you can add a new frmTemplate to the project. Any time you want to add another just rename frmTemplate to something else and add a new one. Remember you must use "Save as..." because simply renaming the form will not get the job done.
 
I think that what you want can be done creating an ActiveX control with the form and create the properties and methods at design time.<br>

 
positran:<br>
What happens when I change the logics of the original form?...<br>
I should change the source code of the "instances" mannually. That's what I'm doing already.<br>
<br>
Hug:<br>
Can I redefine the methods and properties AND CONTROLS of each instance of the Activex control?
 
Making an AxControl you can create your own properties, you should create control arrays and change their properties.<br>
Is like subclassing.<br>
On your property page of the Axcontrol you define all the diferents properties you want to make available and change them at design time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top