Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Showing a form
Message
 
 
To
05/05/2004 17:47:43
General information
Forum:
ASP.NET
Category:
Mobile development
Title:
Miscellaneous
Thread ID:
00901256
Message ID:
00901478
Views:
17
Thanks Bonnie

That's easier than I thought.

John

>John,
>
>A FormsHandler really isn't too much work. This is code I've posted before (I didn't bother searching for the message number, it was easier for me to just post it again).
>First the FormsHandler class. Notice the static methods.
>
>using System;
>using System.Collections;
>using System.Windows.Forms;
>
>namespace MyNameSpace.MyClasses
>{
>	public class FormsHandler
>	{
>		#region Declarations
>		private static ArrayList list = new ArrayList();
>		#endregion
>
>		#region Methods
>		public static int Add(object o)
>		{
>			return list.Add(o);
>		}
>		public static void Remove(object o)
>		{
>			list.Remove(o);
>		}
>		public static bool Close()
>		{
>			int nCount = list.Count;
>			while (list.Count > 0)
>			{
>				((Form)list[0]).Close();
>				if (list.Count == nCount)
>					return false;
>				else
>					nCount = list.Count;
>			}
>
>			return true;
>		}
>		#endregion
>
>		#region Properties
>		public static ArrayList List
>		{
>			get {return list;}
>		}
>		#endregion
>	}
>}
>
>Whenever you open a form, no matter where you open it from, all you do is add it to the ArrayList, like this: (you would need something a bit different, since you need to check for the previous existence of the form ... as I said, this is taken from code I've previously posted).
>
>Form oForm = new MyForm();
>FormsHandler.Add(oForm);
>oForm.Show();
>
>When you close your Main Form, you want all other's to Close (but to execute their own Closing methods) ... do it like this:
>
>// This is a menu item that exits the application
>
>private void menuItem4_Click(object sender, System.EventArgs e)
>{
>	System.ComponentModel.CancelEventArgs ee = new CancelEventArgs();
>	this.ClosingHandler(sender, ee);
>}
>
>// This is the ClosingHandler that will execute normally if you close the app
>// by clicking on the "X"
>
>private void ClosingHandler(object sender, System.ComponentModel.CancelEventArgs e)
>{
>	if (!FormsHandler.Close())
>		e.Cancel = true;
>	else
>		Application.Exit();
>}
>
>
>
>The only difference is that you'd add another static method that would check the ArrayList to see if the form was already there and so you'd use slightly different code from what I've posted to open your forms.
>
>Anyway, hope this helps someone. =)
>
>~~Bonnie
>
>
>
>>Hi Bonnie
>>
>>I was hoping there would be an easier way. This is my first C# project and my first time I have developed for the Pocket PC. I think I will just set the forms to close instead of minimize except the main one with the menu on.
>>
>>Thanks
>>
>>John
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform