Chapter 3 The mouse and the Keyboard. Getting input from the Mouse.

Slides:



Advertisements
Similar presentations
(MICROSOFT EXCEL). Is a spreadsheet application designed to take advantage of the windows graphical interface MICROSOFT EXCEL.
Advertisements

Intro to Computers!.
Lesson 1 & 2 Review Lesson 1 & 2 Activities (Smart Notebook)
Windows Basics: The Mouse. The Mouse Before you can explore the Desktop and Taskbar, you must know how to use your mouse. Your mouse is a pointing device.
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Using Macros and Visual Basic for Applications (VBA) with Excel
1 Computer Graphics Chapter 2 Input Devices. RM[2]-2 Input Devices Logical Input Devices  Categorized based on functional characteristics.  Each device.
Surrey Libraries Computer Learning Centres Totally New to Computers Computer Basics March 2013 Teaching Script.
Online Calculator Basic Word Processing Skills Computer Keyboard Skills Computer Mouse Skills Basic Computer Terminology Computer Mouse Skills “I really.
Macromedia Flash MX 2004 – Design Professional and Interactivity WORKING WITH SYMBOLS.
Spring 2003 CS 325 Class Notes Page 1 Our Application with Clicks What do we need to display the locations of our clicks 1.An application to act as main.
Chapter 1- Visual Basic Schneider 1 Chapter 1 An Introduction to Computers and Visual Basic.
Chapter 4: Working with Windows Types of Windows –Program Windows –Message Boxes –Dialog Boxes Elements of a Window –Window Panes –Scroll Bars –Menus –Tool.
Week 3 C For Win Lecture :.  Mouse Message  Keyboard Message.
Operating Systems Day 4. Cascade Windows 1.Open one or more windows 2.Right click on task bar 3.Click cascade windows menu item Tile Windows 1.Open one.
Office XP Introductory Concepts and Techniques Windows XP Edition M i c r o s o f t Windows XP Project An Introduction to Windows XP Professional and Office.
Chapter 3 Introduction to Event Handling and Windows Forms Applications.
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Adding Free Text to the Chart. Activating the drawing tool bar Adding Free Text to the Chart, Slide 2Copyright © 2004, Jim Schwab, University of Texas.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 7 Move and Copy.
CIS—100 Chapter 15—Windows Vista 1. Parts of a Window 2.
Sketchify Tutorial Defining Interaction and Logic in Sketchify sketchify.sf.net Željko Obrenović
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
MFC Windows Programming: Document/View Approach More detailed notes at: 360/notes-html/class15.htm.
Exploring Windows and Essential Computing Concepts 1 Windows Desktop u Windows Basics u Icon u Start Button u My Computer u Network Neighborhood u Recycle.
RIGHT Mouse Button Formatting Cut Copy Paste Save LEFT Mouse Button MAIN BUTTON Single clicks Double clicks Drag Highlight.
In this activity, we are going to resize and move a window around the desktop with a mouse. 1Double-click the icon ‘My Computer’ to display its content.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Introduction to Windows Created by Mrs. Leverette.
The parts of a Computer Window
Object Oriented Programming Dr. Ennis-Cole CECS 5100.
Bitmap (Chapter 15).
Moving and Copying Text Instructor: Glenda H. Easter ITSW 1401, Intro to Word Processing.
Visual Basic CDA College Limassol Campus Lecture:Pelekanou Olga Semester C Week - 1.
Chapter2: Drawing a Window. Review: Introducing MFC.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 4 Working with Variables, Constants, Data Types, and Expressions.
Chapter2: Drawing a Window
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
Surrey Libraries Computer Learning Centres Totally New to Computers Computer Basics January 2012 Teaching Script.
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
Windows Basics Computers 1. Windows Desktop What is the desktop? What is the desktop? –On-screen work area on which windows, icons, menus, and dialog.
Windows 95/NT/XP. What is Windows 95/NT/XP n A program that sets up an environment for you to work in on your computer, based on colorful pictures (icons)
Computer Vocabulary Computer
Application software- programs that let you do things What are some computer programs that you or your parents use on the computer?
1 After completing this lesson, you will be able to: Open a file. Navigate through a document. Scroll through a document. Insert text in a document. Select.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
THE PARTS OF A COMPUTER WINDOW. Q1. What does Pointing mean? A.Moving the mouse so the arrow touches an object. Q2. What does Clicking mean? A.Pressing.
A lesson approach © 2011 The McGraw-Hill Companies, Inc. All rights reserved. a lesson approach Microsoft® Word 2010 © 2011 The McGraw-Hill Companies,
Implement User Input Windows Development Fundamentals LESSON 2.4A.
Today We Will Review: Operating Systems (Windows) (week 3 & 4) Starting up MS Windows Desktop and its contents Functions of the desktop components Brain.
Chapter2: Drawing a Window. Drawing with the GDI.
Microsoft ® Office Word 2007 Introduction Reviewing your Documents and Editing Text.
 The clipboard is a temporary storage area  The cut or copy commands place information on the CLIPBOARD  There are two types of clipboards: – System.
COMPUTER INPUT DEVICE Keyboard. Keyboard cont…… Print Screen Print contents of screen Pause/Break Terminate/Interrupt Scroll Lock Modify behavior of the.
Jim Fawcett Derived from a presentation by Dmitri Volper Su ‘2001
Summer 2001 James Amyot Robert Gowans
MANIPULATING TEXT WITHIN AND BETWEEN DOCUMENTS
An Introduction to Computers and Visual Basic
Program and Graphical User Interface Design
The mouse controls the movement of the pointer on your screen.
REVIEW FOR WINDOWS APPLICATIONS TEST ON FRIDAY- SEPT. 7, 2012
Chapter 5 The MFC Collection Classes
Keyboard and mouse in Windows API
An Introduction to Computers and Visual Basic
Courses Tab Press the Courses tab
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/19.
Steps to Build Frame Window Recipe Application
Presentation transcript:

Chapter 3 The mouse and the Keyboard

Getting input from the Mouse

3 Client-Area Mouse Messages Message WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCL K WM_MBUTTONDOW N WM_MBUTTONUP WM_MBUTTONDBLC LK WM_RBUTTONDOWN WM_RBUTTONUP WM_RBUTTONDBLC LK WM_MOUSEMOVE Sent When The left mouse button is pressed The left mouse button is released The left mouse button is double-clicked The middle mouse button is pressed The middle mouse button is released The middle mouse button is double-clicked The right mouse button is pressed The right mouse button is released The right mouse button is double-clicked The cursor is moved over the client area

Client-Area Mouse Messages Messages for Mouse Events WM_LBUTTOND OWN WM_LBUTTONU P WM_MOUSEMO VE When moving When clicking Left button Clicking and Dragging Double clicking WM_MOUSEMO VE WM_LBUTTOND OWN WM_MOUSEMO VE WM_LBUTTONU P WM_MOUSEMO VE WM_LBUTTOND OWN WM_LBUTTONU P WM_LBUTTOND BLCLK WM_LBUTTONU P

5 Client-Area Mouse Messages Message-map macros and Message handlers Message WM_LBUTTONDOWN WM_LBUTTONUP WM_LBUTTONDBLCLK WM_MBUTTONDOWN WM_MBUTTONUP WM_MBUTTONDBLCLK WM_RBUTTONDOWN WM_RBUTTONUP WM_RBUTTONDBLCLK WM_MOUSEMOVE Message-Map Macro ON_WM_LBUTTONDOWN() ON_WM_LBUTTONUP() ON_WM_LBUTTONDBLCLK () ON_WM_MBUTTONDOWN() ON_WM_MBUTTONUP() ON_WM_MBUTTONDBLCL K() ON_WM_RBUTTONDOWN() ON_WM_RBUTTONUP() ON_WM_RBUTTONDBLCL K() ON_WM_MOUSEMOVE() Handling function OnLButtonDown OnLButtonUp OnLButtonDblClk OnMButtonDown OnMButtonUp OnMButtonDblClk OnRButtonDown OnRButtonUp OnRButtonDblClk OnMouseMove

How to add the event handler Using “Properties” window of CMainWindow

7 Mouse Message Handler Prototype of the Handler function: –nFlags Status of the mouse buttons and the Shift and Ct 기 key at the time when the message was generated afx_msg void On##### (UINT nFlags, CPoint point) ; Bit MaskMeaning MK_CONTROLCtrl key is pressed MK_SHIFTShift key is pressed MK_LBUTTONMouse left button is pressed MK_MBUTTONMouse middle button is pressed MK_RBUTTONMouse right button is pressed

8 Mouse Message Handler Prototype of the Handler function: –nFlags afx_msg void On##### (UINT nFlags, CPoint point) ; void CChildView::OnLButtonDown(UINT nFlags, CPoint point) { if(nFlags & MK_SHIFT){ // if shift key is pressed } if(nFlags & MK_RBUTTON){ // if right button is pressed at the same time } CWnd ::OnLButtonDown(nFlags, point); } void CChildView::OnLButtonDown(UINT nFlags, CPoint point) { if(nFlags & MK_SHIFT){ // if shift key is pressed } if(nFlags & MK_RBUTTON){ // if right button is pressed at the same time } CWnd ::OnLButtonDown(nFlags, point); }

9 Mouse Message Handler Prototype of the Handler function: –point Location of the cursor afx_msg void On##### (UINT nFlags, CPoint point) ; void CChildView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC dc(this); CPoint pt = point; dc.Rectangle(pt.x-100, pt.y+100, pt.x+100, pt.y-100); CWnd ::OnLButtonDown(nFlags, point); } void CChildView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC dc(this); CPoint pt = point; dc.Rectangle(pt.x-100, pt.y+100, pt.x+100, pt.y-100); CWnd ::OnLButtonDown(nFlags, point); }

Coding practice: Line drawing 1 Draw lines by using mouse Key Idea: –Remembering the beginning and ending position 1.When the mouse left button is down Set the position as the beginning point 2.When the mouse left button is released Set the position as the ending point Drawing the line

Coding practice: Line drawing 2 Draw Lines by using Mouse Show the lines even when dragging the mouse (rubber band effect) Key Idea: –Remembering the beginning and ending position 1.When the mouse left button is down Set the position as the beginning point 2.When dragging the mouse Set the position as the ending point Drawing the line 3.When the mouse left button is released Set the position as the ending point Drawing the line

Any problem? What happen when moving the mouse outside the window’s client area while dragging?

13 Capturing the mouse Mouse Capture: –Receiving mouse messages no matter where the mouse goes on the screen while dragging Related function: FunctionMeaning SetCapture()Starting Mouse Capturing ReleaseCapture()Ending mouse Capturing GetCapture()Returns CWnd pointer that owns the capture

14 Nonclient-Area Mouse Messages When the mouse is clicked or moved in a window’s nonclient area: MessageSent When WM_NCLBUTTONDOWNThe left mouse button is pressed. WM_NCLBUTTONUPThe left mouse button is released. WM_NCLBUTTONDBLCLKThe left mouse button is double-clicked. WM_NCMBUTTONDOWNThe middle mouse button is pressed. WM_NCMBUTTONUPThe middle mouse button is released. WM_NCMBUTTONDBLCLKThe middle mouse button is double-clicked. WM_NCRBUTTONDOWNThe right mouse button is pressed. WM_NCRBUTTONUPThe right mouse button is released. WM_NCRBUTTONDBLCLKThe right mouse button is double-clicked. WM_NCMOUSEMOVEThe cursor is moved over the window's nonclient area.

15 Nonclient-Area Mouse handlers Massage-map Macros and Handlers MessageMessage-Map MacroHandling Function WM_NCLBUTTONDOWNON_WM_NCLBUTTONDOWNOnNcLButtonDown WM_NCLBUTTONUPON_WM_NCLBUTTONUPOnNcLButtonUp WM_NCLBUTTONDBLCLKON_WM_NCLBUTTONDBLCLKOnNcLButtonDblClk WM_NCMBUTTONDOWNON_WM_NCMBUTTONDOWNOnNcMButtonDown WM_NCMBUTTONUPON_WM_NCMBUTTONUPOnNcMButtonUp WM_NCMBUTTONDBLCLKON_WM_NCMBUTTONDBLCLKOnNcMButtonDblClk WM_NCRBUTTONDOWNON_WM_NCRBUTTONDOWNOnNcRButtonDown WM_NCRBUTTONUPON_WM_NCRBUTTONUPOnNcRButtonUp WM_NCRBUTTONDBLCLKON_WM_NCRBUTTONDBLCLKOnNcRButtonDblClk WM_NCMOUSEMOVEON_WM_NCMOUSEMOVEOnNcMouseMove

16 Nonclient-Area Mouse handlers Prototype of the handling function –nHitTest A hit test code indicates where the event occurred. –point Location at which the event occurred (in screen coordinate) –Use CWnd::ScreenToClient() function to convert screen coord to client coord. afx_msg void OnNc* (UINT nHitTest, CPoint point) ;

17 Nonclient-Area Mouse Handlers nHitTest ValueCorresponding Location HTCAPTIONThe title bar HTCLOSEThe close button HTGROWBOXThe restore button (same as HTSIZE) HTHSCROLLThe window's horizontal scroll bar HTMENUThe menu bar HTREDUCEThe minimize button HTSIZEThe restore button (same as HTGROWBOX) HTSYSMENUThe system menu box HTVSCROLLThe window's vertical scroll bar HTZOOMThe maximize button