Introduction to Windows Programming. Contrasting Windows and Console Applications Console...

6
Introduction to Windows Programming

Transcript of Introduction to Windows Programming. Contrasting Windows and Console Applications Console...

Page 1: Introduction to Windows Programming. Contrasting Windows and Console Applications Console applications – Each line in Main( ) executed sequentially –

Introduction to Windows Programming

Page 2: Introduction to Windows Programming. Contrasting Windows and Console Applications Console applications – Each line in Main( ) executed sequentially –

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

Page 3: Introduction to Windows Programming. Contrasting Windows and Console Applications Console applications – Each line in Main( ) executed sequentially –

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.)

Page 4: Introduction to Windows Programming. Contrasting Windows and Console Applications Console applications – Each line in Main( ) executed sequentially –

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

Page 5: Introduction to Windows Programming. Contrasting Windows and Console Applications Console applications – Each line in Main( ) executed sequentially –

Windows Application

Windows-based form

Output generated

from Windows

application

Graphical user interface (GUI)

Page 6: Introduction to Windows Programming. Contrasting Windows and Console Applications Console applications – Each line in Main( ) executed sequentially –

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.