void CDisplayWindow::DrawGradientFill(HDC hdc,RECT *rc)
{
	if(m_hBitmapBackground)
	{
		DeleteObject(m_hBitmapBackground);
	}

	/* Create the (temporary) off-screen buffer used for drawing. */
	m_hBitmapBackground	= CreateCompatibleBitmap(hdc,rc->right - rc->left,rc->bottom - rc->top);
	SelectObject(m_hdcBackground,m_hBitmapBackground);

	Gdiplus::Graphics graphics(m_hdcBackground);

	Gdiplus::Rect DisplayRect(0,0,rc->right - rc->left,rc->bottom - rc->top);

	Gdiplus::GraphicsPath Path;
	Path.AddRectangle(DisplayRect);
	Gdiplus::PathGradientBrush pgb(&Path);
	pgb.SetCenterPoint(Gdiplus::Point(0,0));

	pgb.SetCenterColor(m_CentreColor);

	INT count = 1;
	pgb.SetSurroundColors(&m_SurroundColor,&count);
	graphics.FillRectangle(&pgb,DisplayRect);

	/* This draws a separator line across the top edge of the window,
	so that it is visually separated from other windows. */
	Gdiplus::Pen NewPen(BORDER_COLOUR,1);
	graphics.DrawLine(&NewPen,0,0,rc->right,0);
}
Exemple #2
0
void CChartCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	if (!m_bMemDCCreated)
	{
		RefreshCtrl();
		m_bMemDCCreated = true;
	}

    // Get Size of Display area
    CRect rect;
    GetClientRect(&rect);
	dc.BitBlt(0, 0, rect.Width(), rect.Height(), 
			  &m_BackgroundDC, 0, 0, SRCCOPY) ;

	// Draw the zoom rectangle
	if (m_bZoomEnabled && m_bLMouseDown)
	{
		CPen NewPen(PS_SOLID,1,RGB(255,255,255));
		CPen* pOldPen = dc.SelectObject(&NewPen);

		dc.MoveTo(m_rectZoomArea.TopLeft());
		dc.LineTo(m_rectZoomArea.right,m_rectZoomArea.top);
		dc.LineTo(m_rectZoomArea.BottomRight());
		dc.LineTo(m_rectZoomArea.left,m_rectZoomArea.bottom);
		dc.LineTo(m_rectZoomArea.TopLeft());

		dc.SelectObject(pOldPen);
		DeleteObject(NewPen);
	}
}
Exemple #3
0
void CGridListCtrl::OnPaint()
{
  // Make the gridlines easier to see than default light grey
  // First let the control do its default drawing.
  const MSG *pMsg = GetCurrentMessage();
  DefWindowProc(pMsg->message, pMsg->wParam, pMsg->lParam);

  // Draw the lines only for LVS_REPORT mode
  if ((GetStyle() & LVS_TYPEMASK) == LVS_REPORT) {
    CClientDC dc(this);
    CPen NewPen(PS_SOLID, 0, m_RGBLineColour);
    CPen *pOldPen = dc.SelectObject(&NewPen);

    // Get the number of columns
    CHeaderCtrl *pHeader = (CHeaderCtrl *)GetDlgItem(m_HeaderCtrlID);
    int nColumnCount = pHeader->GetItemCount();

    // The bottom of the header corresponds to the top of the line
    RECT rect;
    pHeader->GetClientRect(&rect);
    int top = rect.bottom;

    // Now get the client rect so we know the line length and when to stop
    GetClientRect(&rect);

    // The border of the column is offset by the horz scroll
    int borderx = 0 - GetScrollPos(SB_HORZ);
    for (int i = 0; i < nColumnCount; i++) {
      // Get the next border
      borderx += GetColumnWidth(pHeader->OrderToIndex(i));

      // if next border is outside client area, break out
      if (borderx >= rect.right) break;

      // Draw the line.
      dc.MoveTo(borderx - 1, top);
      dc.LineTo(borderx - 1, rect.bottom);
    }

    // Draw the horizontal grid lines
    // First get the height
    if (!GetItemRect(0, &rect, LVIR_BOUNDS))
      return;

    int height = rect.bottom - rect.top;

    GetClientRect(&rect);
    int width = rect.right;

    for (int i = 1; i <= GetCountPerPage(); i++) {
      dc.MoveTo(0, top + height * i);
      dc.LineTo(width, top + height * i);
    }

    dc.SelectObject(pOldPen);
  }
}
void CMagneticView::SolidRect(CDC* pDC, LPCRECT lpRect, COLORREF Colour)
{
  CPen NewPen(PS_SOLID,1,Colour);
  CPen* pOldPen = pDC->SelectObject(&NewPen);

  CBrush NewBrush(Colour);
  CBrush* pOldBrush = pDC->SelectObject(&NewBrush);

  pDC->Rectangle(lpRect);

  pDC->SelectObject(pOldPen);
  pDC->SelectObject(pOldBrush);
}
void CChartLineSerie::DrawLegend(CDC *pDC, const CRect& rectBitmap) const
{
	if (m_strSerieName== _T(""))
		return;

	//Draw line:
	LOGBRUSH lb;
	lb.lbStyle = BS_SOLID;
	lb.lbColor = m_SerieColor;
	CPen NewPen(PS_GEOMETRIC | m_iPenStyle,m_iLineWidth,&lb);
	CPen* pOldPen = pDC->SelectObject(&NewPen);
	pDC->MoveTo(rectBitmap.left,rectBitmap.CenterPoint().y);
	pDC->LineTo(rectBitmap.right,rectBitmap.CenterPoint().y);
	pDC->SelectObject(pOldPen);
	DeleteObject(NewPen);
}