![]() |
Languages »
C# »
Windows Forms
Intermediate
Tiny WinForms Application Framework - JujuBy Väinölä HarriTiny WinForms Application Framework - Juju |
C#, Windows, .NET 1.1VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Many times customer says 'we need Windows application which works like browser�. This article describes how to make WinForms Application which mimics a Browser. Because Tiny WinForms Application Framework is so long a name, I have called it JUJU.
When you start to build a new Windows Application and it�s layout looks like Browser, include these files to our project and start to create the new Forms. You can jump from any form to another and the framework remembers how to go backwards or forwards. There is one main class that handles the behaviour of Browser. It is called AppManager (Application Manager). Every time when you create a new Form, and you want to create it to the same stack as previous form, you must create the new form via AppManager, example.
AppManager.Show (new Form1, ��) //new stack, no arguments
AppManager.Show (new Forms, this, arguments) //same stack, with arguments
Every Form has it�s own FormManager class, where you can hide all public events which are common to all Forms. FormManager takes care of usual Form events and it discuss with AppManager.
Main function is Start and it is the place where you initialize AppManager. AppManager glues all windows together with a Double Linked List, see code.
public class Start
{
public Start() {}
[STAThread]
static void Main() {
AppManager.Show(new Home(), "");
Application.Run();
}
}
Expand your Form with your own common interface IForm.
public class Form1 : System.Windows.Forms.Form, IForm{..}
Add FormManager class to every Form which must have Browser like behaviour. FormManager class takes care of usual tasks which the Form must to do. It initialize Toolbars, Event Handler etc. After that you can concentrate real work, designing WinForms. Every common event is circulated via this class.
publicForm1() {
InitializeComponent();
FormManager frmManager = new FormManager( this);
}
Remember also to Implement all IForm functions.
When you want to create new window just call AppManager.Show(...). Every new form inherits properties from previous form (= location, layout). Old Form also send arguments to the new one so that it knows how to initialize data.
AppManager.Show( new Form1(), this, argsOUT);
If the new Form is in the middle of stack when you call function AppManager.Show(..) it removes all the Forms from the right and after that it adds new Form to the end of stack. Previous form is hidden and new form is shown.
publicstatic void Show(Form newForm, Form oldForm, string args) {
Node current = Activate(oldForm);
if (current.Right != null) Remove(current.Right.Value, true);
Node node = new Node(newForm, current, null);
current.Right = node;
nodes.Add(node);
InitForm(newForm, oldForm, args);
ShowHide(newForm, oldForm);
current = null;
}
If you have any ideas how to develop this idea don�t hesitate to contact me, dathava@jippii.fi. I would be pleased if someone can give me me ideas how to develop this idea further. Maybe there are better ways how to handle events. So if you invent any new features, let me know. Juju means a trick in Finnish.
Common Keyboard and Menu handlers.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 23 Dec 2003 Editor: Nishant Sivakumar |
Copyright 2003 by Väinölä Harri Everything else Copyright © CodeProject, 1999-2009 Web10 | Advertise on the Code Project |