Introduction to Windows Programming - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Introduction to Windows Programming

Description:

Introduction to Windows Programming Jim Fawcett CSE 681 Software Modeling and Analysis Fall 2005 References Developing Professional Applications for Windows 95 ... – PowerPoint PPT presentation

Number of Views:196
Avg rating:3.0/5.0
Slides: 27
Provided by: JimFa2
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Windows Programming


1
Introduction to Windows Programming
  • Jim Fawcett
  • CSE 681 Software Modeling and Analysis
  • Fall 2005

2
References
  • Developing Professional Applications for Windows
    95 and NT Using MFC, Marshall Brain and Lance
    Lovett, Prentice Hall, 1997.
  • Now out of print, but some copies still available
    on-line.
  • Practical Visual C 6, Jon Bates and Tim
    Tompkins, Que, 1999.
  • Currently available through Barnes Noble,
    Borders, and Amazon.com.
  • Programming Windows with MFC, Jeff Prosise,
    Microsoft Press, 1999.
  • This is a large, effective book, used in CSE 778
    Advanced Windows Programming, but overkill for
    this course.
  • Windows Forms Programming in C, Chris Sells,
    Addison-Wesley, 2004
  • Comprehensive and very well written.

3
(No Transcript)
4
The Simplest Classical Windows Program
  • Output from the MINWIN program is shown on the
    next slide. The program
  • Creates a frame window
  • Paints a fixed text message in the window
  • Reacts to left mouse button clicks by creating a
    MessageBox
  • You will the program code, minwin.cpp, and
    project workspace, minwin.dsw in the folder
    MINWIN. www.ecs.syr.edu/faculty/fawcett/handouts
    /CoreTechnologies/WindowsProgramming/code/basicWin
    dows/Minwin

5
(No Transcript)
6
(No Transcript)
7
(No Transcript)
8
The Simplest MFC based Program
  • Output from the MFCWIN program is shown on the
    next slide. The program
  • Creates a frame window
  • Paints a fixed text message in the window
  • Reacts to left mouse button clicks by creating a
    MessageBox
  • You will the program code, mfcwin.cpp, and
    project workspace, mfcwin.dsw in the folder
    MINWIN.www.ecs.syr.edu/faculty/fawcett/handouts/
    CoreTechnologies/WindowsProgramming/code/basicWind
    ows/MfcWin

9
(No Transcript)
10
Dialog Based Applications
  • A dialog is an opaque window, called a form, on
    which are embedded a collection of smaller
    windows called controls.
  • The main dialog form is wrapped in a dialog
    class, derived from MFCs CDialog class.
  • Each control is a window with a self contained
    set of functionality that dialog designers use
    as-is, or modify in limited ways.
  • Controls are placed on the dialog form by
    dragging from a palette in the dialog resource
    editor.
  • Controls are hooked into the application
    processing by providing message handlers in the
    main dialog class that access the controls using
    CDialogGetDlgItem() and CDialogSetDlgItem()
    member functions.

11
(No Transcript)
12
Structure of MFC Dialog based Application
13
Frame Window Applications
  • A frame window application consists of a window
    that supports a large client area in which text
    and graphics are displayed, embedded in a frame
    that supports menus and perhaps some controls.
  • All text and drawing in the client area are
    supported by the Graphics Device Interface Object
    (CGDIObject) and Device Context (CDC) classes.
  • Most frame window applications use the Single
    Document Interface (SDI) or Multiple Document
    Interface (MDI) architectures. These follow
    document/view architecture structure
  • Documents provide all the support for managing
    the programs data, including reading and writing
    from persistent storage.
  • Views provide all the support for displaying one
    or more views of the data and most user
    interactions with the program.

14
(No Transcript)
15
(No Transcript)
16
(No Transcript)
17
WinForms
  • WinForms were introduced with .Net and are very
    similar to Visual Basic RAD Forms in Visual
    Studio, version 6.0.
  • Forms are used for both Frame Window and Dialog
    Applications.
  • You get a dialog application by pulling lots of
    controls onto a form and setting the Form
    properties to have dialog behavior.
  • You get a Frame Window by painting the Form your
    self, with the help of the .Net Graphics Device
    Interface (GDI)
  • Forms are quite easy to build with the Visual
    Studio Designers
  • Lots of controls are available in the toolbox
  • Intellisense and the Object Browser make learning
    very fast.

18
Simple Text Editing Demo
  • It is relatively easy to build Forms that
  • open and save files using a FileDialog.
  • Read files from Streams and edit text in a
    TextBox.
  • The Stream and TextBox do almost all the work.
  • Uses menus to interact with files or set program
    behaviours.
  • www.ecs.syr.edu/faculty/fawcett/handouts/CSE681/co
    de/project2HelperF05

19
(No Transcript)
20
Programs with Communicating Forms
  • Often we want to use more than one Form in a
    program.
  • That means that we have to provide a way for them
    to communicate.
  • Each Form that needs to contact another must have
    a reference to it.
  • That happens automatically for the parent. The
    parent creates a Child Form attached to a
    reference it holds onto for later use.
  • For the Child to talk back, the Parent must pass
    it a reference to itself, usually in the Childs
    constructor.
  • For these conversations to be useful, both Parent
    and Child must provide functions for the other to
    call.
  • www.ecs.syr.edu/faculty/fawcett/handouts/CSE681/co
    de/project2HelperF05

21
(No Transcript)
22
An Example Form with
Browse Control
  • If our program needs more than a simple
    FileDialog provides, we may wish to build a more
    sophisticated or specialized control.
  • On the next page you will see an example of a
    Form, written in managed C invoking the
    services of a Browse Control, written in C.
  • www.ecs.syr.edu/faculty/fawcett/handouts/CoreTechn
    ologies/WindowsProgramming/code/demoCppWinForm

23
(No Transcript)
24
Frame Window based on Form
  • The next slide illustrates a WinForm application
    that behaves like a Frame Window
  • It paints is client area with
  • An image
  • A drawn text caption
  • A line
  • But it also has inserted a control, showing mouse
    coordinates. This illustrates that controls can
    be used on Frame Windows
  • They paint their own surfaces
  • They can react to event messages from their
    parent window.
  • www.ecs.syr.edu/faculty/fawcett/handouts/CoreTechn
    ologies/WindowsProgramming/code/CSharpWinForm

25
(No Transcript)
26
End of Presentation
Write a Comment
User Comments (0)
About PowerShow.com