Пример #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();
}
Пример #2
0
int COXSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
	{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if ((HRGN)m_rgn != NULL)
		{
		CRgn rgn;
		rgn.CreateRectRgn(0,0,1,1);
		switch(rgn.CopyRgn(&m_rgn))
			{
			case ERROR:
				TRACE0("COXSplashWnd::OnCreate(): fail to load the calculated region.\r\n");
				rgn.DeleteObject();
				break;
			case NULLREGION:
				TRACE0("COXSplashWnd::OnCreate(): empty region was encountered.\r\n");
				rgn.DeleteObject();
				break;
			default:
				::SetWindowRgn(m_hWnd, (HRGN)rgn.Detach(), TRUE);
			}
		}
	
	CenterWindow();
	if (m_nTimeout != SPLASH_NOTIMER)
		SetTimer(OXSPLASHWND_TIMERID_HIDE, m_nTimeout, NULL);

	SetCapture();
	::SetCursor(::LoadCursor(NULL, IDC_ARROW));
	
	return 0;
	}
Пример #3
0
BOOL CTyBase::PointRgn(float x, float y, int Numble, PointStruct *PointList, float blc)
{
	CRgn rgn; 
	int x1,y1,i;
	CPoint bbcc[MAXPOINTNUM];
	
	if(Numble < 3) 
		return 0;//如果点的数目<3即不是一个区域返回不成功标志

	ASSERT(Numble <= MAXPOINTNUM);

	//将点的坐标转变成屏幕坐标
	x1 = (int)(x/blc);
	y1 = (int)(y/blc);

	//将封闭区域各点的坐标转成屏幕坐标
	for(i = 0;i < Numble;i++)
	{
		bbcc[i].x = (int)((PointList[i].x)/blc);
		bbcc[i].y = (int)((PointList[i].y)/blc);
	}

	rgn.CreatePolygonRgn(bbcc,Numble,1);//初试化一个多边形区域
	i = (rgn.PtInRegion(x1,y1)!=0);		//如果在区域内j=1,否则j=0;
	rgn.DeleteObject();					        //删除定义的rgn对象

	return i;
}
Пример #4
0
void CScoreView::SetupRgn(CDC *pDC,CSkinImage bImage,COLORREF TransColor)
{
	//bImage.GetWidth()/5;
	tagImageLoadInfo ImageIDB;
	bImage.GetLoadInfo(ImageIDB);
	CBitmap cBitmap;
	cBitmap.LoadBitmap(ImageIDB.uResourceID);//这个BITMAP是5倍长的,所以会有问题死机。
	CDC memDC;
	//创建与传入DC兼容的临时DC
	memDC.CreateCompatibleDC(pDC);

	CBitmap *pOldMemBmp=NULL;
	//将位图选入临时DC
	pOldMemBmp=memDC.SelectObject(&cBitmap);

	CRgn wndRgn;
	//创建总的窗体区域,初始region为0
	wndRgn.CreateRectRgn(0,0,0,0);


	BITMAP bit;   
	cBitmap.GetBitmap (&bit);//取得位图参数,这里要用到位图的长和宽     

	int y;
	for(y=0;y<=bit.bmHeight  ;y++)
	{
		CRgn rgnTemp; //保存临时region

		int iX = 0;
		do
		{
			//跳过透明色找到下一个非透明色的点.
			while (iX <= bit.bmWidth  && memDC.GetPixel(iX, y) == TransColor)
				iX++;

			//记住这个起始点
			int iLeftX = iX;

			//寻找下个透明色的点
			while (iX <= bit.bmWidth  && memDC.GetPixel(iX, y) != TransColor)
				++iX;

			//创建一个包含起点与重点间高为1像素的临时“region”
			rgnTemp.CreateRectRgn(iLeftX, y, iX, y+1);

			//合并到主"region".
			wndRgn.CombineRgn(&wndRgn, &rgnTemp, RGN_OR);

			//删除临时"region",否则下次创建时和出错
			rgnTemp.DeleteObject();
		}while(iX <bit.bmWidth );
		iX = 0;
	}
	if(pOldMemBmp)
		memDC.SelectObject(pOldMemBmp);
	CWnd * pWnd = pDC->GetWindow();
	pWnd->SetWindowRgn(wndRgn,TRUE);
	pWnd->SetForegroundWindow();   
} 
Пример #5
0
void CScoreView::SetupRgn(CDC *pDC,				//窗体的DC指针
						  CBitmap &cBitmap,		//含有窗体形状的位图对象
						  // CSkinImage skinImage,
						  COLORREF TransColor)	//透明色
{

	CDC memDC;
	//创建与传入DC兼容的临时DC
	memDC.CreateCompatibleDC(pDC);

	CBitmap *pOldMemBmp=NULL;
	//将位图选入临时DC
	pOldMemBmp=memDC.SelectObject(&cBitmap);

	CRgn wndRgn;
	//创建总的窗体区域,初始region为0
	wndRgn.CreateRectRgn(0,0,0,0);


	BITMAP bit;   
	cBitmap.GetBitmap (&bit);//取得位图参数,这里要用到位图的长和宽     

	int y;
	for(y=0;y<=bit.bmHeight  ;y++)
	{
		CRgn rgnTemp; //保存临时region

		int iX = 0;
		do
		{
			//跳过透明色找到下一个非透明色的点.
			while (iX <= bit.bmWidth  && memDC.GetPixel(iX, y) == TransColor)
				iX++;

			//记住这个起始点
			int iLeftX = iX;

			//寻找下个透明色的点
			while (iX <= bit.bmWidth  && memDC.GetPixel(iX, y) != TransColor)
				++iX;

			//创建一个包含起点与重点间高为1像素的临时“region”
			rgnTemp.CreateRectRgn(iLeftX, y, iX, y+1);

			//合并到主"region".
			wndRgn.CombineRgn(&wndRgn, &rgnTemp, RGN_OR);

			//删除临时"region",否则下次创建时和出错
			rgnTemp.DeleteObject();
		}while(iX <bit.bmWidth );
		iX = 0;
	}
	if(pOldMemBmp)
		memDC.SelectObject(pOldMemBmp);
	//HRGN wndRgn=skinImage.CreateImageRegion(RGB(255,0,255));
	CWnd * pWnd = pDC->GetWindow();
	pWnd->SetWindowRgn(wndRgn,TRUE);    
	pWnd->SetForegroundWindow();    
}
Пример #6
0
//重画函数
void CScoreView::OnPaint() 
{
	CPaintDC dc(this); 

	//设置 DC
	dc.SetBkMode(TRANSPARENT);
	dc.SetTextColor(RGB(255,255,255));
	dc.SelectObject(CSkinResourceManager::GetDefaultFont());

	//设置区域
	CRect rt;
	GetClientRect(&rt);
	CRgn WndRgn;
	WndRgn.CreateRoundRectRgn(rt.left,rt.top,rt.right,rt.bottom,10,10);
	SetWindowRgn(WndRgn,TRUE);
	WndRgn.DeleteObject();

	//绘画背景
	CImageHandle ImageHandle(&m_ImageBack);
	m_ImageBack.BitBlt(dc,0,0);

	//显示分数
	WORD wStation=0;
	TCHAR szBuffer[64]=TEXT("");
	CImageHandle HandleWinLose(&m_ImageWinLose);
	INT nWinLoseWidth = m_ImageWinLose.GetWidth()/3;
	INT nWinLostHeight = m_ImageWinLose.GetHeight();
	for (WORD i=0;i<CountArray(m_szUserName);i++)
	{
		if (m_szUserName[i][0]!=0)
		{
			//输出名字
			CRect rcName(28,wStation*29+79,117,(wStation+1)*29+79);
			dc.DrawText(m_szUserName[i],lstrlen(m_szUserName[i]),&rcName,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

			//输出成绩
			CRect rcScore(117,wStation*29+79,182,(wStation+1)*29+79);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lScore[i]);
			dc.DrawText(szBuffer,lstrlen(szBuffer),&rcScore,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

			//胜负标志
			BYTE byIndex = 0;
			if( m_lScore[i] == 0 ) byIndex = 2;
			else if( m_lScore[i] < 0 ) byIndex = 1;
			m_ImageWinLose.AlphaDrawImage(&dc,182+(253-182)/2-nWinLoseWidth/2,wStation*29+79+29/2-nWinLostHeight/2,nWinLoseWidth,nWinLostHeight,
				byIndex*nWinLoseWidth,0,RGB(255,0,255));

			//服务费用
			CRect rcService(253,wStation*29+79,321,(wStation+1)*29+79);
			_snprintf(szBuffer,sizeof(szBuffer),TEXT("%ld"),m_lGameTax[i]);
			dc.DrawText(szBuffer,lstrlen(szBuffer),&rcService,DT_CENTER|DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

			//设置变量
			wStation++;
		}
	}

	return;
}
Пример #7
0
BOOL GetRegionfromBitmap(RECT r, CRgn *pRgn, CBitmap *pBitmap, COLORREF keyColor, COLORREF cTolerance)
{
	if (!pBitmap) 
		return FALSE;

	if (!pRgn) 
		return FALSE;

	BYTE lr = (BYTE)max(0, (int)GetRValue(keyColor) - (int)GetRValue(cTolerance));
	BYTE lg = (BYTE)max(0, (int)GetGValue(keyColor) - (int)GetGValue(cTolerance));
	BYTE lb = (BYTE)max(0, (int)GetBValue(keyColor) - (int)GetBValue(cTolerance));
	BYTE hr = (BYTE)min((int)0xff, (int)GetRValue(keyColor) + (int)GetRValue(cTolerance));
	BYTE hg = (BYTE)min((int)0xff, (int)GetGValue(keyColor) + (int)GetGValue(cTolerance));
	BYTE hb = (BYTE)min((int)0xff, (int)GetBValue(keyColor) + (int)GetBValue(cTolerance));

	CDC					memDC;
	CBitmap				*pOldMemBmp = NULL;
	CRect				cRect(r);
	int					x, y;
	int					n=0;		//number of transparent pixels
	CRgn				rgnTemp;

	memDC.CreateCompatibleDC(NULL);
	pOldMemBmp = memDC.SelectObject(pBitmap);
	pRgn->CreateRectRgn(0, 0, cRect.Width(), cRect.Height());

	//COLORREF m_Color = memDC.GetPixel(0, 0);
	for (x = 0; x <= r.right - r.left; x++)
	{
		for (y = 0; y <= r.bottom - r.top; y++)
		{
			COLORREF cr = memDC.GetPixel(x,y);
			BYTE b = GetRValue(cr);
			if (lr <= b && b <= hr) 
			{
				b = GetGValue(cr);
				if (lg <= b && b <= hg) 
				{
					b = GetBValue(cr);
					if (lb <= b && b <= hb) 
					{
						rgnTemp.CreateRectRgn(x, y, x + 1, y + 1);
						pRgn->CombineRgn(pRgn, &rgnTemp, RGN_XOR);
						rgnTemp.DeleteObject();	
						++n;
					}
				}
			}
		}
	}

	if (pOldMemBmp) 
		memDC.SelectObject(pOldMemBmp);
	memDC.DeleteDC();

	return n > 0;
}
Пример #8
0
void CProgressCtrlX::DrawClippedText(const CDrawInfo& info, const CRect& rcClip, CString& sText, const CPoint& ptWndOrg)
{
	CDC *pDC = info.pDC;
	CRgn rgn;
	CRect rc = ConvertToReal(info, rcClip);
	rc.OffsetRect(-ptWndOrg);
	rgn.CreateRectRgn(rc.left, rc.top, rc.right, rc.bottom);
	pDC->SelectClipRgn(&rgn);
	pDC->TextOut (0, 0, sText);
	rgn.DeleteObject();
}
Пример #9
0
HRGN CSkinWin::GetRegion(int w, int h)
{
    CWnd *pWnd = CWnd::FromHandle(m_hWnd);
    CRect wr;
    pWnd->GetWindowRect(wr);
	//SKIN_SHANG 右边框
	//wr.left+=m_BorderRightWidth;
    
    CRgn rgn;
    if ( m_bTrans )
    {
        CDC *pDC = pWnd->GetDC();
        CDC memDC;
        CMyBitmap bmp;
        CBitmap *obmp;
        memDC.CreateCompatibleDC(pDC);
        bmp.CreateCompatibleBitmap( pDC, w, m_TitleHeight );
        obmp = memDC.SelectObject(&bmp);
        /*
        memDC.FillSolidRect( 0, 0, w, h, 0 );
        DrawFrame( &memDC, 0, 0, w, h, 0 );
        */
        DrawTitle( &memDC, m_BorderLeftWidth , 0, 
                   wr.Width() - m_BorderRightWidth - m_BorderLeftWidth + 1, 0 );
        DrawLeft( &memDC, 0, 0, m_bmpLeft.Height(), 0 );
		//SKIN_SHANG 右边框
        DrawRight( &memDC, wr.Width() - m_BorderRightWidth , 0, m_bmpRight.Height(), 0 );
        
        memDC.SelectObject(obmp);

		//wyw
		memDC.DeleteDC();

        pWnd->ReleaseDC( pDC );

        rgn.CreateRectRgn( 0, m_TitleHeight, wr.Width(), wr.Height() );
        HRGN hrgn = bmp.CreateRgnFromFile( m_colTrans );
        CRgn newrgn;
        newrgn.CreateRectRgn( 0, m_TitleHeight, wr.Width(), wr.Height() );
        newrgn.CombineRgn( &rgn, CRgn::FromHandle(hrgn), RGN_XOR  );

		//wyw
		bmp.DeleteObject();
		DeleteObject(hrgn);
		rgn.DeleteObject();
        
        return (HRGN)newrgn.Detach();
    }
    else
        rgn.CreateRectRgn( 0, 0, wr.Width(), wr.Height() );
        
    
    return (HRGN)rgn.Detach();
}
Пример #10
0
BOOL CScoreView::OnEraseBkgnd(CDC* pDC)
{
	//
	CRect rt;
	GetClientRect(&rt);
	CRgn WndRgn;
	WndRgn.CreateRoundRectRgn(rt.left,rt.top,rt.right+1,rt.bottom+1,10,10);
	SetWindowRgn(WndRgn,TRUE);
	WndRgn.DeleteObject();
	return TRUE;
	//return CWnd::OnEraseBkgnd(pDC);
}
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();
	}
}
Пример #12
0
BOOL CSkinButton::GetRegion()
{
    CMyBitmap bmp;
    CRgn rgn;
    rgn.CreateEllipticRgn( 00, 00, 50, 50 );
    SetWindowRgn((HRGN)rgn.Detach(), TRUE );

	//wyw
#if 1
	rgn.DeleteObject();
#endif

    return TRUE;
}
Пример #13
0
void cGraphicsMFC::setClipRegion(cRealBox *pclipbox)
{
	if (!pclipbox)
		_pMemDC->SelectClipRgn(NULL); //Makes the clipping region the client window.
	else
	{
		CRgn cliprgn; //Temporary region used as a kind of scratchpad.
		CRect crectclipbox = realBoxToCRect(*pclipbox);
		cliprgn.CreateRectRgn(crectclipbox.left, crectclipbox.top, crectclipbox.right,
			crectclipbox.bottom);
		_pMemDC->SelectClipRgn(&cliprgn); //Makes a copy of cliprgn.
		cliprgn.DeleteObject(); //Need to do this, or resource leak!  CRgn destructor won't do it.
	}
} 
Пример #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;
}
Пример #15
0
//添加Owner Draw属性
void CMyButton::PreSubclassWindow()
{
    // TODO: Add your specialized code here and/or call the base class
    ModifyStyle(0, BS_OWNERDRAW);

    //设置按钮的有效区域,消除残角
    CRgn rgn;
    RECT rect;
    GetClientRect(&rect);

    //有效区域是一个角半径为5的圆角矩形
    rgn.CreateRoundRectRgn(rect.left,rect.top,rect.right,rect.bottom,5,5);
    SetWindowRgn(rgn,TRUE);
    rgn.DeleteObject();
    CButton::PreSubclassWindow();
}
Пример #16
0
void CTextProgressCtrl::OnPaint() 
{
    if (m_nMin >= m_nMax) 
        return;

    CRect LeftRect, RightRect, ClientRect;
    GetClientRect(ClientRect);

    double Fraction = (double)(m_nPos - m_nMin) / ((double)(m_nMax - m_nMin));

    CPaintDC PaintDC(this); // device context for painting
    CMyMemDC dc(&PaintDC);
    //CPaintDC dc(this);    // device context for painting (if not double buffering)

    LeftRect = RightRect = ClientRect;

    LeftRect.right = LeftRect.left + (int)((LeftRect.right - LeftRect.left)*Fraction);
    dc.FillSolidRect(LeftRect, m_colFore);

    RightRect.left = LeftRect.right;
    dc.FillSolidRect(RightRect, m_colBk);

    if (m_bShowText)
    {
        CString str;
        if (m_strText.GetLength())
            str = m_strText;
        else
            str.Format(_T("%d%%"), (int)(Fraction*100.0));

        dc.SetBkMode(TRANSPARENT);

        CRgn rgn;
        rgn.CreateRectRgn(LeftRect.left, LeftRect.top, LeftRect.right, LeftRect.bottom);
        dc.SelectClipRgn(&rgn);
        dc.SetTextColor(m_colTextBk);

        dc.DrawText(str, ClientRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

        rgn.DeleteObject();
        rgn.CreateRectRgn(RightRect.left, RightRect.top, RightRect.right, RightRect.bottom);
        dc.SelectClipRgn(&rgn);
        dc.SetTextColor(m_colTextFore);

        dc.DrawText(str, ClientRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
    }
}
Пример #17
0
void TextProgressCtrl::OnPaint(void)
{
    CPaintDC sPaintDC(this);

    MemDC sMemDC(&sPaintDC);

    CRect sClientRect;
    GetClientRect(sClientRect);

    xpr_double_t sFraction = 0.0;
    if ((mMax - mMin) > 0)
        sFraction = (xpr_double_t)(mPos - mMin) / ((xpr_double_t)(mMax - mMin));

    CRect sProgressRect(sClientRect);
    sProgressRect.right = sProgressRect.left + (xpr_sint_t)(sProgressRect.Width() * sFraction);

    CRect sBackRect(sClientRect);
    sBackRect.left = sProgressRect.right;

    sMemDC.FillSolidRect(sProgressRect, mProgressColor);
    sMemDC.FillSolidRect(sBackRect, mBackColor);

    if (XPR_IS_TRUE(mShowText))
    {
        xpr_tchar_t sText[0xff] = {0};
        _stprintf(sText, XPR_STRING_LITERAL("%d%%"), (xpr_sint_t)(sFraction * 100.0));

        CFont *sOldFont = sMemDC.SelectObject(&mTextFont);
        sMemDC.SetBkMode(TRANSPARENT);

        CRgn sRgn;
        sRgn.CreateRectRgn(sProgressRect.left, sProgressRect.top, sProgressRect.right, sProgressRect.bottom);
        sMemDC.SelectClipRgn(&sRgn);
        sMemDC.SetTextColor(mTextBackColor);

        sMemDC.DrawText(sText, sClientRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

        sRgn.DeleteObject();
        sRgn.CreateRectRgn(sBackRect.left, sBackRect.top, sBackRect.right, sBackRect.bottom);
        sMemDC.SelectClipRgn(&sRgn);
        sMemDC.SetTextColor(mTextProgressColor);

        sMemDC.DrawText(sText, sClientRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);

        sMemDC.SelectObject(sOldFont);
    }
}
Пример #18
0
// @pymethod int|PyCRgn|DeleteObject|Deletes the attached Windows GDI Rgn object from memory by freeing all system storage associated with the Windows GDI object
// Return Values: None
PyObject *
PyCRgn::delete_object(PyObject *self, PyObject *args)
	{
	CRgn *pRgn = PyCRgn::GetRgn(self);
	if (!pRgn) return NULL;

	CHECK_NO_ARGS2(args,DeleteObject);
	
	BOOL ok=TRUE;
	if(pRgn->GetSafeHandle())
		ok=pRgn->DeleteObject();
	if(!ok)
		RETURN_ERR("DeleteObject failed");
	pRgn->m_hObject=0; // assert 

	RETURN_NONE;
	}
Пример #19
0
//初始化函数
BOOL CScoreView::OnInitDialog()
{
	__super::OnInitDialog();

	//设置数据
	m_lBaseScore=0L;
	m_lGameTax=0L;
	memset(m_lGameScore,0,sizeof(m_lGameScore));
	memset(m_szUserName,0,sizeof(m_szUserName));

	//设置界面
	SetClassLong(m_hWnd,GCL_HBRBACKGROUND,NULL);

	//居中窗口
	CenterWindow(GetParent());

	CImageHandle ImageHandle(&m_ImageBack);
	if (ImageHandle.IsResourceValid())
	{
		//创建临时图
		CSkinImage BufferImage;
		int nImageWidth=m_ImageBack.GetWidth();
		int nImageHeight=m_ImageBack.GetHeight();
		BufferImage.Create(nImageWidth,nImageHeight,32);
		ImageHandle->BitBlt(BufferImage.GetDC(),0,0,nImageWidth,nImageHeight,0,0);
		BufferImage.ReleaseDC();

		//创建区域
		CRgn ImageRgn;
		BufferImage.CreateImageRegion( ImageRgn, RGB( 255, 0, 255 ) );
		if ( (( HRGN )ImageRgn) !=NULL)
		{
			SetWindowPos(NULL,0,0,nImageWidth,nImageHeight,SWP_NOMOVE);
			SetWindowRgn(( HRGN )ImageRgn,TRUE);

			ImageRgn.DeleteObject();

			return true;
		}
	}


	return TRUE;
}
Пример #20
0
//////////////////
// Compute the the points, rect and region for a tab.
// Input x is starting x pos.
//
int CFolderTab::ComputeRgn(CDC& dc, int x)
{
	m_rgn.DeleteObject();

	CRect& rc = m_rect;
	rc.SetRectEmpty();

	// calculate desired text rectangle
	dc.DrawText(m_sText, &rc, DT_CALCRECT);
	rc.right  += 2*CXOFFSET + 2*CXMARGIN;						// add margins
	rc.bottom = rc.top + GetSystemMetrics(SM_CYHSCROLL);	// ht = scrollbar ht
	rc += CPoint(x,0);												// shift right

	// create trapezoid region
	CPoint pts[4];
	GetTrapezoid(rc, pts);
	m_rgn.CreatePolygonRgn(pts, 4, WINDING);

	return rc.Width();
}
Пример #21
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 );

}
Пример #22
0
void CDrawCommon::GetRegionFromImage(CRgn& rgn, CBitmap &cBitmap, int threshold)
{
	CDC memDC;

	memDC.CreateCompatibleDC(NULL);
	CBitmap *pOldMemBmp = NULL;
	pOldMemBmp = memDC.SelectObject(&cBitmap);

	//创建总的窗体区域,初始region为0
	rgn.CreateRectRgn(0, 0, 0, 0);

	BITMAP bit;
	cBitmap.GetBitmap(&bit);//取得位图参数,这里要用到位图的长和宽
	int y;
	for (y = 0; y<bit.bmHeight; y++)
	{
		CRgn rgnTemp; //保存临时region
		int iX = 0;
		do
		{
			//跳过透明色找到下一个非透明色的点.
			while (iX < bit.bmWidth && GetColorBritness(memDC.GetPixel(iX, y)) <= threshold)
				iX++;
			int iLeftX = iX; //记住这个起始点

							 //寻找下个透明色的点
			while (iX < bit.bmWidth && GetColorBritness(memDC.GetPixel(iX, y)) > threshold)
				++iX;

			//创建一个包含起点与重点间高为1像素的临时“region”
			rgnTemp.CreateRectRgn(iLeftX, y, iX, y + 1);
			rgn.CombineRgn(&rgn, &rgnTemp, RGN_OR);

			//删除临时"region",否则下次创建时和出错
			rgnTemp.DeleteObject();
		} while (iX < bit.bmWidth);
	}
}
Пример #23
0
//--------------------------------------------------------------------------
// 선택 지점의 좌표 포인트 반환
//--------------------------------------------------------------------------
int GLine::FindSelectPoint(CPoint pt) {
	
	int tempThick = (GObject::m_nsThickness > 4 ? GObject::m_nsThickness : 5); // 기본 크기는 5 
	
	CRgn rgn;
	CPoint tempPt = GObject::m_sStartPoint;
	rgn.CreateEllipticRgn(tempPt.x - tempThick, tempPt.y - tempThick, tempPt.x + tempThick, tempPt.y + tempThick); // 리전 생성

	// 시작점이 Rgn 안에 있으며 시작점이 선택
	if(rgn.PtInRegion(pt) == TRUE) {
		return 0;
	}

	tempPt = GObject::m_sEndPoint;
	rgn.DeleteObject();
	rgn.CreateEllipticRgn(tempPt.x - tempThick, tempPt.y - tempThick, tempPt.x + tempThick, tempPt.y + tempThick); // 리전 생성

	// 끝점이 선택된 경우
	if(rgn.PtInRegion(pt) == TRUE) {
		return 4;
	}
	return -1;
}
Пример #24
0
//添加Owner Draw属性
void CButtonXP::PreSubclassWindow() 
{
	// TODO: Add your specialized code here and/or call the base class
	ModifyStyle(0, BS_OWNERDRAW);
	CButton::PreSubclassWindow();

	// Set initial default state flag
	if(m_nTypeStyle == BS_DEFPUSHBUTTON)
	{
		m_nTypeStyle = BS_PUSHBUTTON;
	} 

	//设置按钮的有效区域
	CRgn rgn;
	CRect rc;
	GetClientRect(&rc);

	//有效区域为一个角半径为5的圆角矩形
	rgn.CreateRoundRectRgn(rc.left, rc.top, rc.right, rc.bottom, 5, 5);

	SetWindowRgn(rgn, TRUE);

	rgn.DeleteObject();
}
Пример #25
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();
}
Пример #26
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();
}
Пример #27
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();
}
Пример #28
0
void CPtEmtDytCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	pdc->FillRect(rcBounds.operator LPCRECT(), CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	if (FALSE == m_PtEmt.IsGrayOK())	{
		pdc->SetTextAlign(TA_CENTER|TA_BASELINE);
		CString pszText = _T("PtEmtDyt");
		pdc->TextOut(rcBounds.Width() / 2, rcBounds.Height() / 2, pszText);
	}	else	{
		CRect rect(rcBounds);

		FLOAT winDiameter = rect.Width() * 1.0f;
		
		if (rect.Width() > rect.Height()) {
			winDiameter = rect.Height() * 1.0f;
		}

		winDiameter *= 0.9f;
		const FLOAT Diameter = 0.13f;
		m_Scale = winDiameter /Diameter;
		m_Center = CPoint(rect.right / 2, rect.bottom / 2);
		
		FLOAT mingray(1e20f), maxgray(-1e20f);
		
		for(SHORT i = 0; i < TotalElement; i++)
		{
			maxgray = max(maxgray, m_PtEmt.GetMGray(i));
			mingray = min(mingray, m_PtEmt.GetMGray(i));
		}
		
		TEXTMETRIC tm;
		CString str;
		CRgn rgn;
		CBrush br;	
		pdc->GetTextMetrics(&tm);
		CPoint ColorBarPoint(10, int(m_Center.y * 2.0 / 3 + 10 * tm.tmHeight));
		for(i = 0; i < lColorNum ;i++)
		{
			CRect rt(ColorBarPoint.x, ColorBarPoint.y-tm.tmHeight,
				ColorBarPoint.x+20, ColorBarPoint.y);
			br.CreateSolidBrush(lColorBegin + lColorEnd * (lColorNum-i-1) * lColorNum);
			pdc->FillRect(rt.operator LPCRECT(), &br);
			FLOAT ruler = mingray + (maxgray-mingray)*FLOAT(i)/(lColorNum - 1);
			str.Format(_T("%e"), ruler);
			ColorBarPoint.y -= tm.tmHeight;
			pdc->TextOut(ColorBarPoint.x + 23, ColorBarPoint.y, str);
			br.DeleteObject();
		}
		
		// Draw Gray Picture
		for (i = 0 ; i < InsideElement; i++)
		{
			if (fabs(m_PtEmt.GetMGray(i)) > 0.000001) 
			{
				CPoint point[4];
				for(SHORT j = 0; j < 4; j++)	{
					point[j] = _PToL(m_PtEmt.GetNodes(i, j));
				}
				
				SHORT clrLevel = SHORT((lColorNum-1) * (m_PtEmt.GetMGray(i)-mingray) / (maxgray-mingray));
				rgn.CreatePolygonRgn(point,4, ALTERNATE); 
				br.CreateSolidBrush(lColorBegin + lColorEnd * (lColorNum-clrLevel-1) * lColorNum);
				pdc->FillRgn(&rgn, &br);
				br.DeleteObject();
				rgn.DeleteObject();
			}
		}
		
		for (i=0; i < DetectorNum; i++)
		{
			FLOAT startangle,stopangle;
			POINT startpoint,stoppoint;
			COMPLEX startnode,stopnode;
			int CurDR = int(DetectorRadius * m_Scale);
			
			startangle = FLOAT(PIE*(2*i+1)/DetectorNum-DetectorAngle/2.0*PIE/180.0);
			stopangle = FLOAT(startangle+DetectorAngle*PIE/180.0);		
			startnode = COMPLEX(DetectorRadius*cos(startangle), DetectorRadius*sin(startangle));
			stopnode = COMPLEX(DetectorRadius*cos(stopangle), DetectorRadius*sin(stopangle));
			startpoint = _PToL(startnode);
			stoppoint = _PToL(stopnode);
			pdc->Arc(m_Center.x-CurDR + 60,m_Center.y-CurDR,m_Center.x+CurDR + 60,m_Center.y+CurDR,
				startpoint.x,startpoint.y,stoppoint.x,stoppoint.y);
		}
		
		CPoint pul, plr, pst;
		pul = _PToL(COMPLEX(-PipeRadius, -PipeRadius));
		plr = _PToL(COMPLEX(PipeRadius, PipeRadius));
		pst = _PToL(COMPLEX(PipeRadius, 0.0));
		pdc->Arc(pul.x,pul.y,plr.x,plr.y,pst.x,pst.y,pst.x,pst.y);
		
		pul = _PToL(COMPLEX(-ScreenRadius, -ScreenRadius));
		plr = _PToL(COMPLEX(ScreenRadius, ScreenRadius));
		pst = _PToL(COMPLEX(ScreenRadius, 0.0));
		pdc->Arc(pul.x,pul.y,plr.x,plr.y,pst.x,pst.y,pst.x,pst.y);			
	}
}
void CSortHeaderCtrl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	// attath to the device context.
	CDC dc;
	VERIFY( dc.Attach( lpDrawItemStruct->hDC ) );

	// save the device context.
	const int iSavedDC = dc.SaveDC();

	// get the column rect.
	CRect rc( lpDrawItemStruct->rcItem );

	// set the clipping region to limit drawing within the column.
	CRgn rgn;
	VERIFY( rgn.CreateRectRgnIndirect( &rc ) );
	(void)dc.SelectObject( &rgn );
	VERIFY( rgn.DeleteObject() );

	// draw the background,
	CBrush brush( GetSysColor( COLOR_3DFACE ) );
	dc.FillRect( rc, &brush );

	// get the column text and format.
	TCHAR szText[ 256 ];
	HD_ITEM hditem;

	hditem.mask = HDI_TEXT | HDI_FORMAT;
	hditem.pszText = szText;
	hditem.cchTextMax = 255;

	VERIFY( 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 iOffset = ( rcIcon.bottom - rcIcon.top ) / 4;

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

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

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

	// draw the sort arrow.
	if( lpDrawItemStruct->itemID == (UINT)m_iSortColumn )
	{
		// 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 );

		if( m_bSortAscending )
		{
			// draw the arrow pointing upwards.
			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
		{
			// draw the arrow pointing downwards.
			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 );		
		}

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

	// restore the previous device context.
	VERIFY( dc.RestoreDC( iSavedDC ) );

	// detach the device context before returning.
	(void)dc.Detach();
}
Пример #30
0
void CSkinWin::OnNcPaint(HRGN rgn1)
{  
    CWnd *pWnd = CWnd::FromHandle(m_hWnd);
    CDC * pDC = pWnd->GetWindowDC();
    CRect wr;
    pWnd->GetWindowRect( wr );
    //SKIN_SHANG 右边框
	//wr.left+=m_BorderRightWidth;

    DWORD style = GetWindowLong( m_hWnd, GWL_STYLE );
    DWORD nCaption = style & WS_CAPTION ;
    if (nCaption == 0)
	{
		//wyw
		pWnd->ReleaseDC(pDC);

        return;
    }

//f ( (DWORD)rgn) 
//pDC->SelectClipRgn( CRgn::FromHandle(rgn) );

    //m_bActive = GetActiveWindow() == m_hWnd;
    int state = 0;
    if ( m_bActive)
        state = 0;
    else 
		state = 1;
    
    pDC->ExcludeClipRect(0, 0, wr.Width(), m_TitleHeight );
    DrawFrame(pDC, 0, 0, wr.Width(), wr.Height(), state, 0);    
    pDC->SelectClipRgn( NULL ); 

    CDC memDC, *pNewDC;
    CMyBitmap bmp;
    CBitmap  *obmp;
    memDC.CreateCompatibleDC( pDC );
    bmp.CreateCompatibleBitmap( pDC, wr.Width(), m_TitleHeight );
    obmp = memDC.SelectObject(&bmp);
    pNewDC = &memDC;
    
    DrawTitle( pNewDC, m_BorderLeftWidth , 0, 
               wr.Width() - m_BorderRightWidth - m_BorderLeftWidth + 1, state );
    DrawLeft( pNewDC, 0, 0, m_bmpLeft.Height(), state );
	//SKIN_SHANG 右边框
    DrawRight( pNewDC, wr.Width() - m_BorderRightWidth , 0, m_bmpRight.Height(), state );
    
    CRgn newrgn;
    newrgn.CreateRectRgn( 0, 0, wr.Width(), wr.Height());

    if ( m_bTrans )
	{
		CRgn rgn;
		rgn.CreateRectRgn( 0, m_TitleHeight, wr.Width(), wr.Height() );
		
 		HRGN hrgn = bmp.CreateRgnFromFile( m_colTrans );
//wyw 防止内存增大 		
//		newrgn.CombineRgn( &rgn, CRgn::FromHandle(hrgn), RGN_XOR);

 		pDC->SelectClipRgn( &newrgn ); 
 		
 		//wyw
 		DeleteObject(hrgn);
		rgn.DeleteObject();
	}
	else
		SetWindowRgn(m_hWnd, newrgn, FALSE);

    if (m_sysmenu){
		if( m_downHitTest == HTCLOSE )
			DrawButton( pNewDC, 0, 1 );
		else if ( m_moveHitTest == HTCLOSE)
			DrawButton( pNewDC, 0, 2 );
		else
			DrawButton( pNewDC, 0, 0 );
	}
	/*if ( m_downHitTest == HTMAXBUTTON )
        DrawButton( pNewDC, 1, 1 );
    else if ( m_moveHitTest == HTMAXBUTTON)
        DrawButton( pNewDC, 1, 2 );
    else
        DrawButton( pNewDC, 1, 0 );  

    if ( m_downHitTest == HTMINBUTTON )
        DrawButton( pNewDC, 2, 1 );
    else if ( m_moveHitTest == HTMINBUTTON)
        DrawButton( pNewDC, 2, 2 );
    else
        DrawButton( pNewDC, 2, 0 ); // liub_modify 去除弹出面板(去掉按钮)
   if ( m_downHitTest == HTMINBUTTON )
        DrawButton( pNewDC, 2, 1 );
    else if ( m_moveHitTest == HTMINBUTTON)
        DrawButton( pNewDC, 2, 2 );
    else
        DrawButton( pNewDC, 2, 0 );    */
	if ( m_downHitTest == HTMINBUTTON )
        DrawButton( pNewDC, 1, 1 );
    else if ( m_moveHitTest == HTMINBUTTON)
        DrawButton( pNewDC, 1, 2 );
    else
        DrawButton( pNewDC, 1, 0 ); 

          

    int cx = GetSystemMetrics(SM_CXSMICON);
    int cy = GetSystemMetrics(SM_CYSMICON);
    HICON hi = (HICON)SendMessage( m_hWnd, WM_GETICON, ICON_SMALL, 0);
    if ( !hi )
    {
//#ifdef IDR_MAINFRAME
        hi = AfxGetApp()->LoadIcon(g_SetData.Main_szMainIcon);
//#endif
    }
    //draw icon
//     ::DrawIconEx( pNewDC->GetSafeHdc(), m_BorderLeftWidth, 5, (HICON)
//         CopyImage( hi, IMAGE_ICON, 
//         cx, cy, 0), cx, cy, 0, 0, DI_NORMAL);

#if 0 //wyw
	//draw icon
	::DrawIconEx( pNewDC->GetSafeHdc(), m_BorderLeftWidth, 5, (HICON)
		CopyImage( hi, IMAGE_ICON, cx, cy, 0), cx, cy, 0, 0, DI_NORMAL);
#else
	if (NULL != hi) {
		HICON hIcon = (HICON)CopyImage( hi, IMAGE_ICON, cx, cy, 0);
		ASSERT(NULL != hIcon);
		::DrawIconEx( pNewDC->GetSafeHdc(), m_BorderLeftWidth, 5, hIcon, cx, cy, 0, 0, DI_NORMAL);
		DestroyIcon(hIcon);
	}
#endif

    //draw text
    if ( m_title.IsEmpty() )
        pWnd->GetWindowText(m_title);

    if (m_bActive)
        pNewDC->SetTextColor( m_colTitle1 );
    else
        pNewDC->SetTextColor( m_colTitle2 );

    CFont font, *ofont;
    font.CreatePointFont( GetSystemMetrics(SM_CYSMCAPTION), _T("System") );
    ofont = pNewDC->SelectObject(&font);

    pNewDC->SetBkMode(TRANSPARENT);
    pNewDC->DrawText( m_title, CRect( m_textShift, m_textShiftVer, wr.Width() - m_bmpTitle.Width() + m_titleoff2, 
        m_TitleHeight ), DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_WORD_ELLIPSIS  );

    pNewDC->SelectObject(&font);

    pDC->BitBlt( 0, 0, wr.Width(),
        m_TitleHeight, pNewDC, 0, 0, SRCCOPY );

    pDC->SelectClipRgn(NULL);

	//wyw
	memDC.SelectObject(obmp);

	#ifdef FEATURE_VERSION_ITELCO
		if(m_pHookedWnd == AfxGetMainWnd())
		{
			pWnd = CWnd::FromHandle(m_hWnd);
			pDC = pWnd->GetWindowDC();
			CRect rtWnd,rtTitle;
			pWnd->GetWindowRect(&rtWnd); 
			CRect m_rtIcon;
			rtTitle.left = GetSystemMetrics(SM_CXFRAME); 
			rtTitle.top = GetSystemMetrics(SM_CYFRAME); 
			//rtTitle.right = rtWnd.right - rtWnd.left - GetSystemMetrics(SM_CXFRAME); 
			rtTitle.bottom = rtTitle.top + GetSystemMetrics(SM_CYSIZE); 

			m_rtIcon.left = rtTitle.left + 350;  
			m_rtIcon.top = rtTitle.top - 1; 
			//m_rtIcon.right = m_rtIcon.left + 323;   //323
			//m_rtIcon.bottom = m_rtIcon.top + 20;    //25

			HICON hLogInfo;

			hLogInfo = (HICON)::LoadImage(NULL,
										  g_SetData.Main_szTitleLogoIcon, 
										  IMAGE_ICON,
										  248, 24, 
										  LR_LOADFROMFILE|LR_DEFAULTCOLOR);
			DWORD dword = GetLastError();

			//IDR_MAINFRAME  IDI_ICON_INFO
			BOOL BRes = ::DrawIconEx(pDC->m_hDC, m_rtIcon.left, m_rtIcon.top,
									 hLogInfo, 0,
									 0, 0, NULL, DI_NORMAL); 
			dword = GetLastError();

		}
	#endif

	//wyw
	font.DeleteObject();
	bmp.DeleteObject();
	newrgn.DeleteObject();
	memDC.DeleteDC();
	pWnd->ReleaseDC(pDC);
}