all groups > dotnet windows forms > november 2007 >
You're in the

dotnet windows forms

group:

Windows app without a master window


Windows app without a master window Harlan Messinger
11/14/2007 11:58:44 AM
dotnet windows forms:
I've set up a Windows app in C# for working with a type of document I've
designed. When I use my app's File | Open menu item, after presenting
the Open Files dialog it opens my selected file in a new window, which
is of the same type as the app's main window.

Now, when I have several documents open, as in Microsoft Word, I should
be able to close any one of them without the app shutting down until all
the document windows have been closed. And this is what happens--except
when I close the original window. Doing that, of course, shuts down the
application, since this is the window referenced in the application's
message loop.

How do I structure the application so that it opens a window initially,
as Word does, but without giving that one window sole control over the
Re: Windows app without a master window Harlan Messinger
11/15/2007 10:38:16 AM
[quoted text, click to view]

I think I figured it out, assuming this is the *correct* way. Replace

Application.Run(new ProjectWindow());

with

(new ProjectWindow()).Show();
Application.Run();

and set up my own singleton window manager that the first ProjectWindow
will cause to be instantiated and that will call Application.Exit() when
Re: Windows app without a master window bryan
11/15/2007 10:41:06 AM
Two thoughts...

Make another hidden window the application window and open an instance of
your document window automatically at start up.

Use MDI and have all the documents open up in MDI child windows. Can close
any child window (document) you want, or all of them when you close the main
window (this is how Word works)

[quoted text, click to view]

AddThis Social Bookmark Button