Chapter 3 Keyboard Input Department of Digital Contents Sang Il Park.

Slides:



Advertisements
Similar presentations
Keyboarding Vocabulary I Finals Study Basic Computer.
Advertisements

Operational & Function Keys Notes 2
Event Handling. In this class we will cover: Keyboard Events Mouse Events Focus Events Action Interface Multicasting.
Week 3 C For Win Lecture :.  Mouse Message  Keyboard Message.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Copyright © 2006 by The McGraw-Hill Companies,
Computer System Examples? Input Output Devices System Unit Devices
Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.
Visual C++ Lecture 11 Friday, 29 Aug Windows Graphic User Interface l Event driven programming environment l Windows graphic libraries (X11 on Unix,
Get to Know Your Keyboard. Operational Keys Escape (Esc) – allows you to exit unwanted menus and dialog boxes Tab – used to indent; moves the cursor 5.
Lecture Two Event Handling Keyboard and Mouse Input.
Keyboard and Events. What about the keyboard? Keyboard inputs can be used in many ways---not just for text The boolean variable keyPressed is true if.
EVENT-DRIVEN PROGRAMMING. โปรแกรมและอุปกรณ์ส่วนมากที่ใช้ใน ชีวิตประจำวัน จะตอบสนองกับเหตุการณ์ที่ เกิดขึ้น ตัวอย่างของเหตุการณ์ อาทิ การเคลื่อน หรือ คลิกเมาส์
Chapter 3 The mouse and the Keyboard. Getting input from the Mouse.
Bitmap (Chapter 15).
Programming Input Devices. Getting the device state Schemes for processing input – Polling – Callbacks Ways to intercept messages from input devices –
{ General Layout of a Keyboard Laptop or Desktop.
Instructions As the slides are displayed, discuss each slide to promote the correct keyboarding position and the proper use of various keys on the keyboard.
CSC 101 Introduction to Computing Lecture 4 M.Wasim Abbas 1.
Chapter 14 Timers and Idle Processing Department of Digital Contents Sang Il Park.
Chapter2: Drawing a Window. Drawing with the GDI.
COMPUTER INPUT DEVICE Keyboard. Keyboard cont…… Print Screen Print contents of screen Pause/Break Terminate/Interrupt Scroll Lock Modify behavior of the.
QWERTYUIOP ?. Parts & Layout of the 1. Main Keypad 2. Functions Keys 3. Modifier Keys 4. Legacy keys 5. Navigation Keys 6. Numeric Keypad 7. Indicator.
Standard Input Devices
Keyboarding Slideshow
Computer Keyboard and Proper Finger Positioning
Presented by: JAHANGIR SHOKAT HUSNAIN ANSER.
Programming Input Devices
Interfacing.
Jim Fawcett Derived from a presentation by Dmitri Volper Su ‘2001
Unit 1 Parts of the Computer
Summer 2001 James Amyot Robert Gowans
Keyboards, Pages & Transforms
A keyboard generates two scan codes when the user types a key
Windows Desktop Applications
GETTING TO KNOW YOUR KEYBOARD
Document Processing Part 2
Keyboarding Objective – Apply formatting and editing features.
CREATING, PRINTING, AND EDITING DOCUMENTS
Formatting and Editing Skills
Keyboarding Objective – Apply formatting and editing features.
Chapter 5 The MFC Collection Classes
Chapter 4 Menu and Chapter 6 File I/O
Chapter 5 The MFC Collection Classes
Keyboarding Objective – Apply formatting and editing features.
Keyboarding – Alphabetic Keys
Keyboarding – Alphabetic Keys
Информатика 5 сынып.
Keyboarding.
Keyboarding – Alphabetic Keys
Қош келдіңіздер! Информатика пәні 5 “А” сынып!.
KEYBOARD and IMPORTANT KEYS
Keyboarding – Alphabetic Keys
Formatting and Editing Skills
01.00 Use the touch method in operating the keyboard and numeric keypad Objectives Execute the touch method in operating the alphabetic keys.
Keyboarding – Alphabetic Keys
Formatting and Editing Skills
Keyboarding Vocabulary
Keyboarding – Alphabetic Keys
Keyboarding – Alphabetic Keys
50 time-saving Outlook keyboard shortcuts
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/19.
The Keyboard Jim Fawcett
Keyboarding – Alphabetic Keys
Keyboarding – Alphabetic Keys
Keyboarding Objective – Apply formatting and editing features.
Word Pad программасымен практикалық сабақ
Word Pad программасымен практикалық сабақ
Keyboarding – Alphabetic Keys
Keyboarding Vocabulary
TERMS AND CONDITIONS   These PowerPoint slides are a tool for lecturers, and as such: YOU MAY add content to the slides, delete content from the slides,
Presentation transcript:

Chapter 3 Keyboard Input Department of Digital Contents Sang Il Park

Midterm Announcement Midterm – Coding Test: –On Apr. 26th (2012/4/26) Thursday –At 10:30 (Class 1) / 12:00 (Class 2) –In the Classroom ( 율곡관 304) –5 problems to code in time. Problem Sets: on our Homepage –3 problems will be chosen from the problem set: those problems are exactly same. –1 problem will be similar to one in the problem set. –1 problem will be new.

Questions are always welcome!! Try to solve the problems by yourself, and

4 The Input Focus Windows decide which window to send the mouse and keyboard message –Mouse messages go to the window under the cursor –Keyboard messages go to the window with the ‘input focus’ Input focus: –Active application has the input focus –Only one window has the input focus at any given time

5 The Input focus Evidence of having the ‘input fucus’ carot

6 The Input Focus Receive or lose the input focus WM_SETFOCUSWM_KILLFOCUS WM_SETFOCUS

The Input Focus functions request the input focus Find out the window currently having the input focus SetFocus (); CWnd * pFocusWnd = GetFocus ();

8 Keystroke Messages Reporting key presses and releases MessagesMeaning WM_KEYDOWNWhen pressing keys (except F10 and Alt) WM_KEYUPWhen releasing keys (except F10 and Alt) WM_SYSKEYD OWN When pressing F10, Alt and Alt+Key WM_SYSKEYU P When releasing F10, Alt and Alt+Key

9 Message Handler Prototype of the message handlers –nChar Virtual key code of the key –nRepCnt Repeat count: Number of repeated keystrokes –nFlags Information of the key (read the textbook) afx_msg void On#### (UINT nChar, UINT nRepCnt, UINT nFlags) ;

10 Virtual Key Code Virtual Keycode VK_CANCEL VK_BACK VK_TAB VK_RETURN VK_SHIFT VK_CONTROL VK_MENU VK_PAUSE VK_CAPITAL VK_ESCAPE VK_SPACE VK_PRIOR VK_NEXT VK_END Key Ctrl-Break Backspace Tab Enter Shift Ctrl Alt Pause Caps Lock Esc Spacebar PgUp PgDn End Virtual Keycode VK_HOME VK_LEFT VK_UP VK_RIGHT VK_DOWN VK_SNAPSHOT VK_INSERT VK_DELETE VK_0 - VK_9 VK_A - VK_Z VK_F1 - VK_F12 VK_NUMLOCK VK_SCROLL Key Home ← ↑ → ↓ Print Screen Insert Delete 0 – 9 A – Z F1 - F12 Num Lock Scroll Lock VK_SCROLLScroll Lock

Shift states Shift, Control and Alt keys are used for combination with other key Information about those keys  shift states reporting a key is held down or not: –Returns a negative value when key is held down or a nonnegative if it is not. GetKeyState ( Virtual Keycode );

Coding practice Moving Rect VK_LEF T VK_UP VK_RIG HT VK_DO WN 1. Create a variable for position CPoint m_pt; 2. Draw a rectangle at the position (OnPaint) dc.Rectangle(m_pt.x, …); 3. Add OnKeyDown Handler 4. Change position w.r.t. nChar if(nChar == VK_RIGHT) m_pt.x += 10; 1. Create a variable for position CPoint m_pt; 2. Draw a rectangle at the position (OnPaint) dc.Rectangle(m_pt.x, …); 3. Add OnKeyDown Handler 4. Change position w.r.t. nChar if(nChar == VK_RIGHT) m_pt.x += 10; void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags) ;

13 Character Messages Possible scenarios when pressing VK_R key: charPossible Virtual Key Combination r In English input mode, press VK_R or VK_R + Caps Lock + Shift R In English input mode, press VK_R + Caps Lock or VK_R + Shift ㄱ In Korean input mode, press VK_R ㄲ In Korean input mode, press VK_R + Shift

14 Character Message When pressing VK_R key When pressing Alt + VK_R Key WM_KEYDOWN WM_CHAR WM_KEYUPWM_SYSKEYDOWN WM_SYSCHAR WM_SYSKEYDOWN WM_SYSKEYUP WM_KEYUP Alt R R

15 Message Handler Prototype of the handler –nChar Character Code (ANSI / unicode) –nRepCnt Repeat count –nFlags More Information afx_msg void OnChar (UINT nChar, UINT nRepCnt, UINT nFlags) ; afx_msg void OnSysChar (UINT nChar, UINT nRepCnt, UINT nFlags) ;

Coding Practice Typing application void CMainWindow::OnChar (UINT nChar, UINT nRepCnt, UINT nFlags) { if (((nChar >= _T (`A')) && (nChar <= _T (`Z'))) || ((nChar >= _T (`a')) && (nChar <= _T (`z')))) { // Display the character } else if (nChar == VK_RETURN) { // Process the Enter key } else if (nChar == VK_BACK) { // Process the Backspace key } void CMainWindow::OnChar (UINT nChar, UINT nRepCnt, UINT nFlags) { if (((nChar >= _T (`A')) && (nChar <= _T (`Z'))) || ((nChar >= _T (`a')) && (nChar <= _T (`z')))) { // Display the character } else if (nChar == VK_RETURN) { // Process the Enter key } else if (nChar == VK_BACK) { // Process the Backspace key }

17 Caret Related Functions FunctionDescription CreateCaretCreates a caret from a bitmap CreateSolidCaretCreates a solid line caret or a block caret CreateGrayCaretCreates a gray line caret or a block caret GetCaretPosRetrieves the current caret position SetCaretPosSets the caret position ShowCaretDisplays the caret HideCaretHides the caret

18 Caret void CMainWindow::OnSetFocus(CWnd* pOldWnd) { CWnd ::OnSetFocus(pOldWnd); CreateSolidCaret(20, 20); SetCaretPos(CPoint(50, 50)); ShowCaret(); } void CMainWindow::OnKillFocus(CWnd* pNewWnd) { CWnd ::OnKillFocus(pNewWnd); HideCaret(); ::DestroyCaret(); }

Virtual Keyboard Application Read the Example in the text book

Chapter 14 Timer Department of Digital Contents Sang Il Park

TIMER When you need to set a repeating job

SetTimer function Sending WM_TIMER message at specified interval –id id of the timer(ex: 0, 1, 2, … ) For indentifying multiple timers –time: interval (=millisec) 1000 = 1 second Call this function after creating the window –Usually set the timer in OnCreate function (the handler for WM_CREATE message) void SetTimer (int id, int time, void * fp) ; Ex) SetTimer(0, 100, NULL);

WM_TIMER’s handler nIDEvent –id of the timer which currently send WM_TIMER Ex) afx_msg void OnTimer (int nIDEvent ) void CChildView::OnTimer(int nIDEvent) { if(nIDEvent == 0) { // define any job here } void CChildView::OnTimer(int nIDEvent) { if(nIDEvent == 0) { // define any job here }

Stopping a Timer Stop the timer with the given id –id id of the timer(ex: 0, 1, 2, … ) void KillTimer (int id) ; Ex) KillTimer(0);

Coding Practice Moving Rectangle Animation 1. Create a variable for the position CPoint m_pt; 2. Draw a rect at the position (OnPaint) dc.Rectangle(m_pt.x, …); 3. Add WM_CREATE handler (OnCreate) 4. Set Timer in OnCreate function SetTimer(0,30,NULL); 5. Add WM_TIMER handler (OnTimer) if(nIDEvent == 0) ….. 1. Create a variable for the position CPoint m_pt; 2. Draw a rect at the position (OnPaint) dc.Rectangle(m_pt.x, …); 3. Add WM_CREATE handler (OnCreate) 4. Set Timer in OnCreate function SetTimer(0,30,NULL); 5. Add WM_TIMER handler (OnTimer) if(nIDEvent == 0) …..