Tech. Q: Implementing multiple forms within single form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm not sure if I'm asking about MDI or not... not a very advanced WinForm (or Win32 client) developer (most of my time is web dev).

I'm creating an applicatoin where I will have a common toolbar, menu, and panel (using one of the free XP-like collapseable panels on the left hand side). The bulk of the UI in my application (to the right of the panel and below the toolbar) will change based on your selections in the toolbar. This is simlar to Outlook where you have a single applicatin, but it's main UI form changes "modes" based on user actions. I could use MDI, but that's not really what I'm trying to accomplish. I could also use multiple panels and hide/show when buttons in the toolbar were clicked, but the main form will get pretty big (which is ok if it's my only option).

Ideally I'd like to develop each "mode" seperately and just load them into the main window when the time comes... not sure if this is feasible (I tired it one time, but with a very convoluted approach >>> I had a main window, then created a new instance of the child window inside the parent with no chrome and placed it perfectly inside.

Thanks in advance for the input.
-AC
 
AC said:
Ideally I'd like to develop each "mode" seperately and just load them into
the main window when the time comes... not sure if this is feasible (I tired
it one time, but with a very convoluted approach >>> I had a main window,
then created a new instance of the child window inside the parent with no
chrome and placed it perfectly inside.

As i see it, what you need are user controls. Place a Panel in your main
window where you want to place your "child windows". Then just create each
of your mode as a User Control (you'll find that in the Add new item in VS)
and place the apppropriate user control in the main window's panel when the
user click on a button of your toolbar. Easy enough to do.
 
Hi !

Also, take a look at this article
http://www.devexpress.com/?section=/bestpractices/SAP-NET

Note that even though DevExpress components are mentioned, you don't need them at all for using the
framework. That said, I've been working with DevExpress stuff for 4 years in Delphi and can heartly
recommend it :)
I'm creating an applicatoin where I will have a common toolbar, menu, and panel (using one of the free XP-like collapseable panels on the left hand side). The bulk of the UI in my application (to the right of the panel and below the toolbar) will change based on your selections in the toolbar. This is simlar to Outlook where you have a single applicatin, but it's main UI form changes "modes" based on user actions. I could use MDI, but that's not really what I'm trying to accomplish. I could also use multiple panels and hide/show when buttons in the toolbar were clicked, but the main form will get pretty big (which is ok if it's my only option).

Ideally I'd like to develop each "mode" seperately and just load them into the main window when the time comes... not sure if this is feasible (I tired it one time, but with a very convoluted approach >>> I had a main window, then created a new instance of the child window inside the parent with no chrome and placed it perfectly inside.

Thanks in advance for the input.
-AC

Best wishes
Kai Bohli
(e-mail address removed)
Norway
 
Great article...

Using that approach, what I'd like to do is have one of the modules control
or access the toolbar in the main window. This way, when a module was
activated, it could rebuild certain parts of the menu without having to do
this in another class. Possible?

-AC

Kai Bohli said:
Hi !

Also, take a look at this article
http://www.devexpress.com/?section=/bestpractices/SAP-NET

Note that even though DevExpress components are mentioned, you don't need them at all for using the
framework. That said, I've been working with DevExpress stuff for 4 years in Delphi and can heartly
recommend it :)
panel (using one of the free XP-like collapseable panels on the left hand
side). The bulk of the UI in my application (to the right of the panel and
below the toolbar) will change based on your selections in the toolbar.
This is simlar to Outlook where you have a single applicatin, but it's main
UI form changes "modes" based on user actions. I could use MDI, but that's
not really what I'm trying to accomplish. I could also use multiple panels
and hide/show when buttons in the toolbar were clicked, but the main form
will get pretty big (which is ok if it's my only option).into the main window when the time comes... not sure if this is feasible (I
tired it one time, but with a very convoluted approach >>> I had a main
window, then created a new instance of the child window inside the parent
with no chrome and placed it perfectly inside.
 
AC said:
Great article...

Using that approach, what I'd like to do is have one of the modules
control or access the toolbar in the main window. This way, when a
module was activated, it could rebuild certain parts of the menu
without having to do this in another class. Possible?

You could for example pass a reference to your tool bar or your main form to
your user control when you create it. This way, your user control could
modify it itself. You could also have a look at the Parent property of your
user control. You could maybe do something with that.

However, i would rather not try to modify a user control's container from
the user control. This would break your code if you want latter to use your
module in another application that has a different user interface. My
approach would be to have a manager class in charge of creating of managing
all your modules (this manager class could be simply your main form class).
This manager class would be in charge of modifying your tool bar in regards
to which module is displayed. If a module needs to modify your main form's
menus, tool bars or status bar at some stage, expose events in your module.
The manager will subscribe to those events and handle the main form UI
modification itself. This way, your modules will be totally independant from
where and how they are placed and used. This will also make your code much
more readable as it will be clearly sperarated into different independant
components.
 
Funny... since i posted I just wanted to get it to work so I added some
stuff to the BaseModule class that would essentially allow you to pass a
reference from the main form to the module itself. then the module creates
the buttons on the toolbar on first time the module is fired off

after i got that working, I noticed that it would be better to build a
manager of sorts like you said. So now i'm working on actually rebuilding
the framework from the ground up and using some of the NetXP UI components.

-AC
 
Hi !

Sorry for my late reply. I'm on vacation, and have to sneak in to my computer after my better half
is asleep and at odd days :)

Anyway, I belive the answer to that is yes. If you look at the article, they build a menu up from
scratch when you select the "grid thingy". You can control this stuff in the baseclass or in the
inherited or both. Aka - the framework lets you control which menus, toolbars are visible through
the "register" functions embedded.

I found that I've lost too much control, and decided to use the framework itself, but take controls
of navigation and menus outside of the framework. Anyway, I've got it working and timesaving when
you want to make new forms and load them into the same panel.

BTW - to access a module's public function you'll have to write something like this:

((modModCust)ModuleInfoCollection.Instance[2].Module).PrintScheme();

I've also put in the following code in the "basemodule" so I can reach the mainform (parent) from
any inherited module. (module = usercontrol):
MainForm = ((frmMain)this.FindForm()); // points back to the mother of all form (or usercontrols)
// (or modules)

That way, I can forinstance say something like this from any module.
MainForm.ShowEditButtons();


Great article...

Using that approach, what I'd like to do is have one of the modules control
or access the toolbar in the main window. This way, when a module was
activated, it could rebuild certain parts of the menu without having to do
this in another class. Possible?

Best wishes
Kai Bohli
(e-mail address removed)
Norway
 
Back
Top