UE CS 350 - CS 350: Computer/Human Interaction Lecture 06 Overview

Unformatted text preview:

CS 350 Computer Human Interaction Lecture 06 Overview Event driven programming Visual Basic form designer Visual Basic event handlers Visual Basic form elements Visual Basic code elements References VBMS VBCL September 15 2009 CS 350 Lecture 06 1 CS 350 Computer Human Interaction Window Management Several ways to organize Each application could be responsible for its own windows Not efficient Operating system manages windows E g Windows old MacOS Separate management server e g X Windows Generic across operating systems e g Unix MacOS X WIMP interface Window Icons Menus Pointers Abstract actual hardware into notions of screen keyboard and mouse Device driver translates abstract commands into actual hardware commands USB has become a meta abstraction for many peripherals September 15 2009 CS 350 Lecture 06 CS 350 Lecture 06 Read evaluation loop Win 3 1 old MacOS Client maintains a queue of interaction events Server notices events and places them on client foreground process queue Client handles events in queue order Loop event getEvent Select on event type Case type1 do type1 processing Case type2 do type2 processing End Loop 3 September 15 2009 CS 350 Lecture 06 Application Register Each program registers a handler for events it is interested in E g keypress mouse click mouse move Wait for notify Server Receive Event Handlers also are called call back functions Send to appropriate handler Handler1 CS 350 Lecture 06 4 CS 350 Computer Human Interaction Notification based Win MacOS X X Java GUI programs September 15 2009 2 CS 350 Computer Human Interaction Read Eval Loop CS 350 Computer Human Interaction Event Driven Processing Generally client server architecture often network based September 15 2009 CS 350 Computer Human Interaction Windowing Systems 5 September 15 2009 Handler2 Handler3 CS 350 Lecture 06 6 CS 350 Computer Human Interaction In class Exercise 1 Download Pizza1 3 zip from course website to local storage File unzips into 3 folders September 15 2009 CS 350 Lecture 06 7 CS 350 Computer Human Interaction Starting Visual Basic Starts with the default main form named Form1 with programmer code stored in file named Form1 vb Starts with designer view Get code view by right clicking in Solution Explorer Also creates file Form1 Designer vb that stores automatically generated designer code File does not show up in Solution Explorer Can open it explicitly September 15 2009 CS 350 Lecture 06 9 CS 350 Computer Human Interaction Properties CS 350 Computer Human Interaction Starting Visual Basic Due to network security features cannot run a program from the network drive at UE so create projects on local C drive or on removable storage File New Project under Project Types choose Other Languages Visual Basic under Templates choose Windows Form Application September 15 2009 CS 350 Lecture 06 CS 350 Computer Human Interaction Designer Generated Code Application is a class that inherits from System Windows Forms Form One instance is created when program is run Form elements are Friend data members of application class Generated code creates form elements initializes properties and registers handlers for events September 15 2009 CS 350 Lecture 06 Property is anything that can be initialized during element creation Appearance BackColor ForeColor BorderStyle Font Text Scrollbars etc View Other Windows Properties Window to see properties Behavior Multiline ReadOnly TabIndex TabStop etc Click on Form1 vb in Solution Explorer to change file name in properties window This also changes the main form object s name to match Layout Size Location etc Accessibility Window style etc CS 350 Lecture 06 11 10 CS 350 Computer Human Interaction Properties September 15 2009 8 September 15 2009 CS 350 Lecture 06 12 CS 350 Computer Human Interaction Getting Started Design interface first Every GUI application has a base form Drop interface elements from a toolbox using the form designer Pull on the handles to set size of element Drag to place element CS 350 Lecture 06 13 Default handlers when double clicking element in designer Command buttons Click Radio buttons ClickChanged Checkboxes ClickChanged Textboxes TextChanged Forms FormLoaded CS 350 Lecture 06 15 CS 350 Computer Human Interaction VB Coding Notes Stub for handler is automatically generated as a private subroutine of the application class in form s code file September 15 2009 Not case sensitive auto capitalization Comments start with single quote All statements must be one line Use underscore to continue on next line Variable declarations are CS 350 Lecture 06 14 CS 350 Computer Human Interaction Basic Form Elements Look at Pizza1 project Labels Text is what the label displays also used to display images generally no interaction Textboxes single and multiline text with or without scrollbars Text is value entered Command buttons Text is the button label can also have image as label All form elements are friends by default so can access any property using dot notation September 15 2009 Framework for adding handlers is automatically generated when interface element is double clicked in the designer Private Sub Submit Click ByVal sender As System Object ByVal e As System EventArgs Handles Submit Click Handler code goes here End Sub CS 350 Computer Human Interaction Adding Handlers Set properties especially rename important elements to something meaningful under Design September 15 2009 CS 350 Computer Human Interaction Adding Handlers September 15 2009 CS 350 Lecture 06 16 CS 350 Computer Human Interaction VB Coding Notes vbCrLf is a defined constant VB string for carriage return and linefeed Me is the application object reference Me Dispose deletes the object thus program terminates Dim name As type init value String concatenation operator is or No semicolons If Then ElseIf Then Else End If September 15 2009 CS 350 Lecture 06 17 September 15 2009 CS 350 Lecture 06 18 CS 350 Computer Human Interaction Message Boxes Message boxes are a separate pop up window for short messages Look at Pizza2 project Radio buttons radio buttons grouped together are tied together Type controls icon style and buttons E g MsgBox message type title CS 350 Computer Human Interaction Selection Elements vbExclamation vbCritical vbOKOnly default vbAbortRetryIgnore Added together to combine vbQuestion vbOkCancel Check boxes Returns value of button clicked E g Checked is Boolean property Text is the button label also has Checked property Text is the box label vbOK vbCancel


View Full Document

UE CS 350 - CS 350: Computer/Human Interaction Lecture 06 Overview

Download CS 350: Computer/Human Interaction Lecture 06 Overview
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CS 350: Computer/Human Interaction Lecture 06 Overview and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CS 350: Computer/Human Interaction Lecture 06 Overview 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?