introduction to windows programming. contrasting windows and console applications console...
TRANSCRIPT
Introduction to Windows Programming
Contrasting Windows and Console Applications
• Console applications– Each line in Main( ) executed sequentially – then the
program halts
• Windows applications– Once launched, sits and waits for an event– Sits in a process loop
• Event: notification from operating system that an action, such as the user clicking the mouse or pressing a key, has occurred – Write event-handler methods for Windows apps
Graphical User Interface
• Windows applications also look different from console applications
• Interface: front end of a program– Visual image you see when you run a program – Graphical user interface (GUI)
• Graphical user interface (GUI) includes:– Menus– Text in many different colors and sizes– Other controls (pictures, buttons, etc.)
using System.Windows.Forms; namespace WindowsApp{ public class Form1 : Form { public Form1( ) { Text = "Simple Windows Application"; } static void Main( ) { Form1 winForm = new Form1( ); Application.Run(winForm); } }}
Constructor
Base class
Starts process
loop
Windows Application
Windows-based form
Output generated
from Windows
application
Graphical user interface (GUI)
The Concept
For Windows programming, Visual Studio presents you with two development Windows:
1. Graphical Design Window – for the user interface You select, drag and drop visual artifacts such textboxes, buttons, etc. from the Toolbox pane onto the Designer Canvas. Visual Studio automatically generates the code for these artifacts.
2. Program Code Window – for the program which reacts to a user interacting with the artifacts in the Design Window, e.g. a user clicking a button.