⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 caption.cpp

📁 3D reconstruction, medical image processing from colons, using intel image processing for based clas
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		RxSuppressStyle ss(wnd.GetSafeHwnd(), WS_VISIBLE);		Default();						// Normal message handling	}	Refresh();}//////////// Ensure caption is repainted when system colors change//void RxCaption::OnColorChange(){	 	Default();							 // Normal message handling	Refresh();}void RxCaption::PaintCaption(){	ASSERT(m_pWndHooked);	CWnd&	wnd		= *m_pWndHooked;	DWORD	dwStyle	= wnd.GetStyle();	CWindowDC	dc(&wnd);	CRect	rcCaption, rcButton, rcText;	rcCaption  = GetCaptionRect();	CDC			dcMem;	CBitmap		bmpMem, *pOldBitmap;	dcMem.CreateCompatibleDC(&dc);	bmpMem.CreateCompatibleBitmap(&dc, rcCaption.Width(), rcCaption.Height());	pOldBitmap  = dcMem.SelectObject(&bmpMem);	{		int cxIcon = GetSystemMetrics(SM_CXSIZE);		int cyIcon = GetSystemMetrics(SM_CYSIZE);		rcText = rcCaption;		CBrush		brush, *pOldBrush;		brush.CreateSolidBrush(m_bActive ? GetActiveColor() : GetInactiveColor());		pOldBrush = dcMem.SelectObject(&brush);		dcMem.PatBlt(0, 0, rcCaption.Width(), rcCaption.Height(), PATCOPY);		dcMem.SelectObject(pOldBrush);		brush.DeleteObject();		rcText.left  = 2;		rcText.right = rcCaption.right - 4;		if(cxIcon >= 25)		{			// window XP style			// If there's no icon or system menu, don't draw one			if(dwStyle & WS_SYSMENU)			{				//////////////				// Within the basic button rectangle, Windows 95 uses a 1 or 2 pixel border				// Icon has 2 pixel border on left, 1 pixel on top/bottom, 0 right				//				rcButton.left = 0;				rcButton.top  = 0;				rcButton.right  = rcButton.left + cxIcon;				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(2, 1, 0, 1);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.left = rcButton.right + 2;				//////////////				// Close box has a 2 pixel border on all sides but left, which is zero				//				rcButton.left = (rcCaption.Width() - (cxIcon-2));				rcButton.top  = 0;				rcButton.right  = rcButton.left + (cxIcon-4);				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(0, 2, 0, 2);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.right = rcButton.left - 4;			}			//////////////			// Max/restore button is like close box; just shift rectangle left			// Also does help button, if any.			//			if ((dwStyle & WS_MAXIMIZEBOX) || (wnd.GetExStyle() & WS_EX_CONTEXTHELP)) 			{				rcButton.left = (rcCaption.Width() - (cxIcon-2)*2);				rcButton.top  = 0;				rcButton.right  = rcButton.left + (cxIcon-4);				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(0, 2, 0, 2);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.right = rcButton.left - 4;			}			///////////////			// Minimize button has 2 pixel border on all sides but right.			//			if (dwStyle & WS_MINIMIZEBOX) 			{				rcButton.left = (rcCaption.Width() - (cxIcon-2)*3);				rcButton.top  = 0;				rcButton.right  = rcButton.left + (cxIcon-4);				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(0, 2, 0, 2);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.right = rcButton.left - 4;			}		}		else		{			// window 95, 2000 style			// If there's no icon or system menu, don't draw one			if(dwStyle & WS_SYSMENU)			{				//////////////				// Within the basic button rectangle, Windows 95 uses a 1 or 2 pixel border				// Icon has 2 pixel border on left, 1 pixel on top/bottom, 0 right				//				rcButton.left = 0;				rcButton.top  = 0;				rcButton.right  = rcButton.left + cxIcon;				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(2, 1, 0, 1);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.left = rcButton.right + 2;				//////////////				// Close box has a 2 pixel border on all sides but left, which is zero				//				rcButton.left = (rcCaption.Width() - cxIcon);				rcButton.top  = 0;				rcButton.right  = rcButton.left + cxIcon;				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(0, 2, 2, 2);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.right = rcButton.left - 4;			}			//////////////			// Max/restore button is like close box; just shift rectangle left			// Also does help button, if any.			//			if ((dwStyle & WS_MAXIMIZEBOX) || (wnd.GetExStyle() & WS_EX_CONTEXTHELP)) 			{				rcButton.left = (rcCaption.Width() - cxIcon*2);				rcButton.top  = 0;				rcButton.right  = rcButton.left + cxIcon;				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(0, 2, 2, 2);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.right = rcButton.left - 4;			}			///////////////			// Minimize button has 2 pixel border on all sides but right.			//			if (dwStyle & WS_MINIMIZEBOX) 			{				rcButton.left = (rcCaption.Width() - cxIcon*3);				rcButton.top  = 0;				rcButton.right  = rcButton.left + cxIcon;				rcButton.bottom = rcButton.top  + cyIcon;				rcButton.DeflateRect(2, 2, 0, 2);				PaintRect(&dcMem, rcButton, m_crMask);				rcText.right = rcButton.left - 4;			}		}		///////////////		// Draw Text		//		CString		strText;		wnd.GetWindowText(strText);		// Get caption font	and select into DC		CFont	*pOldFont = dcMem.SelectObject(GetFont());		dcMem.SetBkMode(TRANSPARENT);			// draw on top of our background		dcMem.SetTextColor(GetTextColor(m_bActive));		dcMem.DrawText(strText, rcText, DT_LEFT|DT_END_ELLIPSIS);		dcMem.SelectObject(pOldFont);		///////////////		// Draw lower border		//		CRect	rcBorder;		rcBorder.left   = 0;		rcBorder.top    = rcCaption.Height() - GetSystemMetrics(SM_CYBORDER);		rcBorder.right  = rcCaption.right;		rcBorder.bottom = rcCaption.Height();		PaintRect(&dcMem, rcBorder, RGB( 74, 74, 74));	}	TransparentBlt(dc.GetSafeHdc(), rcCaption.left, rcCaption.top, rcCaption.Width(), rcCaption.Height(),						dcMem.GetSafeHdc(), 0, 0, rcCaption.Width(), rcCaption.Height(), m_crMask);		dcMem.SelectObject(pOldBitmap);	bmpMem.DeleteObject();	dcMem.DeleteDC();	wnd.ReleaseDC(&dc);}// Paint the color into the rectangle dimensions on the device contextvoid RxCaption::PaintRect(CDC* pDC, CRect rect, COLORREF color){	CBrush brush(color), *pOldBrush;	pOldBrush = pDC->SelectObject(&brush);	pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);	pDC->SelectObject(pOldBrush);	brush.DeleteObject();}CRect RxCaption::GetCaptionRect(){	ASSERT(m_pWndHooked);	CWnd&	wnd = *m_pWndHooked;	// Get window rect as window-relative	CRect	rcCaption;	wnd.GetWindowRect(rcCaption);	rcCaption -= rcCaption.TopLeft();	// shift origin to (0,0)	////////////////////////////////////////	// Get size of frame around window	CSize szFrame = (wnd.GetStyle() & WS_THICKFRAME) ?		CSize(GetSystemMetrics(SM_CXSIZEFRAME),  GetSystemMetrics(SM_CYSIZEFRAME)) :		CSize(GetSystemMetrics(SM_CXFIXEDFRAME), GetSystemMetrics(SM_CYFIXEDFRAME));	rcCaption.InflateRect(-szFrame.cx, -szFrame.cy);	rcCaption.bottom = rcCaption.top + GetSystemMetrics(SM_CYCAPTION);	// height of caption	// Iconic captions move 1 pixel up. They just do, OK?	//	if (wnd.IsIconic())		rcCaption.OffsetRect(0, -1);		return rcCaption;}/////////////////////////////////////////////////////////////////////////////// Color Infomation.void RxCaption::SetActiveColor(COLORREF crActive){	m_crActive = crActive;}void RxCaption::SetInactiveColor(COLORREF crInactive){	m_crInactive = crInactive;}void RxCaption::SetCustomColors(COLORREF crActive, COLORREF crInactive){	m_crActive		= crActive;	m_crInactive	= crInactive;}void RxCaption::UseSystemActiveColor(){	m_crActive = -1;}void RxCaption::UseSystemInactiveColor(){	m_crInactive = -1;}void RxCaption::UseSystemColors(){	UseSystemActiveColor();	UseSystemInactiveColor();}BOOL RxCaption::IsUsingSystemColors(){	return m_crActive == -1;}COLORREF RxCaption::GetActiveColor() const{	return m_crActive == -1 ? GetSysColor(COLOR_ACTIVECAPTION) : m_crActive;}COLORREF RxCaption::GetInactiveColor() const{	return m_crInactive == -1 ? GetSysColor(COLOR_INACTIVECAPTION) : m_crInactive;}COLORREF RxCaption::GetTextColor(BOOL bActive){	return bActive ? GetActiveTextColor() : GetInactiveTextColor();}void RxCaption::SetActiveTextColor(COLORREF crActiveText){	m_crActiveText = crActiveText;}void RxCaption::SetInactiveTextColor(COLORREF crInactiveText){	m_crInactiveText = crInactiveText;}COLORREF RxCaption::GetActiveTextColor() const{	return m_crActiveText == -1 ? GetSysColor(COLOR_CAPTIONTEXT) : m_crActiveText;}COLORREF RxCaption::GetInactiveTextColor() const{	return m_crInactiveText == -1 ? GetSysColor(COLOR_INACTIVECAPTIONTEXT) : m_crInactiveText;}void RxCaption::SetFont(CFont& font){	LOGFONT lf;	font.GetLogFont(&lf);	if (m_font.m_hObject)		m_font.DeleteObject();	m_font.CreateFontIndirect(&lf);}CFont* RxCaption::GetFont(){	if(!m_font.m_hObject)	{		if(!m_fontSys.m_hObject)		{			NONCLIENTMETRICS ncm;			memset(&ncm, 0, sizeof(ncm));			ncm.cbSize = sizeof(ncm);			SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);			m_fontSys.CreateFontIndirect(&ncm.lfCaptionFont);		}		return &m_fontSys;	}	else		return &m_font;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -