Need to load Form onto Form 
Author Message
 Need to load Form onto Form

Good day, all.

Our VB5 application requires us to dynamically load forms onto a top
level form. Currently, this is effectively being done using a
UserControl which sits on the top level form, SetParents a subsidiary
form to itself, and is then responsible for clearing itself up when the
application terminates.

Unfortunately, we have a problem. When a control in the contained form
is selected, and you move to another application, when you come back,
the control no longer has the focus. In fact, you will find that one of
the controls on the top level form will have focus instead. There are
also a couple of other problems (such as keystrokes going awry which we
guess are caused by this mechanism).

I have compared this scenario to the optimal one in which UserControls,
not Forms, are used to contain the application units. This behaves by
somehow adding its constituent controls to the tab order of the top
level form, and it works very nicely. If we could somehow replicate
this, I'll be very happy.

Any suggestions?

Thanks,

-------------------------
Mark Alexander Bertenshaw
Programmer/Analyst
Prime Response
Brentford
UK

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 21 Oct 2002 03:00:00 GMT  
 Need to load Form onto Form
Mark,

Sounds like an MDI application to me.  Is there a reason why you chose to
create your own 'container' form instead of using the standard VB MDI form
implementation?

Cheers,
Gary


Quote:
> Good day, all.

> Our VB5 application requires us to dynamically load forms onto a top
> level form. Currently, this is effectively being done using a
> UserControl which sits on the top level form, SetParents a subsidiary
> form to itself, and is then responsible for clearing itself up when the
> application terminates.

> Unfortunately, we have a problem. When a control in the contained form
> is selected, and you move to another application, when you come back,
> the control no longer has the focus. In fact, you will find that one of
> the controls on the top level form will have focus instead. There are
> also a couple of other problems (such as keystrokes going awry which we
> guess are caused by this mechanism).

> I have compared this scenario to the optimal one in which UserControls,
> not Forms, are used to contain the application units. This behaves by
> somehow adding its constituent controls to the tab order of the top
> level form, and it works very nicely. If we could somehow replicate
> this, I'll be very happy.

> Any suggestions?

> Thanks,

> -------------------------
> Mark Alexander Bertenshaw
> Programmer/Analyst
> Prime Response
> Brentford
> UK

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 21 Oct 2002 03:00:00 GMT  
 Need to load Form onto Form
Gary - thanks for replying.

Yes, ironically, it <does> sound a bit like an MDI thing. The only
problem is that you cannot load child forms from another DLL into your
MDI parent form. Daniel Appleman came up with a solution in a VBPJ
article a couple of months back, but unfortunately this involves using
UserControls that are dynamically loaded into project local child MDI
forms. We are using VB5 so this is not an option.

-------------------------
Mark Alexander Bertenshaw
Programmer/Analyst
Prime Response
Brentford
UK



Quote:
> Mark,

> Sounds like an MDI application to me.  Is there a reason why you
chose to
> create your own 'container' form instead of using the standard VB MDI
form
> implementation?

> Cheers,
> Gary



> > Good day, all.

> > Our VB5 application requires us to dynamically load forms onto a top
> > level form. Currently, this is effectively being done using a
> > UserControl which sits on the top level form, SetParents a
subsidiary
> > form to itself, and is then responsible for clearing itself up when
the
> > application terminates.

> > Unfortunately, we have a problem. When a control in the contained
form
> > is selected, and you move to another application, when you come
back,
> > the control no longer has the focus. In fact, you will find that
one of
> > the controls on the top level form will have focus instead. There
are
> > also a couple of other problems (such as keystrokes going awry
which we
> > guess are caused by this mechanism).

> > I have compared this scenario to the optimal one in which
UserControls,
> > not Forms, are used to contain the application units. This behaves
by
> > somehow adding its constituent controls to the tab order of the top
> > level form, and it works very nicely. If we could somehow replicate
> > this, I'll be very happy.

> > Any suggestions?

> > Thanks,

> > -------------------------
> > Mark Alexander Bertenshaw
> > Programmer/Analyst
> > Prime Response
> > Brentford
> > UK

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Mon, 21 Oct 2002 03:00:00 GMT  
 Need to load Form onto Form
Well, after all that, I have found a reasonable solution. First of all,
all of the controls on the top level form must have TabStop set to
False. However, if you want the focus to go to controls in one
particular contained form, this should be the first added control, or
TabStop should be set to True for this particular instance.

Furthermore, the Form Container control should be subclassed for the
WM_SETFOCUS message (UserControl_GotFocus and UserControl_EnterFocus
won't work). If the control receives this message, then it should
SetFocus to the form. This will in turn set the focus to the
ActiveControl on the form.

This is not a perfect generic solution, since it means that the focus
will only return to one of the contained forms, when gaining focus from
another application; however, for my particular application, this is
sufficient.

Mark Alexander Bertenshaw
Programmer/Analyst
Prime Response
Brentford
UK

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 22 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Loading a control from another Form onto current Form

2. loading form onto panel

3. load another form form one form

4. Windows Forms - Loading & Unloading Forms

5. VB Form Designer cannot load a form

6. Changing form-properties while running before loading the form

7. how to load a form from another form

8. Loading MDI Child forms to a parent form from a DLL

9. Loading a form within a form

10. How to load form using form name from field

11. ???????? GURUS - Showing or Loading Forms by use of String variable containing Form Name

12. Unloading Forms causing a Form Load Event???

 

 
Powered by phpBB® Forum Software