Application Architecture in Windows Forms 2.0—Application


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

Appl. Architecture Forms

© 2006 Pearson Education, Inc.

Application

An application is anything with an .exe extension that can be started from the Windows shell. However, applications are also provided for directly in Windows Forms by the Application class:

namespace System.Windows.Forms {
 sealed class Application {
 
  // Properties
  public static bool AllowQuit { get; }
  public static string CommonAppDataPath { get; }
  public static RegistryKey 
     CommonAppDataRegistry { get; }
  public static string CompanyName { get; }
  public static CultureInfo 
     CurrentCulture { get; set; }
  public static InputLanguage 
     CurrentInputLanguage { get; set; }
  public static string ExecutablePath { get; }
  public static string LocalUserAppDataPath { get; }
  public static bool MessageLoop { get; }
  public static FormCollection OpenForms { get; } // New
  public static string ProductName { get; }
  public static string ProductVersion { get; }
  public static bool RenderWithVisualStyles { get; } // New
  public static string SafeTopLevelCaptionFormat { get; set; }
  public static string StartupPath { get; }
  public static string UserAppDataPath { get; }
  public static RegistryKey UserAppDataRegistry { get; }
  public static bool UseWaitCursor { get; set; } // New
  public static VisualStyleState VisualStyleState { get; set; } // New
  
  // Methods
  public static void AddMessageFilter(IMessageFilter value);
  public static void DoEvents();
  public static void EnableVisualStyles();
  public static void Exit();
  public static void Exit(CancelEventArgs e); // New
  public static void ExitThread();
  public static bool FilterMessage(ref Message message); // New
  public static ApartmentState OleRequired();
  public static void OnThreadException(Exception t);
  public static void RaiseIdle(EventArgs e); // New
  public static void RegisterMessageLoop(
   MessageLoopCallback callback); // New
  public static void RemoveMessageFilter(IMessageFilter value);
  public static void Restart(); // New
  public static void Run();
  public static void Run(ApplicationContext context);
  public static void Run(Form mainForm);
  public static void SetCompatibleTextRenderingDefault(
   bool defaultValue); // New
  public static bool SetSuspendState(
   PowerState state, bool force, bool disableWakeEvent); // New
  public static void SetUnhandledExceptionMode(
   UnhandledExceptionMode mode); // New
  public static void SetUnhandledExceptionMode(
   UnhandledExceptionMode mode, bool threadScope); // New
  public static void UnregisterMessageLoop();// New
 
  // Events
  public static event EventHandler ApplicationExit;
  public static event EventHandler EnterThreadModal; // New
  public static event EventHandler Idle;
  public static event EventHandler LeaveThreadModal; // New
  public static event ThreadExceptionEventHandler ThreadException;
  public static event EventHandler ThreadExit;
 }
}

Notice that all the members of the Application class are static. Although there is per-application state in Windows Forms, there is no instance of an Application class. Instead, the Application class is a scoping mechanism for exposing the various services that the class provides, including control of application lifetime and support for message handling.


Previous_Page_.gif Next_Page_.gif


Personal tools