CHAPTER 19 BUILDING A BETTER WINDOW WITH (Web design programs)
Thursday, May 22nd, 2008CHAPTER 19 BUILDING A BETTER WINDOW WITH SYSTEM.610 STEM.WINDOWS.FORMS Figure 19-2. Reading attributes via the Application type // Some attributes regarding this assembly. [assembly:AssemblyCompany(”Intertech Training”)] [assembly:AssemblyProduct(”A Better Window”)] [assembly:AssemblyVersion(”1.1.0.0″)] namespace MyWindowsApp { … } Rather than manually reflecting over the [AssemblyCompany] and [AssemblyProduct] attributes using the techniques illustrated in Chapter 12, the Application class will do so automatically using various static properties. To illustrate, implement the default constructor of MainForm as so: public class MainWindow : Form { public MainWindow() { MessageBox.Show(Application.ProductName, string.Format(”This app brought to you by {0}”, Application.CompanyName)); } } When you run this application, you ll see amessage box that displays various bits of information (see Figure 19-2). Now, let s equip this Form to respond to the ApplicationExit event. When you wish to respond to events from within aWindows Forms application, you will be happy to find that the same event syntax detailed in Chapter 8 is used to handle GUI-based events. Therefore, if you wish to intercept the static ApplicationExit event, simply register an event handler using the += operator: public class MainForm : Form { public MainForm() { … // Intercept the ApplicationExit event. Application.ApplicationExit += new EventHandler(MainWindow_OnExit); } private void MainWindow_OnExit(object sender, EventArgs evArgs) { MessageBox.Show(string.Format(”Form version {0} has terminated.”, Application.ProductVersion)); } }
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.