1 / 52

Microsoft VB 2005: Reloaded, Advanced

Microsoft VB 2005: Reloaded, Advanced. Chapter 6 More about Windows Forms. Objectives. Understand program code generated by Visual Basic for user interfaces Create a user interface with a flow layout and a table layout Create a user interface with tabbed pages and dialog forms

denzel
Download Presentation

Microsoft VB 2005: Reloaded, Advanced

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Microsoft VB 2005: Reloaded, Advanced Chapter 6 More about Windows Forms

  2. Objectives • Understand program code generated by Visual Basic for user interfaces • Create a user interface with a flow layout and a table layout • Create a user interface with tabbed pages and dialog forms • Create a user interface with a menu and shortcut keys • Create an application with a multiple document interface (MDI) Microsoft VB 2005: Reloaded, Advanced

  3. A Closer Look at GUIs • Objective • Understand the code generated by Visual Basic as you build a GUI Microsoft VB 2005: Reloaded, Advanced

  4. Forms and Components • Form • Window or dialog box that makes up an application’s graphical user interface • Instance of the class System.Windows.Forms.Form • Component • Object that is added to a form to provide functionality • Control • Visible component derived from the Control class Microsoft VB 2005: Reloaded, Advanced

  5. The Event-Handling Model • Event • A message indicating that a user action has occurred • Event-driven applications • GUIs generate events (via user actions) that drive the application’s functionality • Event-handlers • Methods written by the programmer to provide the application with the desired responses to events • Visual Basic uses a MulticastDelegate object to implement event handling Microsoft VB 2005: Reloaded, Advanced

  6. The Event-Handling Model (continued) • Delegate • An instance of the Delegate class • Delegate class • Data structure that refers to either: • A static method • A class instance and an instance method of that class • An event generated by a GUI calls a delegate that is registered for that event • Delegate in turn calls all methods (static methods or instance methods) that it references Microsoft VB 2005: Reloaded, Advanced

  7. Visual Basic Generated Code for GUIs • When you create a GUI using the Visual Basic Form Designer • Visual Basic generates the required program code in the Code window • View code by right-clicking the open space in the Windows Form Designer, outside the form • And then clicking View Code • Details of the code for the GUI are hidden from view • Figure 6.3 shows the code generated by Windows Form Designer Microsoft VB 2005: Reloaded, Advanced

  8. Visual Basic Generated Code for GUIs (continued) Microsoft VB 2005: Reloaded, Advanced

  9. Visual Basic Generated Code for GUIs (continued) Microsoft VB 2005: Reloaded, Advanced

  10. Enhancing a GUI’s Appearance and Functionality • Objective • Learn tips for enhancing Windows application forms Microsoft VB 2005: Reloaded, Advanced

  11. Form Startup Location • By default, a form will appear at the Windows default location • Near the upper-left corner of the screen Microsoft VB 2005: Reloaded, Advanced

  12. Form Startup Location (continued) Microsoft VB 2005: Reloaded, Advanced

  13. Making a Form Scrollable • A form may contain more controls than will fit within the boundaries of the form • You can make your form scrollable with scroll bars that appear only when necessary • Select True for the Autoscroll property value Microsoft VB 2005: Reloaded, Advanced

  14. Making a Form Scrollable (continued) Microsoft VB 2005: Reloaded, Advanced

  15. Making a Form Scrollable (continued) Microsoft VB 2005: Reloaded, Advanced

  16. Making a Form Scrollable (continued) Microsoft VB 2005: Reloaded, Advanced

  17. The FlowLayoutPanel Control Microsoft VB 2005: Reloaded, Advanced

  18. The FlowLayoutPanel Control (continued) Microsoft VB 2005: Reloaded, Advanced

  19. The Margin and Padding Properties • Margin property • Determines the amount of space, in pixels, reserved around a control • When calculating its automatic position in a FlowLayoutPanel • Padding property • Determines the amount of space, in pixels, reserved along the inside of containers Microsoft VB 2005: Reloaded, Advanced

  20. The Margin and Padding Properties (continued) Microsoft VB 2005: Reloaded, Advanced

  21. The TableLayoutPanel Control • Allows you to create a rectangular grid of rows and columns in which other controls can be placed • Helps maintain an organized appearance for the form Microsoft VB 2005: Reloaded, Advanced

  22. The TableLayoutPanel Control (continued) Microsoft VB 2005: Reloaded, Advanced

  23. The TableLayoutPanel Control (continued) Microsoft VB 2005: Reloaded, Advanced

  24. The TableLayoutPanel Control (continued) Microsoft VB 2005: Reloaded, Advanced

  25. The TableLayoutPanel Control (continued) Microsoft VB 2005: Reloaded, Advanced

  26. The TabControl Control • Allows you to create a form with several related tabbed pages • Can consist of two or more TabPage controls, each of which can contain various other controls Microsoft VB 2005: Reloaded, Advanced

  27. The TabControl Control (continued) Microsoft VB 2005: Reloaded, Advanced

  28. The TabControl Control (continued) Microsoft VB 2005: Reloaded, Advanced

  29. Dialog Forms • Dialog form • Modal form that can return standard results using the DialogResult property • Convenient way of getting quick standard responses • Displayed using the ShowDialog method • Modal form • Requires the user to close the form before activating another window in the application • Modeless form • Does not have this requirement Microsoft VB 2005: Reloaded, Advanced

  30. Dialog Forms (continued) Microsoft VB 2005: Reloaded, Advanced

  31. Menus • One of the best ways of organizing a larger number of commands is with menus Microsoft VB 2005: Reloaded, Advanced

  32. About Menus • Menu • List of items that specify options or groups of options for an application • Menu items • Represent the individual menu commands in a menu • A menu item can be a parent menu for other submenu items • Shortcut key • Single key or a combination of keys that the user can press to execute a menu item Microsoft VB 2005: Reloaded, Advanced

  33. Implementing Menus • Adding a menu • With an empty form displayed in the Designer • Drag a MenuStrip control from the Toolbox to any part in the form • Adding a menu item • See Figure 6.24 Microsoft VB 2005: Reloaded, Advanced

  34. Implementing Menus (continued) Microsoft VB 2005: Reloaded, Advanced

  35. Implementing Menus (continued) Microsoft VB 2005: Reloaded, Advanced

  36. Implementing Menus (continued) • Adding shortcut keys • See Figure 6.26 and Figure 6.27 • Adding functionality to menu items • See Figure 6.29 Microsoft VB 2005: Reloaded, Advanced

  37. Implementing Menus (continued) Microsoft VB 2005: Reloaded, Advanced

  38. Implementing Menus (continued) Microsoft VB 2005: Reloaded, Advanced

  39. Multiple-Document-Interface Windows • Single-document-interface (SDI) applications • Applications that support only one open window or document at a time • Multiple-document-interface (MDI) applications • Allow many documents to be open at once • Allow the user to easily move from document to document • The application window of an MDI program is called the parent window • Each window in application is called a child window Microsoft VB 2005: Reloaded, Advanced

  40. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  41. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  42. Multiple-Document-Interface Windows (continued) • Example • Birthday application Microsoft VB 2005: Reloaded, Advanced

  43. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  44. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  45. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  46. Multiple-Document-Interface Windows (continued) • Properties, methods, and events associated with MDI forms • See Table 6.1 Microsoft VB 2005: Reloaded, Advanced

  47. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  48. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  49. Multiple-Document-Interface Windows (continued) Microsoft VB 2005: Reloaded, Advanced

  50. Summary • A form is a graphical element that appears on the screen • A component is an object that ultimately derives much of its functionality from the Component class • When a user interacts with a control by using the mouse or the keyboard • The control raises an event within the application • When you create a GUI using the Visual Basic Form Designer • Visual Basic generates the required program code in the Code window Microsoft VB 2005: Reloaded, Advanced

More Related