Example #1
0
void CInspectorTreeCtrl::OnPaint()
{   
    CPaintDC dc(this); 

    CPropertyInspector * parent = static_cast <CPropertyInspector *> (GetParent());

    CRect rcClip;
    dc.GetClipBox( &rcClip );       
    rcClip.right = getColumnWidth(0);

    CRgn rgn;                   
    rgn.CreateRectRgnIndirect( &rcClip );
    dc.SelectClipRgn(&rgn);

    CWnd::DefWindowProc(WM_PAINT, reinterpret_cast <WPARAM> (dc.m_hDC), 0);     // let CTreeCtrl paint as normal
    rgn.DeleteObject();

    rcClip.right += parent->getColumnWidth(1);
    rgn.CreateRectRgnIndirect( &rcClip );
    dc.SelectClipRgn(&rgn);

    drawValues(dc);

    rgn.DeleteObject();
}
Example #2
0
// CPhotoPubView 绘制
void CPhotoPubView::DrawImage(CDC *pDC,IplImage *pImg)
{
	int wid=0,hi=0;

	CRect ClipBox;
	GetClientRect(&ClipBox);
	if (!pImg) {
		CBitmap bkg;
		bkg.LoadBitmap(IDB_BACKGROUND);
		CBrush brush(&bkg);
		pDC->FillRect(&ClipBox,&brush);	
		return;
	}

	wid=int(pImg->width*m_ratio);
	hi=int(pImg->height*m_ratio);

	IplImage *pStub=pImg;
	IplImage *pTmp=NULL;
	if (wid!=pImg->width) {
		pTmp=cvCreateImage(cvSize(wid,hi),IPL_DEPTH_8U,3);
		cvResize(pImg,pTmp);
		pStub=pTmp;
	}
		

	CRgn WindowRgn;
	WindowRgn.CreateRectRgnIndirect(&ClipBox);
	CRect ImageRect(0,0,wid,hi);
	int top=max((ClipBox.Height()-hi)/2,0);
	int left=max((ClipBox.Width()-wid)/2,0);
	ImageRect.MoveToXY(left,top);
	CRgn ImageRgn;
	ImageRgn.CreateRectRgnIndirect(&ImageRect);
	WindowRgn.CombineRgn(&WindowRgn,&ImageRgn,RGN_DIFF);

	CBitmap bkg;
	bkg.LoadBitmap(IDB_BACKGROUND);
	CBrush brush(&bkg);
	pDC->FillRgn(&WindowRgn,&brush);	
	
	memset(m_bmih_buffer, 0, sizeof(*m_bmih_buffer));
    m_bmih_buffer->biSize = sizeof(BITMAPINFOHEADER);
    m_bmih_buffer->biWidth = wid;
    m_bmih_buffer->biHeight = -hi;
    m_bmih_buffer->biPlanes = 1;
    m_bmih_buffer->biBitCount = 24;
    m_bmih_buffer->biCompression = BI_RGB;


	SetDIBitsToDevice(
		pDC->m_hDC, 
		ImageRect.left,ImageRect.top,pStub->width,pStub->height, 
		0, 0, 0, hi, pStub->imageData, m_bmi_buffer, DIB_RGB_COLORS 
	);

	cvReleaseImage(&pTmp);

}
Example #3
0
void COXTabViewContainer::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here

	CWnd* pWnd=GetActivePage();
	if(pWnd!=NULL)
	{
		CRect rect;
		pWnd->GetWindowRect(rect);
		ScreenToClient(rect);
		if(m_rectPage!=rect && !rect.IsRectEmpty())
		{
			CRgn rgnInTheory;
			CRgn rgnInReality;
			if(rgnInTheory.CreateRectRgnIndirect(m_rectPage) &&
				rgnInReality.CreateRectRgnIndirect(rect))
			{
				if(rgnInTheory.CombineRgn(&rgnInTheory,&rgnInReality,
					RGN_DIFF)!=ERROR)
				{
					CBrush* pBrush=NULL;
					CBrush brush;
					HBRUSH hBrush=(HBRUSH)(INT_PTR)::GetClassLongPtr(pWnd->m_hWnd,
						GCL_HBRBACKGROUND);
					if(hBrush==NULL)
					{
						if(brush.CreateSolidBrush(::GetSysColor(COLOR_WINDOW)))
							pBrush=&brush;
						else
							pBrush=dc.GetCurrentBrush();
					}
					else
					{
						pBrush=CBrush::FromHandle(hBrush);
					}
					
					if(pBrush!=NULL)
						dc.FillRgn(&rgnInTheory,pBrush);
				}
			}
		}
	}

	DrawScrollButtons(&dc);
	DrawSplitter(&dc);
	DrawSizeBar(&dc);
	DrawTabBtnArea(&dc);

	// Do not call CWnd::OnPaint() for painting messages
}
Example #4
0
void CMcLogo::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CRect	Client;
	GetClientRect(&Client);

	dc.SetBoundsRect(Client,DCB_SET);

	CRgn	reg;
	reg.CreateRectRgnIndirect(Client);
	
	dc.SelectClipRgn(&reg);

//	CRect rendRect(CPoint((Client.Width()-227)/2,0),CSize(227,36)), 
//		rectLeft(0,0,(Client.Width()-227)/2,36),
//		rectRight((Client.Width()-227)/2+227,0,Client.Width(),36);
	CRect rendRect(CPoint(0, 0), CSize(227,36)),
		rectRight(227, 0, Client.Width(), 36);
	
	//dc.FillSolidRect(rectLeft,m_BkgColor);
	dc.FillSolidRect(rectRight, m_BkgColor);
	if(m_Image.m_pPict)
		m_Image.Render(&dc, rendRect, rendRect);
	else
		dc.FillSolidRect(rendRect, m_BkgColor);
}
Example #5
0
// Create the "4 corner" region surrounding cRect
void CFlashingWnd::MakeFixedRegion(CRgn &wndRgn, CRgn &rgnTemp, CRgn &rgnTemp2, CRgn &rgnTemp3)
{
	CRect rectWnd(0, 0, m_cRect.Width() + THICKNESS + THICKNESS, m_cRect.Height() + THICKNESS + THICKNESS);
	CRect rectTemp(THICKNESS, THICKNESS, m_cRect.Width() + THICKNESS + 1, m_cRect.Height() + THICKNESS + 1);
	CRect rectTemp2(0, SIDELEN2, m_cRect.Width() + THICKNESS + THICKNESS, m_cRect.Height() - SIDELEN + 1);
	CRect rectTemp3(SIDELEN2, 0, m_cRect.Width() - SIDELEN + 1, m_cRect.Height() + THICKNESS + THICKNESS);

	VERIFY(wndRgn.CreateRectRgnIndirect(rectWnd));
	VERIFY(rgnTemp.CreateRectRgnIndirect(rectTemp));
	VERIFY(rgnTemp2.CreateRectRgnIndirect(rectTemp2));
	VERIFY(rgnTemp3.CreateRectRgnIndirect(rectTemp3));

	VERIFY(ERROR != wndRgn.CombineRgn(&wndRgn, &rgnTemp, RGN_DIFF));
	VERIFY(ERROR != wndRgn.CombineRgn(&wndRgn, &rgnTemp2, RGN_DIFF));
	VERIFY(ERROR != wndRgn.CombineRgn(&wndRgn, &rgnTemp3, RGN_DIFF));

	VERIFY(ERROR != wndRgn.OffsetRgn(m_cRect.left - THICKNESS, m_cRect.top - THICKNESS));
}
Example #6
0
void MyGraphSeries::SetTipRegion(int nGroup, const CRect& rc)
{
	VALIDATE;

	CRgn* prgnNew = new CRgn;
	ASSERT_VALID(prgnNew);

	VERIFY(prgnNew->CreateRectRgnIndirect(rc));
	SetTipRegion(nGroup, prgnNew);
}
Example #7
0
//****************************************************************************************
COLORREF CImageStyle::OnDrawControlBarCaption (CDC* pDC, CBCGPDockingControlBar* pBar, 
	BOOL /*bActive*/, CRect rectCaption, CRect /*rectButtons*/)
{
	CRgn rgn;
	rgn.CreateRectRgnIndirect (rectCaption);

	pDC->SelectClipRgn (&rgn);
	FillArea (pDC, rectCaption, pBar, FALSE, TRUE);

	return RGB (0, 0, 0);
}
Example #8
0
//****************************************************************************************
void CGCQStyle::OnFillBarBackground  (CDC* pDC, CControlBar* pBar,
										CRect rectClient, CRect rectClip,
										BOOL bNCArea)
{
	ASSERT_VALID (pDC);
	ASSERT_VALID (pBar);

	if (!bNCArea)
	{
		CRgn rgn;
		rgn.CreateRectRgnIndirect (&rectClient);

		pDC->SelectClipRgn (&rgn);
	}

	CBCGDrawManager dm (*pDC);

	CRect rectFill = rectClient;

	if (!pBar->IsFloating () &&
		!pBar->IsKindOf (RUNTIME_CLASS (CBCGPopupMenuBar)))
	{
		CRect rectMainFrame;
		pBar->GetTopLevelFrame ()->GetWindowRect (rectMainFrame);

		pBar->ScreenToClient (&rectMainFrame);
		rectFill = rectMainFrame;

		if (bNCArea)
		{
			CRect rectWindow;
			pBar->GetWindowRect (rectWindow);

			pBar->ScreenToClient (rectWindow);

			CRect rectClientActual;
			pBar->GetClientRect (rectClientActual);

			rectFill.left += rectClientActual.left - rectWindow.left;
			rectFill.top += rectClientActual.top - rectWindow.top;
			rectFill.right += 10;
		}
	}

	dm.FillGradient (rectFill, CGCQLApp::sm_BackgroundColor1, CGCQLApp::sm_BackgroundColor2, FALSE);

	if (!bNCArea)
	{
		pDC->SelectClipRgn (NULL);
	}

	//pDC->SetTextColor( RGB(255,255,255) );
}
void CXTPReportGroupRow::Draw(CDC* pDC, CRect rcRow, CRect rcClip, int nLeftOffset,
	CXTPReportRecordMergeItems& /*mergeItems*/, int nColumnFrom, int nColumnTo)
{
	UNREFERENCED_PARAMETER(rcClip);
	UNREFERENCED_PARAMETER(nColumnFrom);
	UNREFERENCED_PARAMETER(nColumnTo);

	CRgn rgnClip;
	if (!pDC->IsPrinting())
	{
		rgnClip.CreateRectRgnIndirect(&rcClip);
		pDC->SelectClipRgn(&rgnClip, RGN_COPY);
	}

	CXTPReportPaintManager *pPaintManager = m_pControl->GetPaintManager();

	pDC->SetBkMode(TRANSPARENT);

	m_rcRow = rcRow;
	if (0 == GetControl()->GetFreezeColumnsCount())
	{
		m_rcRow.left  -= nLeftOffset;
		m_rcRow.right -= nLeftOffset;
	}

	XTP_REPORTRECORDITEM_DRAWARGS drawArgs;
	drawArgs.pDC        = pDC;
	drawArgs.nTextAlign = DT_LEFT;
	drawArgs.pControl   = m_pControl;
	drawArgs.pColumn    = NULL;
	drawArgs.pRow       = this;
	drawArgs.pItem      = NULL;
	drawArgs.rcItem     = m_rcRow;

	XTP_REPORTRECORDITEM_METRICS* pDrawMetrics = new XTP_REPORTRECORDITEM_METRICS;
	pDrawMetrics->strText = GetCaption();

	pPaintManager->FillGroupRowMetrics(this, pDrawMetrics, pDC->IsPrinting());

	ASSERT(m_pControl);
	if (m_pControl)
		m_pControl->GetItemMetrics(&drawArgs, pDrawMetrics);

	pPaintManager->DrawGroupRow(pDC, this, m_rcRow, pDrawMetrics);

	pDrawMetrics->InternalRelease();

	if (!pDC->IsPrinting())
	{
		pDC->SelectClipRgn(NULL, RGN_COPY);
		rgnClip.DeleteObject();
	}
}
void CNOutBarCtrl::hilightItem(CDC *pDC, int i, BOOL pressed)
{	
	CRect rc;
	getInsideRect(rc);
	CRgn rgn;
	rgn.CreateRectRgnIndirect(rc);
	pDC->SelectClipRgn(&rgn);
	getIconRect(rc, i);
	
	if (pressed)
		pDC->Draw3dRect(rc, GetSysColor(COLOR_3DDKSHADOW), GetSysColor(COLOR_BTNHILIGHT));
	else
		pDC->Draw3dRect(rc, GetSysColor(COLOR_BTNHILIGHT), GetSysColor(COLOR_3DDKSHADOW));
}
Example #11
0
UINT CRoboticsLabDlg::StartDlgUpdateThread (LPVOID param){

	DLGTHREADSTRUCT*	ts = (DLGTHREADSTRUCT*)param;

	Sleep(3000);

	// Default Point to Simulator so that encoders can point to something
	ts->_this->m_MOTSDK = &(ts->_this->m_MOTSDK_simulator);


	// Update openGL screen until terminated from dialog OK
	while(!ts->_this->openGLControl->terminate && !ts->_this->StopThreads)
	{

		// Update Encoders
		ts->_this->m_Encoder1 = ts->_this->m_MOTSDK->GetEncoderPulse1();
		ts->_this->m_Encoder2 = ts->_this->m_MOTSDK->GetEncoderPulse2();

		// Udpate Sonars
		ts->_this->m_Sonar1= ts->_this->m_MOTSDK->GetSensorSonar1 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_Sonar2= ts->_this->m_MOTSDK->GetSensorSonar2 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_Sonar3= ts->_this->m_MOTSDK->GetSensorSonar3 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);

		// Update IR sensors
		ts->_this->m_IR1 = ts->_this->m_MOTSDK->GetSensorIRRange (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);	
		ts->_this->m_IR2 = ts->_this->m_MOTSDK->GetCustomAD3 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_IR3 = ts->_this->m_MOTSDK->GetCustomAD4 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_IR4 = ts->_this->m_MOTSDK->GetCustomAD5 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_IR5 = ts->_this->m_MOTSDK->GetCustomAD6 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_IR6 = ts->_this->m_MOTSDK->GetCustomAD7 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);
		ts->_this->m_IR7 = ts->_this->m_MOTSDK->GetCustomAD8 (ts->_this->robot_dlg->x, ts->_this->robot_dlg->y, ts->_this->robot_dlg->t);

		//ts->_this->openGLControl->Invalidate();
		//ts->_this->openGLControl->UpdateWindow();

		// Send WM_PAINT Message
		RECT DialogRegion;
		CRgn Region; 
		Region.CreateRectRgnIndirect(&DialogRegion);
		//ts->_this->InvalidateRgn(&Region,TRUE);
		ts->_this->openGLControl->Invalidate(TRUE);
		//ts->_this->OnPaint();
		
		// Sleep to approximate 10 Hz update rate
		Sleep(100);
	}
	//AfxEndThread(0);
	
	return 1;
}
Example #12
0
//*********************************************************************************
void CImageStyle::OnFillOutlookPageButton (CDC* pDC, const CRect& rect,
										BOOL /*bIsHighlighted*/, BOOL /*bIsPressed*/,
										COLORREF& clrText)
{
	CRgn rgn;
	rgn.CreateRectRgnIndirect (rect);

	pDC->SelectClipRgn (&rgn);
	FillArea (pDC, rect, &((CMainFrame*) AfxGetMainWnd ())->GetOutlookBar (), FALSE, FALSE);

	pDC->SelectClipRgn (NULL);

	clrText = m_clrText;
}
Example #13
0
//****************************************************************************************
void CImageStyle::OnFillBarBackground  (CDC* pDC, CBCGPBaseControlBar* pBar,
										CRect rectClient, CRect /*rectClip*/,
										BOOL bNCArea)
{
	if (!bNCArea)
	{
		CRgn rgn;
		rgn.CreateRectRgnIndirect (&rectClient);

		pDC->SelectClipRgn (&rgn);
	}

	FillArea (pDC, rectClient, pBar, pBar->IsFloating (), bNCArea);
	pDC->SelectClipRgn (NULL);
}
Example #14
0
int CNaviWnd::MouseTest(int x, int y)
{
	int res=0;
	CRect rect;
	CRgn rgn;
	for(int i=1;i<5;i++)
	{
		rect.SetRect(2+(i-1)*17,2,2+i*17,18);
		rgn.CreateRectRgnIndirect(&rect);
		if(rgn.PtInRegion(x,y))
			res=i;
		rgn.DeleteObject();
	}
	rect.SetRect(180,8,195,18);
	rgn.CreateRectRgnIndirect(&rect);
		if(rgn.PtInRegion(x,y))
			res=5;
	rect.SetRect(178,20,1985,40);
	rgn.DeleteObject();
	rgn.CreateRectRgnIndirect(&rect);
		if(rgn.PtInRegion(x,y))
			res=6;
	return res;
}
void CNOutBarCtrl::drawItem(CDC *pDC, int i, BOOL redraw)
{
	CRect rc;
	getIconRect(rc, i);
	if (redraw) {
		CRect clip;
		getInsideRect(clip);
		CRgn rgn;
		rgn.CreateRectRgnIndirect(clip);
		pDC->SelectClipRgn(&rgn);
		drawBackground(pDC, rc);
	}
	drawItemImage(pDC, i, rc);
	if (!redraw)
		drawItemText(pDC, i, fontColor);
}
Example #16
0
void CMcAppBar::OnPaint()
{
    CPaintDC dc(this); // device context for painting

    CRect clientRect;
    GetClientRect(&clientRect);

    CRgn rgn;
    rgn.CreateRectRgnIndirect(&clientRect);
    dc.SelectClipRgn(&rgn,RGN_COPY);

    CMemoryDC	memDc(&dc);
    memDc.FillSolidRect(&clientRect,m_dwBkgColor);

    m_AppCtrl.Draw(&memDc);
}
Example #17
0
void CUIImagePreview::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CStatic::OnPaint()
	CMemDC memDC(dc, this);
	CDC* pDC = &memDC.GetDC();

	CRect rectClient;
	CRgn rgnClip;
	this->GetClientRect(&rectClient);
	rgnClip.CreateRectRgnIndirect(&rectClient);
	pDC->SelectClipRgn(&rgnClip);
	pDC->FillRect(&rectClient, &afxGlobalData.brBtnFace);
	if(!m_imgPreview.IsNull())
		m_imgPreview.BitBlt(pDC->GetSafeHdc(), 0, 0);
}
void CBCGPSDPlaceMarkerWnd::ShowTabbedAt (CRect rect, CRect rectTab)
{
    if (!m_bTabbed || m_rectLast != rect || m_rectTab != rectTab)
    {
        Hide ();

        CRgn rgnMain;
        CBCGPTabbedControlBar::m_bTabsAlwaysTop ? 
			rgnMain.CreateRectRgn (0, rectTab.Height (), rect.Width(), rect.Height() + rectTab.Height ()) :
			rgnMain.CreateRectRgn (0, 0, rect.Width(), rect.Height());

        CRgn rgnTab;
        if (CBCGPTabbedControlBar::m_bTabsAlwaysTop)
		{
			rgnTab.CreateRectRgn (rectTab.left, 0, rectTab.Width (), rectTab.Height ());
		}
		else
		{
			rgnTab.CreateRectRgnIndirect (rectTab);
		}

        rgnMain.CombineRgn (&rgnMain, &rgnTab, RGN_OR);
        SetWindowRgn (rgnMain, FALSE);

        m_bTabbed = TRUE;

        m_rectLast = rect;
		m_rectTab = rectTab;

		if (CBCGPTabbedControlBar::m_bTabsAlwaysTop)
		{
			SetWindowPos (&CWnd::wndTop, rect.left, rectTab.top, 
				rect.Width(), rect.Height() + m_rectTab.Height (),
				SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOREDRAW);
		}
		else
		{
			SetWindowPos (&CWnd::wndTop, rect.left, rect.top, 
				rect.Width(), rect.Height() + m_rectTab.Height (),
				SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOREDRAW);
		}
		m_bShown = TRUE;
        RedrawWindow ();
    }
}
Example #19
0
void CWmfShape::OnPaint()  {
	CPaintDC dc(this); // device context for painting
	CRect	rcClient;
	CRgn	rgClip;

	GetClientRect( &rcClient );
	rgClip.CreateRectRgnIndirect( &rcClient );
	dc.SelectClipRgn( &rgClip, RGN_AND );
	
	if( NULL != m_pMetaFile ) {
		CPoint	ptZero( rcClient.left, ( rcClient.bottom + rcClient.top ) / 2 );
		CDRect	rcDraw( 0, 0, m_szPict.cx, m_szPict.cy );
		m_pMetaFile->Play( &dc, m_rcDraw, &ptZero, m_bSwapX, m_bSwapY );
	}
	DrawOffset( &dc );

	// Do not call CStatic::OnPaint() for painting messages
}
void CNOutBarCtrl::drawAll(CDC *pDC)
{
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CRect rcClient;
	GetClientRect(rcClient);
	CBitmap bm;
	bm.CreateCompatibleBitmap(pDC, rcClient.Width(), rcClient.Height());
	CBitmap *oldBitmap = memDC.SelectObject(&bm);

	int obj = HITOBJ(lastHit);
	int index = HITINDEX(lastHit);

	int i;
	for (i = folders.size() - 1; i >= 0; i--)
		drawFolder(&memDC, i, FALSE, (obj == HT_FOLDER && index == i));

	CRect rc;
	getInsideRect(rc);
	drawBackground(&memDC, rc);

	CRgn rgn;
	rgn.CreateRectRgnIndirect(rc);
	memDC.SelectClipRgn(&rgn);

	int max = getMaxVisibleItem();
	for (i = scrollPos(); i <= max; i++)
		drawItem(&memDC, i);

	if (obj == HT_ITEM)
		hilightItem(&memDC, index, FALSE);

	for (i = 1; i >= 0; i--) {
		if (canScroll(i))
			drawScroll(&memDC, i, pressedHit == MAKEHIT(HT_SCROLL, i));
	}

	pDC->BitBlt(0, 0, rcClient.Width(), rcClient.Height(), &memDC, 0, 0, SRCCOPY);

	memDC.SelectObject(oldBitmap);
}
Example #21
0
void CLoadEzdFile::OnDrawPreview()
{
	CWnd* pWnd = GetDlgItem(IDC_STATIC_WND);
	if(pWnd==NULL)
		return;    	
	//	pWnd = this;
	CRect rect;
    pWnd->GetClientRect(rect);
    rect.InflateRect(-2,-2);
    
	CDC* pDC = pWnd->GetDC(); 
	CRgn pRgn;
	pRgn.CreateRectRgnIndirect(rect);
	pDC->SelectClipRgn(&pRgn);
	
	//CBrush Brsh(GetSysColor(COLOR_BTNFACE));
	CBrush Brsh(RGB(255,255,255));
	pDC->FillRect(rect,&Brsh);	
	if(m_pPrevBmp != NULL)
    {//显示预览图片	
		CDC memDC;
		CBitmap* pOld=NULL;
		memDC.CreateCompatibleDC(pDC);
		
		pOld = memDC.SelectObject(m_pPrevBmp);
		
		BITMAP bm;
		m_pPrevBmp->GetBitmap(&bm);		
		CPoint ptCen = rect.CenterPoint ();
		::SetStretchBltMode(pDC->GetSafeHdc(), COLORONCOLOR);	
		
		pDC->BitBlt (ptCen.x - bm.bmWidth/2,ptCen.y - bm.bmHeight/2,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
		
		memDC.SelectObject(pOld);		
	}	
	
	pWnd->ReleaseDC( pDC );     
    return;

}
//*********************************************************************************************************
void CBCGPVisualManagerVS2008::OnEraseTabsButton (CDC* pDC, CRect rect,
											  CBCGPButton* pButton,
											  CBCGPBaseTabWnd* pBaseTab)
{
	ASSERT_VALID (pDC);
	ASSERT_VALID (pButton);
	ASSERT_VALID (pBaseTab);

	if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () ||
		!pBaseTab->IsVS2005Style () ||
		pBaseTab->IsDialogControl () ||
		pButton->IsPressed () || pButton->IsHighlighted ())
	{
		CBCGPVisualManagerVS2005::OnEraseTabsButton (pDC, rect, pButton, pBaseTab);
		return;
	}

	CRgn rgn;
	rgn.CreateRectRgnIndirect (rect);

	pDC->SelectClipRgn (&rgn);

	CFrameWnd* pMainFrame = BCGCBProGetTopLevelFrame (pButton);
	if (pMainFrame->GetSafeHwnd () != NULL)
	{
		CRect rectMain;
		pMainFrame->GetClientRect (rectMain);
		pMainFrame->MapWindowPoints (pButton, &rectMain);

		rect.top = rectMain.top;
		rect.left = rectMain.left;
		rect.right = rect.left + globalData.m_rectVirtual.Width () + 10;
	}

	CBCGPDrawManager dm (*pDC);
	dm.FillGradient (rect, m_clrBarGradientDark, m_clrBarGradientLight, FALSE, 0);

	pDC->SelectClipRgn (NULL);
}
Example #23
0
void CSettingsSpawn::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	CDC * pDC = m_csBGColor.GetDC();
	CRgn rgn;
	CRect rect;
	m_csBGColor.GetWindowRect( &rect );
	CBrush * pNewBrush = new (CBrush);
	pNewBrush->CreateSolidBrush( (COLORREF) m_dwSpawnBGColor );
	CBrush * pOldBrush = pDC->SelectObject(pNewBrush);
	CRect cr;
	m_csBGColor.GetClientRect(&cr);
	rgn.CreateRectRgnIndirect(cr);
	pDC->SelectClipRgn(&rgn);
	pDC->FillRect(cr, pNewBrush);
	pDC->SelectObject(pOldBrush);
	delete (pNewBrush);
	rgn.DeleteObject();
	m_csBGColor.ReleaseDC( pDC );

}
BOOL CSkinScrollWnd::_DoPaint()
{
	//bHandled = FALSE;
	CPaintDC dc ( m_hWnd );

	CRect rcClient;
	GetClientRect ( &rcClient );

	CRect rcFill;
	rcFill.SetRectEmpty();
	INT32 nLeft = 0, nTop = 0;

	if ( 1 == m_nAngleType ) // LeftScrollBar
	{
		nLeft = rcClient.left;
		nTop = rcClient.bottom - m_nScrollWidth;
		rcFill.SetRect ( nLeft, nTop, nLeft + m_nScrollWidth, nTop + m_nScrollWidth );
	}
	else if ( 2 == m_nAngleType )
	{
		nLeft = rcClient.right - m_nScrollWidth;
		nTop = rcClient.bottom - m_nScrollWidth;
		rcFill.SetRect ( nLeft, nTop, nLeft + m_nScrollWidth, nTop + m_nScrollWidth );
	}

	if ( !rcFill.IsRectEmpty() )
	{
		CRgn rgn;
		rgn.CreateRectRgnIndirect(&rcFill);
		dc.SelectClipRgn(rgn);


		dc.FillRect(rcFill, m_brBackground);
		m_imgCorner.Draw( dc.m_hDC, rcFill.left, rcFill.top, rcFill.Width(), rcFill.Height() );

	}
	return TRUE;
}
//*********************************************************************************************************
void CBCGPVisualManagerVS2008::OnDrawTabResizeBar (CDC* pDC, CBCGPBaseTabWnd* pWndTab, 
									BOOL bIsVert, CRect rect,
									CBrush* pbrFace, CPen* pPen)
{
	ASSERT_VALID (pDC);
	ASSERT_VALID (pbrFace);
	ASSERT_VALID (pPen);
	ASSERT_VALID (pWndTab);

	if (globalData.m_nBitsPerPixel <= 8 || globalData.IsHighContastMode () || pWndTab->IsFlatTab ())
	{
		CBCGPVisualManagerVS2005::OnDrawTabResizeBar (pDC, pWndTab, bIsVert, rect, pbrFace, pPen);
		return;
	}

	CRgn rgn;
	rgn.CreateRectRgnIndirect (rect);

	pDC->SelectClipRgn (&rgn);

	CFrameWnd* pMainFrame = BCGCBProGetTopLevelFrame (pWndTab);
	if (pMainFrame->GetSafeHwnd () != NULL)
	{
		CRect rectMain;
		pMainFrame->GetClientRect (rectMain);
		pMainFrame->MapWindowPoints (pWndTab, &rectMain);

		rect.top = rectMain.top;
		rect.left = rectMain.left;
		rect.right = rect.left + globalData.m_rectVirtual.Width () + 10;
	}

	CBCGPDrawManager dm (*pDC);
	dm.FillGradient (rect, m_clrBarGradientDark, m_clrBarGradientLight, FALSE, 0);

	pDC->SelectClipRgn (NULL);
}
Example #26
0
void CImageWnd::DisplayRoiTracker()
{
   if (m_pAppWnd == NULL)
      return;

   if (m_RectTracker.m_nStyle)
   {
      CRect rect;
      CWnd *pViewWnd;

      pViewWnd = m_pViewWnd != NULL ? m_pViewWnd : m_pAppWnd;

      pViewWnd->GetClientRect(&rect);

      CRgn clipRgn;
      clipRgn.CreateRectRgnIndirect(&rect);

      CClientDC dc(pViewWnd);
      dc.SelectClipRgn(&clipRgn);
      dc.SetWindowOrg(GetScrollPos(SB_HORZ), GetScrollPos(SB_VERT));

      m_RectTracker.Draw(&dc);
   }
}
Example #27
0
BOOL AFX_GLOBAL_DATA::DrawParentBackground(CWnd* pWnd, CDC* pDC, LPRECT rectClip)
{
	ASSERT_VALID(pDC);
	ASSERT_VALID(pWnd);

	BOOL bRes = FALSE;

	CRgn rgn;
	if (rectClip != NULL)
	{
		rgn.CreateRectRgnIndirect(rectClip);
		pDC->SelectClipRgn(&rgn);
	}

	CWnd* pParent = pWnd->GetParent();
	ASSERT_VALID(pParent);

	// In Windows XP, we need to call DrawThemeParentBackground function to implement
	// transparent controls
	bRes = DrawThemeParentBackground(pWnd->GetSafeHwnd(), pDC->GetSafeHdc(), rectClip) == S_OK;

	if (!bRes)
	{
		CPoint pt(0, 0);
		pWnd->MapWindowPoints(pParent, &pt, 1);
		pt = pDC->OffsetWindowOrg(pt.x, pt.y);

		bRes = (BOOL) pParent->SendMessage(WM_ERASEBKGND, (WPARAM)pDC->m_hDC);

		pDC->SetWindowOrg(pt.x, pt.y);
	}

	pDC->SelectClipRgn(NULL);

	return bRes;
}
Example #28
0
/*******************************************************************************
  Function Name  : DrawItem
  Input(s)       : LPDRAWITEMSTRUCT
  Output         : -
  Functionality  : overrided for drawing the Arrow direction for sort in
                   Column header field.
  Member of      : CListHdrCtrl
  Author(s)      : Arunkumar K
  Date Created   : 20-05-2010
  Modifications  :
*******************************************************************************/
void CRxMsgList::CListHdrCtrl::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    //Attach the column header HDC.
    CDC dc;
    dc.Attach(lpDrawItemStruct->hDC);
    // save device context.
    const int nSavedDCState = dc.SaveDC();
    // get the column rect.
    CRect rc(lpDrawItemStruct->rcItem);
    // set the clipping region to limit drawing within the column.
    CRgn rgn;
    rgn.CreateRectRgnIndirect(&rc);
    dc.SelectObject(&rgn);
    rgn.DeleteObject();
    // draw the background,
    CBrush brush(GetSysColor(COLOR_3DFACE));
    dc.FillRect(rc, &brush);
    // get the column text and format.
    char szText[ 256 ];
    HD_ITEM hditem;
    hditem.mask = HDI_TEXT | HDI_FORMAT;
    hditem.pszText = szText;
    hditem.cchTextMax = 255;
    GetItem(lpDrawItemStruct->itemID, &hditem);
    // determine the format for drawing the column label.
    UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS ;

    if(hditem.fmt & HDF_CENTER)
    {
        uFormat |= DT_CENTER;
    }
    else if(hditem.fmt & HDF_RIGHT)
    {
        uFormat |= DT_RIGHT;
    }
    else
    {
        uFormat |= DT_LEFT;
    }

    // adjust the rect if the mouse button is pressed on it.
    if(lpDrawItemStruct->itemState == ODS_SELECTED)
    {
        rc.left++;
        rc.top += 2;
        rc.right++;
    }

    CRect rcIcon(lpDrawItemStruct->rcItem);
    const int nOffset = (rcIcon.bottom - rcIcon.top) / 4;

    // adjust the rect further if the sort arrow is to be displayed.
    if(lpDrawItemStruct->itemID == (UINT)m_nSortCol)
    {
        rc.right -= 3 * nOffset;
    }

    rc.left += nOffset;
    rc.right -= nOffset;

    // draw the column label.
    if(rc.left < rc.right)
    {
        dc.DrawText(szText, -1, rc, uFormat);
    }

    // draw the sort arrow.
    if(lpDrawItemStruct->itemID == (UINT)m_nSortCol)
    {
        // set up the pens to use for drawing the arrow.
        CPen penLight(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
        CPen penShadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
        CPen* pOldPen = dc.SelectObject(&penLight);
        CDC dcMem;
        BITMAP bm;
        CBitmap bmpArrowDir;
        COLORMAP cm = {RGB(0, 0, 0), GetSysColor(COLOR_BTNTEXT)};
        dcMem.CreateCompatibleDC(&dc);

        if(m_bIsAscendingSort)
        {
            bmpArrowDir.LoadMappedBitmap(IDB_HDRUP, 0, &cm, 1);
            bmpArrowDir.GetBitmap(&bm);
            dcMem.SelectObject(&bmpArrowDir);
            dc.SetStretchBltMode(HALFTONE);
            dc.SetBkMode(TRANSPARENT);
            dc.StretchBlt(rcIcon.right-15, rcIcon.top+5, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCAND);
        }
        else
        {
            bmpArrowDir.LoadMappedBitmap(IDB_HDRDOWN, 0, &cm, 1);
            bmpArrowDir.GetBitmap(&bm);
            dcMem.SelectObject(&bmpArrowDir);
            dc.SetStretchBltMode(HALFTONE);
            dc.SetBkMode(TRANSPARENT);
            dc.StretchBlt(rcIcon.right-15, rcIcon.top+5, bm.bmWidth, bm.bmHeight, &dcMem, 0, 0, bm.bmWidth, bm.bmHeight, SRCAND);
        }

        bmpArrowDir.DeleteObject();
        // restore the pen.
        dc.SelectObject(pOldPen);
    }

    // restore the stored device context state.
    dc.RestoreDC(nSavedDCState);
    // detach the HDC before exit.
    dc.Detach();
}
Example #29
0
void CMyTreeCtrl::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	// Create a memory DC compatible with the paint DC
	CDC memDC;
	memDC.CreateCompatibleDC( &dc );
	
	CRect rcClip, rcClient;
	dc.GetClipBox( &rcClip );
	GetClientRect(&rcClient);

	// Select a compatible bitmap into the memory DC
	CBitmap bitmap;
	bitmap.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
	CBitmap *pOldBitmap=memDC.SelectObject( &bitmap );

	// Set clip region to be same as that in paint DC
	CRgn rgn;
	rgn.CreateRectRgnIndirect( &rcClip );
	memDC.SelectClipRgn(&rgn);
	rgn.DeleteObject();

	// First let the control do its default drawing.
	CWnd::DefWindowProc( WM_PAINT, (WPARAM)memDC.m_hDC, 0 );

	HTREEITEM hItem = GetFirstVisibleItem();
	
	int n = GetVisibleCount()+1;
	while( hItem && n--)
	{
		CRect rect;

		// Do not meddle with selected items or drop highlighted items
		UINT selflag = TVIS_DROPHILITED | TVIS_SELECTED;
		
		Color_Font cf;	
		if ( !(GetItemState( hItem, selflag ) & selflag ) && m_mapColorFont.Lookup( hItem, cf ))
		{
			CFont *pFontDC;
			CFont fontDC;

			LOGFONT logfont;
			
			if( cf.logfont.lfFaceName[0] != '\0' )
			{
				logfont = cf.logfont;
			}
			else
			{
				// No font specified, so use window font
				CFont *pFont = GetFont();
				pFont->GetLogFont( &logfont );
			}
			
			if( GetItemBold( hItem ) )
			{
				logfont.lfWeight = 700;
			}

			fontDC.CreateFontIndirect( &logfont );
			pFontDC = memDC.SelectObject( &fontDC );
			
			if( cf.color != (COLORREF)-1 )
			{
				memDC.SetTextColor( cf.color );
			}
			
			CString sItem = GetItemText( hItem );
			GetItemRect( hItem, &rect, TRUE );
			memDC.SetBkColor( GetSysColor( COLOR_WINDOW ) );
			memDC.TextOut( rect.left+2, rect.top+1, sItem );			

			memDC.SelectObject( pFontDC );
		}	
		hItem = GetNextVisibleItem( hItem );
	}

	dc.BitBlt( rcClip.left, rcClip.top, rcClip.Width(), rcClip.Height(), &memDC,
			   rcClip.left, rcClip.top, SRCCOPY );

	memDC.SelectObject(pOldBitmap);
	bitmap.DeleteObject();
}
Example #30
0
void CMyHeaderCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	CDC dc;
	VERIFY( dc.Attach( lpDrawItemStruct->hDC ) );
	const int iSavedDC = dc.SaveDC();
	CRect rc( lpDrawItemStruct->rcItem );
	CRgn rgn;
	VERIFY( rgn.CreateRectRgnIndirect( &rc ) );
	(void)dc.SelectObject( &rgn );
	VERIFY( rgn.DeleteObject() );
	CBrush brush( GetSysColor( COLOR_3DFACE ) );
	dc.SetBkMode(TRANSPARENT);
		int r1=GetRValue(m_clrBack);
		int g1=GetGValue(m_clrBack);
		int b1=GetBValue(m_clrBack);
		for(int i=rc.Height()/2;i>0;i--)
		{
			r1=(r1+5)>255?255:(r1+5);
			g1=(g1+5)>255?255:(g1+5);
			b1=(b1+5)>255?255:(b1+5);
			CPen pen(PS_SOLID, 1, RGB(r1, g1, b1));
			CPen *old = dc.SelectObject(&pen);
			dc.MoveTo(rc.left,rc.top+i);
			dc.LineTo(rc.right,rc.top+i);
			dc.MoveTo(rc.left,rc.bottom-i);
			dc.LineTo(rc.right,rc.bottom-i);
			dc.SelectObject(old);
		}	
	TCHAR szText[ 256 ];
	HD_ITEM hditem;
	hditem.mask = HDI_TEXT | HDI_FORMAT;
	hditem.pszText = szText;
	hditem.cchTextMax = 255;
	VERIFY( GetItem( lpDrawItemStruct->itemID, &hditem ) );
	UINT uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_NOCLIP | DT_VCENTER | DT_END_ELLIPSIS ;
	if( hditem.fmt & HDF_CENTER)
		uFormat |= DT_CENTER;
	else if( hditem.fmt & HDF_RIGHT)
		uFormat |= DT_RIGHT;
	else
		uFormat |= DT_LEFT;
	if( lpDrawItemStruct->itemState == ODS_SELECTED )
	{
		rc.left++;
		rc.top += 2;
		rc.right++;
	}
	CRect rcIcon( lpDrawItemStruct->rcItem );
	const int iOffset = ( rcIcon.bottom - rcIcon.top ) / 4;
	if( lpDrawItemStruct->itemID == (UINT)m_iSortColumn )
		rc.right -= 3 * iOffset;

	rc.left += iOffset;
	rc.right -= iOffset;
	if( rc.left < rc.right )
		(void)dc.DrawText( szText, -1, rc, uFormat );
	if( lpDrawItemStruct->itemID == (UINT)m_iSortColumn )
	{
		CPen penLight( PS_SOLID, 1,m_clrLeft);
		CPen penShadow( PS_SOLID, 1,m_clrRight);
		CPen* pOldPen = dc.SelectObject( &penLight );
		if( m_bSortAscending )
		{
			dc.MoveTo( rcIcon.right - 2 * iOffset, iOffset);
			dc.LineTo( rcIcon.right - iOffset, rcIcon.bottom - iOffset - 1 );
			dc.LineTo( rcIcon.right - 3 * iOffset - 2, rcIcon.bottom - iOffset - 1 );
			(void)dc.SelectObject( &penShadow );
			dc.MoveTo( rcIcon.right - 3 * iOffset - 1, rcIcon.bottom - iOffset - 1 );
			dc.LineTo( rcIcon.right - 2 * iOffset, iOffset - 1);		
		}
		else
		{
			dc.MoveTo( rcIcon.right - iOffset - 1, iOffset );
			dc.LineTo( rcIcon.right - 2 * iOffset - 1, rcIcon.bottom - iOffset );
			(void)dc.SelectObject( &penShadow );
			dc.MoveTo( rcIcon.right - 2 * iOffset - 2, rcIcon.bottom - iOffset );
			dc.LineTo( rcIcon.right - 3 * iOffset - 1, iOffset );
			dc.LineTo( rcIcon.right - iOffset - 1, iOffset );		
		}
		(void)dc.SelectObject( pOldPen );
	}
	VERIFY( dc.RestoreDC( iSavedDC ) );
	(void)dc.Detach();
}