Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2006

Tip: Looking for answers? Try searching our database.

NON-MDI application that keeps track of open windows

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Brian Sokolnicki - 15 Jun 2006 16:14 GMT
I need to write a non-mdi winforms application using c# and .net framework
2.0 that keeps track of open windows and binds to a control on the main
application or shell.  I can't use a MDI application becuase I need the
application to support dual monitors where I can have multiple windows open
on both screens.

Any suggestion on how I can accomplish this.

Thanks.
Mehdi - 15 Jun 2006 16:43 GMT
> I need to write a non-mdi winforms application using c# and .net framework
> 2.0 that keeps track of open windows and binds to a control on the main
[quoted text clipped - 3 lines]
>
> Any suggestion on how I can accomplish this.

There are several possibilties. One of them would be to create a class
deriving from Form which would have a static property returning the list of
windows (forms) of your application. The constructor of this class would
add itself to this static list of windows. Then, whenever you create a new
Form in your application, derive from your custom Form class instead of
using the standard .NET Form class so that each time you instanciate a new
window, it automatically adds itself to the list of windows of your
application.
Linda Liu [MSFT] - 16 Jun 2006 07:04 GMT
Hi Brian,

Thank you for posting.

I think the solution of Mehdi is good. What I want to supplement to the
Mehdi's solution is that you should remove the form instance from the
static list of forms when the form instance is closed.

Here is a sample for you.
// the BaseForm is a base class for all other form classes in the project
public partial class BaseForm : Form
   {
       public BaseForm()
       {
           InitializeComponent();
           _InstanceList.Add(this);
       }    

       private void BaseForm_FormClosed(object sender, FormClosedEventArgs
e)
       {
           _InstanceList.Remove(this);
       }

       private static Collection<BaseForm> _InstanceList = new
Collection<BaseForm>();
       public static Collection<BaseForm> InstanceList
       {
           get { return _InstanceList; }
       }      
   }

If there's anything unclear, don't hesitate to get in touch. I look forward
to your reply.

Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.