CSC300 Visual Programming Dr. Craig Reinhart

Download Report

Transcript CSC300 Visual Programming Dr. Craig Reinhart

CSC300
Visual Programming
Dr. Craig Reinhart
Objectives
• Teach the basics of C++
– You won’t be an expert but hopefully a very
good novice
– GUI development
• Lots of aspects to this (similar to Swing in Java)
Introduction to Visual C++
Chapter 1
The .NET Framework
• The .NET framework is part of the Windows®
operating system
• Consists of
– Common Language Runtime environment
– .NET Framework libraries
• Programming language agnostic
– C++, C#, Visual Basic
• We will be using C++
C++ in Visual Studio 2005
• Two modes
– Native – programs run directly on the CPU
• Microsoft Foundation Classes (object oriented)
• Windows API (more like C than C++)
• Applications are unmanaged (programmer responsible for
dynamic memory deallocation)
– CLR – programs run in a virtual environment (like Java)
• Windows Forms from the .NET framework
• Applications are managed (garbage collector)
• We will look at all but, realistically it won’t make a world
of difference so our concentration will be on MFC
(object oriented)
Common Language Runtime
• Implements a standard known as “C++/CLI”
– C++ Common Language Infrastructure
– This is similar to the Java virtual machine
– “standard” means
• Programs can easily implemented making C++ programs
portable across architectures and operating systems
• Programs of different languages (C++, C#, VB) can be easily
combined into a single application
• Applications can exercise a high degree of security
• Microsoft C++, C#, and VB programs compile into
MicroSoft Intermediate Language (MSIL)
– Similar to Java byte code
Lay of the Land
Managed C++
Native C++
Native C++
.NET framework
MFC
CLR
Operating System
Hardware
Windows (visual) programming
• Programs are typically (should be!) divided
into two parts
– The Graphical User Interface (GUI)
• You will get lots of help from the Visual Studio 2005
development environment with this part
– The business logic
• You’ll have to write this part yourself
• Why should we divide a program like this?
– Because doing so allows us to change the GUI
without changing the business logic (portability)
C++
• Looks syntactically similar to Java
– This can be either good or bad
• ISO/IEC 14882 standard defines C++
– If you adhere to the standard your code will compile on any
compiler
– In general, your business logic should adhere to the
standard
• There is no generally accepted GUI standard
– There are some cross platform APIs (OPENGL, JUCE, FTK,
others)
– C++/CLI extends the ISO standard to include support for the
.NET framework
– MFC is an add-on library and therefore not standard
Two user interface modes of C++
• Console applications
–
–
–
–
–
These are simple command line UI applications
Concentration is on the business logic
Smaller, faster, easy to write
Good for developing algorithms
Typically single threaded, deterministic,
synchronous execution
• GUI applications
– More or less the opposite of the above
Visual Studio 2005
• Integrated Development Environment
– Similar (in function) to Eclipse or NetBeans for
Java
– Unlike Java (Swing, AWT) it’s virtually impossible
to develop a C++ GUI based application without
an IDE
– Editor, compiler, linker, librarian, debugger, source
code repository, and more…
• I can supply you with a copy of Visual Studio
2005
Visual Studio 2005 notes
• Object (.OBJ) files have nothing to do with
object oriented programming
• Visual Studio 2005 is not backwards
compatible with previous versions of Visual
Studio (2003, 2002, .NET, …)
• When you create your projects pay very close
attention to what you are doing
– If you make a mistake you will have to start over –
it’s virtually impossible [for a beginner] to change
some things
Let’s try it
• Console applications (pages 13 – 27)
– Native mode, pre-defined version
– Native mode, programmer-defined version
(empty project)
– CLR mode, pre-defined version
• GUI applications (pages 28 – 36)
– Native mode, MFC
– Managed mode, CLR
Homework assignment
• Install Visual Studio 2005 on your personal computer
• Recreate all projects from pages 13 – 36 on your
computer
• Turn in a [short] write-up describing the experiences
including
–
–
–
–
Failures
Successes
Unresolved issues
Resolved issues
• Due beginning of next class meeting