Graphics Reference
In-Depth Information
class
CDrawAndMouseHandler :
public
UWBD3D
_
WindowHandler {
Source file.
DrawAndMouseHandler.h
in
the
WindowHandler
folder of
the
D3D
_
MouseInput
project.
Identical to CDrawOnlyHandler from Tutorial 5.1
bool
Initialize(CDialog& parent
_
dlg,
int
control
_
id);
void
DrawGraphics();
UWBMFC
_
UIWindow m
_
window;
Override from UWB_WindowHandler to implement Listing 5.13
void
OnMouseButton(
bool
down,
unsigned int
nFlags,
int
hwX,
int
hwY);
void
OnMouseMove(
unsigned int
nFlags,
int
hwX,
int
hwY);
//
down
- TRUE (mouse button when down) or FALSE (mouse button went up)
//
nFlags
- Which buttons (e.g. left, right, center, etc.)
//
hwX
/
hwY
- Mouse Position (in hardware coordinate where upper-left is origin)
};
Listing 5.14.
CDrawAndMouseHandler
class (Tutorial 5.2).
void
CDrawAndMouseHandler::OnMouseButton(
bool
down,
unsigned int
nFlags,
int
hwX,
int
hwY)
Transforms origin from the upper left to the lower left corner
HardwareToDevice(hwX, hwY, deviceX, deviceY);
// hardware to device coordinate
Left Mouse Button Down: this is condition
A:
of Listing 5.13.
if
(nFlags & MK
_
LBUTTON)
if
(down) theApp.GetModel().CreateCircleAt(deviceX, deviceY);
.
Right Mouse Button Down: this is condition
C:
of Listing 5.13.
Source file.
DrawAndMouseHandler.cpp
in the
WindowHandler
folder
of
if
(nFlags & MK
_
RBUTTON)
if
(down) theApp.GetModel().MoveCirceTo(deviceX, deviceY);
.
void
CDrawAndMouseHandler::OnMouseMove(
unsigned int
nFlags,
int
hwX,
int
hwY)
HardwareToDevice(hwX, hwY, deviceX, deviceY);
// hardware to device coordinate
.
Left Mouse Button Down: this is condition
B:
of Listing 5.13.
if
(nFlags & MK
_
LBUTTON)
theApp.GetModel().ResizeCircle(deviceX, deviceY);
.
Left Mouse Button Down: this is condition
D:
of Listing 5.13.
if
(nFlags & MK
_
RBUTTON)
theApp.GetModel().MoveCirceTo(deviceX, deviceY);
D3D
_
MouseInput
the
project.
Listing 5.15.
CDrawAndMouseHandler
mouse event services (Tutorial 5.2).
Search WWH ::
Custom Search