CS-360 Course Information
GUI & Windows Programming Office: EB-N6
Phone: 777-4365
Dr. Richard R. Eckert Office Hours: TBA
Computer Science Department Email: reckert@binghamton.edu
SUNY Binghamton http://www.cs.binghamton.edu/~reckert/
Fall, 2003 CS-360 link for syllabus, notes, programs,
assignments, etc.
MWF, 10:50-11:50 A.M. Class Listserv:
LH-13 cs360-l@listserv.binghamton.edu
TA Information: TBA
Text Book Information
Required:
Course Prerequisites Kate Gregory, “Special Edition Visual C++ 6 .NET”
Que, 2002, ISBN 0-7887-2466-9. (For VC++ MFC &
.NET programming with Visual Studio .NET)
CS-220, Computer Organization and Recommended:
Assembling Language Programming Charles Petzold, "Programming Windows," Fifth
Edition, Microsoft Press, 1999, ISBN 1-57231-995-X.
CS-240, Data Structures (For Win32 API)
Kruglinski, Shepherd, Wingo, "Programming Microsoft
Some knowledge of C or C++ helpful
Viausl C++", Fifth Edition, Microsoft Press, 1998,
Not essential ISBN 1-57231-857-0, (For VC++ MFC Programming--
about 50% of course)
Paul E. Kimball, "The X Tookit Cookbook," Prentice
Hall PTR, 1995, ISBN 0-13-973132-6. (For X-
Windows Programming)
Many Books on Reserve
Policies
Evaluation Assignments
Individual
Programming Assignments 45% Due on due date, but can be turned in to CS-360
drop drawer in filing cabinet outside CS
Term Examinations (2) 40% Department any time that day or night
Final Project 15% 5% off for every day late
) Weekends and holidays not included
No assignments accepted more than one week
late
Originality
Any work found to be copied will be grounds
for an F in the course
1
Course Schedule (weekly)
Course Schedule (continued)
1. Intro to GUIs & Windows Programming
2. Using Visual Studio,Win32 API Programming 10. COM, ActiveX, & ATL
3. MFC Programming: App/Window Approach 11. Multitasking & Multithreading; DLLs
4. MFC Programming: Doc/View Approach 12. Network Programming with TCP/IP Sockets;
5. Graphics, Animation, Bitmaps, Timers Creating Web Services
6. Windows Controls, Dialog Boxes 13. .NET Managed Code & the Common Language
7. Printing, Mapping modes, Serialization, File I/O, Runtime
Dialog-based Apps, Windows Common Dialogs 14. Program Integration: Multilanguage Apps,
8. Toolbars & Status Bars; Windows Clipboard; Mixing .NET Managed & Unmanaged Code
Multimedia Programming 15. The X Window System
9. ODBC & ADO Data Bases 16. X Toolkit Intrinsics, OSF/Motif Toolkit
Introduction To GUIs and User Interfaces
Windows Programming
Connection between the computer and
the user
Two types:
Command Line
GUI--Graphical (Visual)
Command Line Interfaces Visual (Graphical) Interfaces
Show graphical objects on screen
User types commands ==> must e.g., images, icons, buttons, scroll bars
remember User interacts using pointing device
Results scroll by Intuitive
Text-based Objects can be dragged, buttons pushed, etc....
“Interactive” but hard to use Better way of using screen space
Panescan overlap
No direct interaction between user and
Underlyingpanes can be brought to forefront
screen Desktop metaphor (like papers on a desk)
) Well, not exactly!
2
Graphical Interfaces, Continued Main Feature of GUIs:
Use graphics to organize user workspace THE WINDOW
Environment allows many tasks to be Rectangular area of screen onto which a
performed simultaneously program draws text and graphics.
Different tasks share screen space User interacts with program using
Visually rich way of conveying information pointer device to select objects inside.
WYSIWYG display of documents Some window components:
) border, title bar, client area, menu bar, tool bars,
scroll bars, max/min/close buttons, etc.
Brief History of GUIs Xerox PARC--Alto Computer
1968: ARPA-funded Stanford Research 1970s
Center (Doug Engelbart)
First GUI
First windows (screen sliced up into
Cursor tracked position of mouse
overlapping panes)
Only textual info WYSIWYG
Underlying windows could be popped to the Windows with precise text
top Displayed more than just text
Selection done with light pen
First interactive painting program
Invented the mouse
Technology “acquired” by Apple
Recent History (PCs)
Recent History (Microsoft)
1977: Radio Shack TRS-80, Commodore Pet,
Apple II 1990: Windows 3.0
1981: IBM PC, DOS 80x86 protected mode, up to 16 Meg memory,
1983: Apple Lisa (failure) cooperative multitasking
1984: Apple Macintosh--standard for GUIs 1992: Windows 3.1, Windows for
1985: Microsoft releases Windows 1.0 Workgroups 3.11
Difficult to program TrueType fonts, multimedia, protected mode
Prone to crashing only; Networking
Needed hardware not yet available 1993: Windows NT
1987: Windows 2.0 (still real mode only) 32-bit flat memory space, 16 MB, thread-based
1988: Windows/386 (Virtual 86 mode on pre-emptive multitasking, separate from DOS,
386==>multiple DOS sessions in windows) multi-platform, networking, secure)
3
Recent History (Microsoft) Other GUI-Windowing Systems
1995: Windows 95 IBM OS/2: Presentation Manager
Runs on 4 Meg, long file names, plug and play, new
controls, new desktop/window style Sun Microsystems: Java
Hybrid 16/32 bit OS, depends on DOS, lacks security of AWT
NT, no portability to RISC
Swing
1998: Windows 98
Integrated Web functionality Platform independent
2000-01: Windows 2000, ME, XP JDK is free
Upgradesof 95-98-NT The X Window System
95->98->Me->XP Home: for home use
Developed at MIT, late 1980s
NT->2000->XP Professional: for businesses
XP: Networked graphics programming interface
) fancier user interface; latest multimedia (DVD); upgraded web Independent of machine architecture/OS (but
& network capabilities; improved help (remote); improved
performance & security most used under UNIX)
Course Content Win32 API Programming
Microsoft Windows Visual C++
Using Microsoft Developer Studio (Visual Event-Driven Programming (Messages)
Studio .NET) Menus and other Resources
Win32 API Programming
Text and Graphics
MFC Programming
Mouse and Keyboard
.NET Managed & Unmanaged Code
Bitmaps, Animation, Timers
Integrating Languages under .NET
Child Window Controls
X-Windows Programming
Example programs and notes online at:
Child and Popup Windows
) http://www.cs.binghamton.edu/~reckert/ Dialog Boxes
) “CS-360” link The Clipboard
MFC Programming Introduction to Windows
The MFC Class Hierarchy Programming in Visual Basic
The Application/Window Approach
The Document/View Approach
A Quick Introduction
Using “AppWizard” & “ClassWizard”
Drawing, Menus, & Dialog Boxes with MFC
File Handling and Printing
Dialog-Based MFC Applications & Common Dialog Boxes
DLLs; Windows Multimedia
Multitasking and Multithreading
COM, ActiveX, ATL
Using Data Bases with ODBC & ADO
Network Programming (TCP/IP)
Web Services using Microsoft IIS
4
Microsoft .NET Framework X-Windows Programming
Unmanaged vs. Managed Code Client/Server Model
Web Services X Display Servers
Integrating with other .NET Languages XLIB Programming
Toolkits and Widgets
XtIntrinsics
OSF/Motif
Windowing Systems Features Consistent User Interface,
Consistent user interface continued
Display within a window
Programs have same look and feel
Menus to initiate program functions
Same built-in logic to:
Make use of child window “controls”:
draw text/graphics
) predefined windows used with main program
window display menus
) examples: buttons, scroll bars, edit controls, receive user input
list boxes, drop-down list boxes, combo controls, dialog boxes, use of mouse
boxes
) Dialog box--popup window containing
several controls
Multitasking Windows Multitasking Features
Cooperative (Windows 3.xx)
Every program acts like a RAM-resident
Programs give up control so others can run
popup Programs coexist with other programs
Programs run “simultaneously” Preemptive (Windows NT, 95, 98, XP)
Each program occupies its own window Thread-based: System timer allocates time
User interacts with program in its window slices to running program threads
User can switch between programs Under both systems, code is moved or
swapped into and out of memory as needed
5
Windows Memory Management
Windows Object Orientation
Older versions: 16-bit, segmented memory
Dictated by processor architecture
A window is handled like a C++ object Hard to program
Hasa user-defined type (Windows class) Newer versions: 32-bit, flat memory model
Instances
of class created at run time Easier to program
Messages sent to windows affect their behavior
As old programs terminate, new ones start
Code swapped into and out of memory
Fragmentation can occur
Windows must consolidate memory space
Moves blocks of code/data continually
Memory Management, continued Static vs. Dynamic Linking
Static Linking
) Code incorporated into executable at link
Programs can share code located in other time
files (Dynamic linking) Dynamic Linking
Code is put into separate modules
) These are loaded at run time
Linker generates relocation information
) Only that info is put into the executable
) Smaller programs
DLL loaded when needed
Relocationinfo used to get DLL function code
as needed
6
Pros/Cons of Dynamic Linking Device Independent Graphics Interface
Windows programs don’t access hardware devices
Smaller programs (code is not in program) directly
DLL can be used by many programs with Make calls to generic functions within the
Windows ‘Graphics Device Interface’ (GDI)
no memory penalty
The GDI translates these into HW commands
Only loaded once!
Updates to DLLs don’t require Program GDI Hardware
recompilation of programs using them
Disadvantage--DLL must be present at run
time ==> no standalone programs
Device Independent Graphics Interface Windows API
May use device drivers (HW control
programs) The interface between an application and
Windows
Program GDI Driver Hardware
A library of functions Windows programs
can call
Thus graphics I/O done in a “standard” way
Several versions
Programs will run unaltered on other HW
Win16 (16 bit apps for Windows 3.xx)
platforms
Win32 (32 bit apps for Windows NT/95 &
successors)
Win32s (patches Win16 to create 32 bit apps
that run under Windows 3.xx)
Classical Win32 API Windows Class-based MFC Windows
programming Programming
Use C to access raw API functions directly
No C++ class library wrappers to hide API Microsoft’s MFC Library
Hard way to go, but most basic Borland’s OWL Library
Faster executables Characteristics:
Provides understanding of how Windows Encapsulatethe API functions into classes
and application program interact Providea logical framework for building
Windows applications
Establishes a firm foundation for MFC
Reusable code
programming
We will try to do both
7
MFC Library
Microsoft’s C++ Interface to Windows API
O-O Approach to Windows Programming
Some 200 classes
API functions encapsulated in the MFC
Classes derived from MFC do grunt work
Just add data/functions to customize app
Provides a uniform application framework
Microsoft Visual C++
Developer Studio IDE
Some MFC Characteristics
3 Windows application development systems
C programs using Win32 API
Reusable code
C++ programs using MFC Compact executables
.NET Framework Class Library & the CLR Faster program development
Some Developer Studio IDE Components But a steep learning curve is required
Text/ResourceEditors
And there is less flexibility
C/C++, Resource Compilers
Linker Programs must be written in C++
Debugger Require the use of classes==>
Wizards
Programmer must know OOP
On-line Help
Microsoft .NET .NET Framework
Platform for developing distributed applications for
What is it? the Internet
A platform to run code on Design Goals:
Provide high degree of language interoperability
A class library of code that can be used from
Provide a managed runtime environment
any language
Provide simple software deployment & versioning
New programming interactive development
Provide high-level code security through code access
environment security & strong type checking
New versions of some programming languages Provide consistent object-oriented programming model
A set of server products Facilitate application communication by using industry
standards such as SOAP & XML
New way of designing & creating applications
Simplify Web application development
that share work between components (local and
distributed over the internet)
8
Components of .NET Common Language Runtime
The .NET Framework Class Library (FCL)` Automatic garbage collection
Organized into namespaces (like packages)
Elimination of memory leaks
Handle things like: Data, IO (simple & file), Windows
& Web Forms, Windows Controls, User Interfaces, Code access security
Drawing, Threading, Exceptions, Networking, Web Simplified versioning
Services, Data Bases, XML, ASP, Security,
Collections, … lots of others Simple & reliable deployment
Common Type System (CTS) Deep cross-language integration & inheritance
Common Language Specification (CLS) Debugging/profiling across different languages
Common Language Runtime (CLR) Performance
Scalability
Compilation in the .NET Framework Some Types of VC++ .NET
Applications
Windows Console applications
Win32 API Applications
MFC applications
MFC ActiveX Control projects
MFC ISAPI projects
ATL, ATL Server, & ATL Server Web projects
Managed C++ applications
Managed C++ Web services
Sequential Programming (Console
Applications) Event-Driven Programming
Standard programming--program solicits Designed to avoid limitations of sequential,
input (polling loop) procedure-driven methodologies
Approach follows a structured sequence of Process user actions (events) as they happen: non-
sequential
events
Program doesn’t solicit input
Example--averaging grades: OS detects an event has happened (e.g.., there’s
Input name input) and sends a message to the program
Input first grade Program then acts on the message
Input second grade Messages can occur in any order
Input third grade, etc.
Calculate average
Output average
9
Sequential vs. Event-Driven Programming
Standard Sequential programming:
Program does something & user responds
Program controls user (the tail wags the dog)
Event-Driven Programming:
Used by Windows
User does something and program responds
User can act at any time
User controls program (the dog wags the tail)
OS really is in control (coordinates message
flow to different applications)
Good for apps with lots of user intervention
10