Interfacing Key pressed Kernel get it Signal translated

  • Slides: 15
Download presentation
Interfacing

Interfacing

Key pressed Kernel get it Signal translated to ASCII Message sent to window and

Key pressed Kernel get it Signal translated to ASCII Message sent to window and to Caret

Cursor vs Caret • Cursor – graphical image to indicate position • Caret –

Cursor vs Caret • Cursor – graphical image to indicate position • Caret – flashing object for text input

Keys messages • WM_KEYDOWN LPARAM bits Meaning 0 -15 Times a key was pressed

Keys messages • WM_KEYDOWN LPARAM bits Meaning 0 -15 Times a key was pressed 16 -23 Key code 29 Context code 30 Previous key state 31 Transition state • WM_KEYUP

Caret • System provides one caret per message queue (read more about message queue)

Caret • System provides one caret per message queue (read more about message queue) • Window creates a caret only when it has the keyboard focus or is active • Only one active caret at the moment! – WM_SETFOCUS – WM_KILLFOCUS

Cursor (mouse) Mouse can send a lot of messages. In addition LPARAM and WPARAM

Cursor (mouse) Mouse can send a lot of messages. In addition LPARAM and WPARAM variables stores additional information.

Mouse messages (standart) • • • WM_LBUTTONDBLCLK WM_LBUTTONDPWN WM_LBUTTONUP WM_MBUTTONDOWN WM_MBUTTONUP WM_MOUSEMOVE WM_MOUSEWHEEL WM_RBUTTONDOWN

Mouse messages (standart) • • • WM_LBUTTONDBLCLK WM_LBUTTONDPWN WM_LBUTTONUP WM_MBUTTONDOWN WM_MBUTTONUP WM_MOUSEMOVE WM_MOUSEWHEEL WM_RBUTTONDOWN WM_BUTTONUP

LPARAM stores information about X-Y coordinates, and WPARAM – SHIFT and CTRL state. System

LPARAM stores information about X-Y coordinates, and WPARAM – SHIFT and CTRL state. System provides support for mouse tracking, but program can interfere into mouse movement or messages sent.

Timer • Used to interrupt program’s workflow – Message queue • Though timer isn’t

Timer • Used to interrupt program’s workflow – Message queue • Though timer isn’t input device, but it can send input messages to window, thus it can be considered as one. • Native timer’s time function isn’t accurate enough to use with games or time response (Direct. X API)

How to use? • Set. Timer – create a timer • Kill. Timer –

How to use? • Set. Timer – create a timer • Kill. Timer – destroys a timer • WM_TIMER – message sent to window after the set time is run out

Two ways. . . • It is possible to process WM_TIMER message inside window

Two ways. . . • It is possible to process WM_TIMER message inside window procedure • It is possible to define feedback function Timer. Proc to process message

Timer. Proc

Timer. Proc

Timer message(s) • Timer sends only one message – WM_TIMER • Variable WPARAM keeps

Timer message(s) • Timer sends only one message – WM_TIMER • Variable WPARAM keeps timers ID