本文整理汇总了C++中CDC::DrawDragRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CDC::DrawDragRect方法的具体用法?C++ CDC::DrawDragRect怎么用?C++ CDC::DrawDragRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDC
的用法示例。
在下文中一共展示了CDC::DrawDragRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawDragRect
void CDlgMovedBase::DrawDragRect( CRect* pRcBefore, CRect* pRcAfter , int nMode /*= 1*/)
{
//CPaintDC dc(GetDesktopWindow()); //this will failed, why
CSize szBefor(2,2);
CSize szAfter(2,2);
if (nMode == 2)
{
szAfter = CSize(0,0);
}
else if (nMode == 0)
{
szBefor = CSize(0,0);
}
CDC *pDC = GetDesktopWindow()->GetWindowDC();
ASSERT(pDC != NULL);
pDC->DrawDragRect(pRcAfter, szAfter, pRcBefore,szBefor );
GetDesktopWindow()->ReleaseDC(pDC);
}
示例2: DrawDragLine
LRESULT CNormalsChartsCtrl::DrawDragLine(const CPoint& oldPt, const CPoint& newPt, int w)
{
// Draw last rect, but no new one (erase old rect)
CDC *cdc = GetDC();
static const CRect RECT_NULL = CRect(0, 0, 0, 0);
CRect rectRange;
GetClientRect(&rectRange);
CRect oldRect(oldPt.x - w, rectRange.top, oldPt.x + w, rectRange.bottom);
CRect newRect(newPt.x - w, rectRange.top, newPt.x + w, rectRange.bottom);
bool bOldValid = oldPt.x >= 0 && oldPt.y >= 0;
bool bNewValid = newPt.x >= 0 && newPt.y >= 0;
cdc->DrawDragRect(bNewValid ? newRect : RECT_NULL, CSize(w, w), bOldValid ? oldRect : RECT_NULL, CSize(w, w));
ReleaseDC(cdc);
return TRUE;
}
示例3: OnLButtonDown
void CySplitterWnd::OnLButtonDown(UINT /*nFlags*/, CPoint point)
{
// TODO: Add your message handler code here and/or call default
// don't handle if capture already set
if (::GetCapture() != NULL) return;
// don't handle if no room to drag
RECT rectMouseClip;
if (!GetMouseClipRect(&rectMouseClip, point)) return;
::ClipCursor(&rectMouseClip);
// set capture to the window which received this message
SetCapture();
ASSERT(this == CWnd::GetCapture());
// get DC for drawing
CDC* pDrawDC;
pDrawDC = m_Parent->GetDC();
ASSERT_VALID(pDrawDC);
int curX, curY;
int xDiff, yDiff;
CRect rectOrg, rectCur, rectOld;
CSize sizeBar;
GetWindowRect(rectOrg);
sizeBar = CSize(rectOrg.Width(), rectOrg.Height());
m_Parent->ScreenToClient(rectOrg);
pDrawDC->DrawDragRect(&rectOrg, sizeBar, NULL, sizeBar);
rectOld = rectCur = rectOrg;
xDiff = yDiff = 0;
// get messages until capture lost or cancelled/accepted
for (;;) {
MSG msg;
VERIFY(::GetMessage(&msg, NULL, 0, 0));
if (CWnd::GetCapture() != this)
break;
switch (msg.message) {
// handle movement/accept messages
case WM_MOUSEMOVE:
// handle resize cases (and part of move)
curX = (int)(short)LOWORD(msg.lParam);
curY = (int)(short)HIWORD(msg.lParam);
xDiff = curX - point.x;
yDiff = curY - point.y;
rectCur = rectOrg;
rectCur.top += yDiff;
rectCur.bottom += yDiff;
pDrawDC->DrawDragRect(&rectCur, sizeBar, &rectOld, sizeBar);
rectOld = rectCur;
break;
// handle cancel messages
case WM_KEYDOWN:
if (msg.wParam != VK_ESCAPE)
break;
case WM_LBUTTONUP:
case WM_RBUTTONDOWN:
goto ExitLoop;
// just dispatch rest of the messages
default:
DispatchMessage(&msg);
break;
}
}
ExitLoop:
pDrawDC->DrawDragRect(&rectCur, sizeBar, NULL, sizeBar);
m_Parent->ReleaseDC(pDrawDC);
ReleaseCapture();
::ClipCursor(NULL);
if (yDiff == 0) return;
// move the splitter bar & re-position the attached panes if necessary
MoveWindow(rectCur, FALSE);
RecalcLayout();
m_Parent->SendMessage(WM_SPLITTER_MOVED, yDiff, GetDlgCtrlID());
//CWnd::OnLButtonDown(nFlags, point);
}