Game Development Reference
In-Depth Information
void CMFCSingleDocView::OnDraw(CDC* dc)
{
CMFCSingleDocDoc* doc = GetDocument();
ASSERT_VALID(doc);
dc->FrameRect(&doc->rect, &CBrush(RGB(255, 0, 0)));
}
To reshape the rectangle we can use Class Wizard to add an event
handler. We select CMFCSingleDoc as the class we are dealing with in
the Message Maps tab. Then select WM_LBUTTONDOWN from the
message ID list. Select 'Add Function' and a message handling function
is created. You can add code to this function to handle your specific
needs.
void CMFCSingleDocView::OnLButtonDown(UINT nFlags, CPoint point)
{
GetDocument()->rect.left = point.x;
GetDocument()->rect.top = point.y;
CView::OnLButtonDown(nFlags, point);
}
We use the same technique to implement a mouse button release
function.
void CMFCSingleDocView::OnLButtonUp(UINT nFlags, CPoint point)
{
GetDocument()->rect.right = point.x;
GetDocument()->rect.bottom = point.y;
CView::OnLButtonUp(nFlags, point);
}
As the mouse moves, we redraw the view if the left mouse button is held
down, VK_LBUTTON.
void CMFCSingleDocView::OnMouseMove(UINT nFlags, CPoint point)
{
if (VK_LBUTTON & nFlags){
GetDocument()->rect.right = point.x;
GetDocument()->rect.bottom = point.y;
Invalidate();
}
CView::OnMouseMove(nFlags, point);
}
Search Nedrilad ::




Custom Search