Пример #1
0
bool CFigure::MoveFigure(CPoint ptCorner, CSpiroDoc* pDoc)
{
    pDoc->SetModifiedFlag();

    // does the user want to remove the picture from the drawing?
    if (ptCorner.x > pDoc->m_sizeExtent.cx || ptCorner.y < 0)
    {
        delete this;
        return false;  // figure was deleted
    }

    CSize	sizeOffset(ptCorner.x - m_rectBound.left + 2, ptCorner.y - m_rectBound.top + 2);
    m_rectBound.OffsetRect(sizeOffset);  //LO_ENGLISH METRICS USED

    CFigCommand	figCommand;
    INT_PTR iLast = m_arrCommands.GetUpperBound();
    for (int i = 0; i <= iLast; i++)
    {
        figCommand = m_arrCommands.GetAt(i);
        if (figCommand.m_type != LINE_TO && figCommand.m_type != MOVE_TO)
            continue;

        figCommand.m_point.Offset(sizeOffset);
        m_arrCommands.SetAt(i, figCommand);
    }

    iLast = pDoc->m_arrPFigures.GetUpperBound() + 1;
    pDoc->m_arrPFigures.SetAtGrow(iLast, this);
    return true;
}
Пример #2
0
UINT ThreadDraw(PVOID pParam)
{
    static int snCount = 0;
    snCount++;
    TRACE(TEXT("- ThreadDraw %d: started...\n"), snCount);

    THREADINFO *pInfo = reinterpret_cast<THREADINFO *> (pParam);

    CWnd *pWnd = CWnd::FromHandle(pInfo->hWnd);

    CClientDC dc(pWnd);

    int x = pInfo->point.x;
    int y = pInfo->point.y;

    srand((UINT)time(NULL));
    CRect rectEllipse(x - 25, y - 25, x + 25, y + 25);

    CSize sizeOffset(1, 1);

    CBrush brush(RGB(rand() % 256, rand() % 256, rand() % 256));
    CBrush *pOld = dc.SelectObject(&brush);
    while (WAIT_TIMEOUT == ::WaitForSingleObject(g_eventEnd, 0))
    {
        CRect rectClient;
        pWnd->GetClientRect(rectClient);

        if (rectEllipse.left < rectClient.left || rectEllipse.right > rectClient.right)
        {
            sizeOffset.cx *= -1;
        }

        if (rectEllipse.top < rectClient.top || rectEllipse.bottom > rectClient.bottom)
        {
            sizeOffset.cy *= -1;
        }

        dc.FillRect(rectEllipse, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));

        rectEllipse.OffsetRect(sizeOffset);

        dc.Ellipse(rectEllipse);
        Sleep(25);
    }

    dc.SelectObject(pOld);

    delete pInfo;

    TRACE(TEXT("- ThreadDraw %d: exiting.\n"), snCount--);
    return 0;
}
Пример #3
0
void COXSizeControlBar::EraseNonClient()
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this);
    CRect rectClient;
    GetClientRect(rectClient);
    CRect rectWindow;
    GetWindowRect(rectWindow);
    ScreenToClient(rectWindow);
	CSize sizeOffset(-rectWindow.left, -rectWindow.top);
	rectClient+=sizeOffset;

    rectWindow+=sizeOffset;

    // erase parts not drawn
	dc.ExcludeClipRect(rectClient);
	dc.IntersectClipRect(rectWindow);
	CRect rect;
	dc.GetClipBox(&rect);

	GetDockbarSkin()->DrawNonClientArea(&dc, rectWindow, this);

	RecalcLayout();

	if(IsGripper())
	{
		DrawGripper(&dc);
	}
	if(IsCloseBtn())
	{
		DrawCloseBtn(&dc);
	}
	if(IsResizeBtn())
	{
		DrawResizeBtn(&dc);
	}

	// Draw the border
	if (m_bClientBorder)
	{
		CBrush brBorder;
		brBorder.CreateSolidBrush(GetDockbarSkin()->GetClientBorderColor());
		rectClient.InflateRect(1, 1);
		dc.FrameRect(rectClient, &brBorder);
	}
}