Dynamic forms ? 
Author Message
 Dynamic forms ?

FORM PROBLEM !!!

My problem is, how to show (or create first instance) of a form if I
have its name in a string variable. I'd need something like :
SFormName = "frmMyForm"
Load (sFormName)
Or
(sFormName).Show
It (of course) doesn't work. I didn't even expect that. But I think that
there should be either hi-level object-based  (COM) solution or some
low-level API based solution. Because I'm not too familiar with API, I
tried the object way.

1) I created an ActiveX DLL and frmTest form in it. I set reference to
this DLL from my app and wrote this :
CreateObject(, "MyDll.frmTest")
This didn't work, because I couldn't set instancing property of form
class in that DLL !!!! If form is just a class (Microsoft says YES), why
can't I set its instancing property when placed in ActiveX DLL ??? Or
could I ?
2) I added a class clsMakeFormCreatable in my ActiveX DLL, which had
just one property : PUBLIC frmRef AS Form. Because class inside ActiveX
DLL can see forms in the same DLL, I was able to access formerly not
"visible" forms in DLL through my small class.  But it still didn't
solve my problem, because in fact I have MDI Main window in my
application and what I need is to show MDI child windows using that
string parameter containing its name. But forms stored in DLL can't be
displayed as a MDI children of the MDI main form in main application (or
could they ?!?!?!?!?). So I had to try third way :
3) I thought that if my application would be an ActiveX EXE (which
sounds fine to me) and all forms will be in this EXE, it could allow me
to write this :
Dim frmInstance AS Form
FrmInstance = GetObject (, frmTest)
But it unfortunately doesn't work - "ActiveX can't create object"
message appears. Is there any way how to make it work ?

So this is my problem. I have names of MDI child forms stored in a data
table and I want to display them. Is there ANY way (hi or low-level) to
do this ?
PS : The solution MUST be generic. Some people from USENET advice me to
make a procedure LoadForm which will include a huge CASE statement. It
is not acceptable. There will be a lot of forms in our app. It must be
generic, so no form name can be hardcoded in the code. I also know that
forms aren't in the FORMS collection before first LOAD (other usual
advice from USENET).

---------------------------------------------------------------------------------------------------------------------

 I've already written complete menu-building routines to create menus
dynamically and with look like VB menu has (bitmaps, fonts, separators,
menubreaks). Now I'm solving the problem of dynamic form creation.
Microsoft lies to us that form is just a normal class plus some visual
interface. But where it has an instancing property ? Now we have to
create a shadow class in our form's ActiveX DLL with one property AS
FORM. This class hopefully can have an instancing property so we can use
CREATEOBJECT. But again : after my research, studying and begging for
information, I found these solutions :
1) ActiveX DLL, shadow classes and SetParent API call. It would probably
need another subclassing. Does anybody know how to make it work ?
2) ActiveX Documents - but how about performance ???
3) Own forms. It means to create a form template that includes one
instance of each control you need. They must have indexes=0 to allow
'cloning' in control arrays. Then we just need to have data structure to
store all form's definition (all control instances, their position,
size, etc...). Then we need a couple of generic routines to build
specific forms from the template according form's definition in table.
And performance ???? Some people have done it already. We just can ask
them...

I'm  wondering, what is MS saying about that. They're still talking
about dynamic three tier applications... I thing DCOM should support
something like this, otherwise ...

Thank you in advance for you response and any useful information

PS : I don't read news often, please send me a e-mail to



Mon, 14 Feb 2000 03:00:00 GMT  
 Dynamic forms ?

Quote:

>FORM PROBLEM !!!
>2) I added a class clsMakeFormCreatable in my ActiveX DLL, which had
>just one property : PUBLIC frmRef AS Form. Because class inside ActiveX
>DLL can see forms in the same DLL, I was able to access formerly not
>"visible" forms in DLL through my small class.  But it still didn't
>solve my problem, because in fact I have MDI Main window in my
>application and what I need is to show MDI child windows using that
>string parameter containing its name. But forms stored in DLL can't be
>displayed as a MDI children of the MDI main form in main application (or
>could they ?!?!?!?!?). So I had to try third way :

        Could you not simply set the MDIchild value of each form to
True, then in your DLL use the SetParent API call to  make each
instance of the created form 'BELONG' to the MDIparent form? Just
thinking off the top of my head, but it might work.


Mon, 14 Feb 2000 03:00:00 GMT  
 Dynamic forms ?

Try this one:

Function LoadForm(FormName$)
    Dim i%

    For i = 0 to Forms.Count - 1
        if Forms(i).Name = FormName then
            Load Forms(i).Name
            Exit For
        End If
    Next
End Sub

Mick

Quote:

> FORM PROBLEM !!!

> My problem is, how to show (or create first instance) of a form if I
> have its name in a string variable. I'd need something like :
> SFormName = "frmMyForm"
> Load (sFormName)
> Or
> (sFormName).Show



Wed, 16 Feb 2000 03:00:00 GMT  
 Dynamic forms ?

Try this one:

Function LoadForm(FormName$)
    Dim i%

    For i = 0 to Forms.Count - 1
        if Forms(i).Name = FormName then
            Load Forms(i).Name
            Exit For
        End If
    Next
End Sub

Mick

Quote:

> FORM PROBLEM !!!

> My problem is, how to show (or create first instance) of a form if I
> have its name in a string variable. I'd need something like :
> SFormName = "frmMyForm"
> Load (sFormName)
> Or
> (sFormName).Show



Wed, 16 Feb 2000 03:00:00 GMT  
 Dynamic forms ?

Will you tell me how to use the codes for vb i am new to this and i need help

                          -Xx0PuNt0xX-



Thu, 24 Feb 2000 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Accessing Dynamic Controls on Dynamic Forms

2. Dynamic forms on the fly(2nd post)

3. Dynamic Forms: Creating Controls On The Fly

4. Runtime Creation of Dynamic Forms

5. Dynamic Forms

6. Passing info from dynamic form to caller

7. Dynamic Form Re-sizing

8. Creating dynamic forms

9. Dynamic form generation

10. Example of dynamic form and data binding.

11. Referring to Dynamic form elements

12. Dynamic Forms

 

 
Powered by phpBB® Forum Software