Microsoft VB 2005: Reloaded, Advanced - PowerPoint PPT Presentation

1 / 52
About This Presentation
Title:

Microsoft VB 2005: Reloaded, Advanced

Description:

Select True for the Autoscroll property value. Microsoft VB 2005: Reloaded, Advanced ... AutoScroll property. FlowLayoutPanel control. Margin and Padding properties ... – PowerPoint PPT presentation

Number of Views:53
Avg rating:3.0/5.0
Slides: 53
Provided by: ftpC
Category:

less

Transcript and Presenter's Notes

Title: Microsoft VB 2005: Reloaded, Advanced


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)

3
A Closer Look at GUIs
  • Objective
  • Understand the code generated by Visual Basic as
    you build a GUI

4
Forms and Components
  • Form
  • Window or dialog box that makes up an
    applications 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

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 applications 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

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

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

8
Visual Basic Generated Code for GUIs (continued)
9
Visual Basic Generated Code for GUIs (continued)
10
Enhancing a GUIs Appearance and Functionality
  • Objective
  • Learn tips for enhancing Windows application forms

11
Form Startup Location
  • By default, a form will appear at the Windows
    default location
  • Near the upper-left corner of the screen

12
Form Startup Location (continued)
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

14
Making a Form Scrollable (continued)
15
Making a Form Scrollable (continued)
16
Making a Form Scrollable (continued)
17
The FlowLayoutPanel Control
18
The FlowLayoutPanel Control (continued)
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

20
The Margin and Padding Properties (continued)
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

22
The TableLayoutPanel Control (continued)
23
The TableLayoutPanel Control (continued)
24
The TableLayoutPanel Control (continued)
25
The TableLayoutPanel Control (continued)
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

27
The TabControl Control (continued)
28
The TabControl Control (continued)
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

30
Dialog Forms (continued)
31
Menus
  • One of the best ways of organizing a larger
    number of commands is with menus

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

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

34
Implementing Menus (continued)
35
Implementing Menus (continued)
36
Implementing Menus (continued)
  • Adding shortcut keys
  • See Figure 6.26 and Figure 6.27
  • Adding functionality to menu items
  • See Figure 6.29

37
Implementing Menus (continued)
38
Implementing Menus (continued)
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

40
Multiple-Document-Interface Windows (continued)
41
Multiple-Document-Interface Windows (continued)
42
Multiple-Document-Interface Windows (continued)
  • Example
  • Birthday application

43
Multiple-Document-Interface Windows (continued)
44
Multiple-Document-Interface Windows (continued)
45
Multiple-Document-Interface Windows (continued)
46
Multiple-Document-Interface Windows (continued)
  • Properties, methods, and events associated with
    MDI forms
  • See Table 6.1

47
Multiple-Document-Interface Windows (continued)
48
Multiple-Document-Interface Windows (continued)
49
Multiple-Document-Interface Windows (continued)
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

51
Summary (continued)
  • Enhancing GUIs
  • StartPosition property
  • AutoScroll property
  • FlowLayoutPanel control
  • Margin and Padding properties
  • TableLayoutPanel control
  • TabControl control
  • A dialog form is a modal form that can return
    standard results using the DialogResult property

52
Summary (continued)
  • A menu is a component of the MenuStrip class that
    represents the container for the menu structure
    of a form
  • A menu contains menu items
  • All menu items can have key shortcuts (or hot
    keys)
  • MDI applications allow many documents to be
    opened at once
Write a Comment
User Comments (0)
About PowerShow.com