Share via


CDC::DrawDragRect

Call this member function repeatedly to redraw a drag rectangle.

void DrawDragRect(
   LPCRECT lpRect,
   SIZE size,
   LPCRECT lpRectLast,
   SIZE sizeLast,
   CBrush* pBrush = NULL,
   CBrush* pBrushLast = NULL 
);

Parameters

  • lpRect
    Points to a RECT structure or a CRect object that specifies the logical coordinates of a rectangle — in this case, the end position of the rectangle being redrawn.

  • size
    Specifies the displacement from the top-left corner of the outer border to the top-left corner of the inner border (that is, the thickness of the border) of a rectangle.

  • lpRectLast
    Points to a RECT structure or a CRect object that specifies the logical coordinates of the position of a rectangle — in this case, the original position of the rectangle being redrawn.

  • sizeLast
    Specifies the displacement from the top-left corner of the outer border to the top-left corner of the inner border (that is, the thickness of the border) of the original rectangle being redrawn.

  • pBrush
    Pointer to a brush object. Set to NULL to use the default halftone brush.

  • pBrushLast
    Pointer to the last brush object used. Set to NULL to use the default halftone brush.

Remarks

Call it in a loop as you sample mouse position, in order to give visual feedback. When you call DrawDragRect, the previous rectangle is erased and a new one is drawn. For example, as the user drags a rectangle across the screen, DrawDragRect will erase the original rectangle and redraw a new one in its new position. By default, DrawDragRect draws the rectangle by using a halftone brush to eliminate flicker and to create the appearance of a smoothly moving rectangle.

The first time you call DrawDragRect, the lpRectLast parameter should be NULL.

Requirements

Header: afxwin.h

See Also

Reference

CDC Class

Hierarchy Chart

RECT Structure

CRect Class

CDC::GetHalftoneBrush

Other Resources

CDC Members