Beispiel #1
1
void CRibbonDialog::OnNcPaint()
{
	CRect       r, rTitle, rMenu, rCookie;

	GetWindowRect(r);
	r.OffsetRect(-r.left, -r.top);
	CalcTitleRect(TRUE, rTitle);
	CalcSysMenuRect(TRUE, rMenu);
	rCookie.SetRect(
		rMenu.left + SYS_COOKIE_OFFSET + 1,
		rMenu.top  + SYS_COOKIE_OFFSET + 1,
		rMenu.left + SYS_COOKIE_OFFSET + SYS_COOKIE_WIDTH,
		rMenu.top  + SYS_COOKIE_OFFSET + SYS_COOKIE_HEIGHT);

	// Draw the title bar, sys menu cookie, and border	
	CDC *pDC = GetWindowDC();
	if (!pDC)
    	return;
	
	CBrush TitleBrush(GetSysColor(COLOR_ACTIVECAPTION));
	CBrush FrameBrush(COLOR_BORDER);
	CBrush MenuBrush(COLOR_SYSMENU);
	CBrush CkBrush(COLOR_COOKIEFILL);
	CBrush CkBrushShadow(COLOR_SYSSHADOW);
	
	pDC->FillRect(rTitle, &TitleBrush);
	pDC->FillRect(rMenu,  &MenuBrush);
	
	pDC->FrameRect(rTitle,  &FrameBrush);
	pDC->FrameRect(r,       &FrameBrush);
	pDC->FrameRect(rMenu,   &FrameBrush);
	pDC->FrameRect(rCookie, &CkBrushShadow);
	rCookie.OffsetRect(-1, -1);
	pDC->FillRect(rCookie,  &CkBrush);
	pDC->FrameRect(rCookie, &FrameBrush);

	CFont fnt;
	int FntHeight = 12;
	if (fnt.CreateFont(FntHeight,0,0,0,FW_NORMAL,FALSE,FALSE,0,0,OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE|TMPF_TRUETYPE,NULL))
	{
		CFont   *pfont = pDC->SelectObject(&fnt);
		pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(GetSysColor(COLOR_CAPTIONTEXT));
		pDC->DrawText((LPCSTR)"Picture Publisher",-1,&rTitle,DT_CENTER|DT_VCENTER);
		pDC->SelectObject(pfont);
		fnt.DeleteObject();
	}
	
	ReleaseDC(pDC);
}
Beispiel #2
0
void ZoomBox_NcPaint(HWND hwnd, HRGN hrgn)
/************************************************************************/
{
	CRect  r, rTitle, rMenu, rCaption, rCookie;
	TCHAR Caption[80];


	GetWindowRect(hwnd,&r);
	r.OffsetRect(-r.left, -r.top);
	CalcTitleRect(hwnd,TRUE, rTitle);
	CalcSysMenuRect(hwnd,TRUE, rMenu);
	rCookie.SetRect(
		rMenu.left + SYS_COOKIE_OFFSET + 1,
		rMenu.top  + SYS_COOKIE_OFFSET + 1,
		rMenu.left + SYS_COOKIE_OFFSET + SYS_COOKIE_WIDTH,
		rMenu.top  + SYS_COOKIE_OFFSET + SYS_COOKIE_HEIGHT);

	// Exclude the Caption Bar area and Have default draw
    HDC hDC = ::GetDCEx(hwnd, hrgn,
	    DCX_USESTYLE | DCX_WINDOW | DCX_INTERSECTRGN | DCX_LOCKWINDOWUPDATE);
	int level = ::SaveDC(hDC);
	CRgn rgn1;
	CRgn rgn2;
	rCaption.UnionRect((LPRECT)&rTitle,(LPRECT)&rMenu);
	::ClientToScreen(hwnd,(LPPOINT)&rCaption);
	::ClientToScreen(hwnd,(LPPOINT)&rCaption.right);
	rgn1.FromHandle(hrgn);
	rgn2.CreateRectRgn(rCaption.left,rCaption.top,rCaption.right,rCaption.bottom);
	int ret = rgn2.CombineRgn(&rgn1,&rgn2,RGN_DIFF);
/*
ERROR		    0
NULLREGION	    1
SIMPLEREGION	    2
COMPLEXREGION	    3
*/
	DefWindowProc(hwnd, WM_NCPAINT, (WPARAM)(HRGN)(rgn2.GetSafeHandle()),
		(LPARAM)0L); 
	::RestoreDC(hDC,level);
	::ReleaseDC(hwnd,hDC);


	// Draw the title bar, sys menu cookie, and border	
	CWnd *pWnd = CWnd::FromHandle(hwnd);
	CDC *pDC = pWnd->GetWindowDC(); 
	if (!pDC)
    	return;
	
	CBrush TitleBrush(GetSysColor(COLOR_ACTIVECAPTION));
	CBrush FrameBrush(COLOR_BORDER);
	CBrush MenuBrush(COLOR_SYSMENU);
	CBrush CkBrush(COLOR_COOKIEFILL);
	CBrush CkBrushShadow(COLOR_SYSSHADOW);
	
	pDC->FillRect(rTitle, &TitleBrush);
	pDC->FillRect(rMenu,  &MenuBrush);
	
	pDC->FrameRect(rTitle,  &FrameBrush);
	pDC->FrameRect(r,       &FrameBrush);
	pDC->FrameRect(rMenu,   &FrameBrush);
	pDC->FrameRect(rCookie, &CkBrushShadow);
	rCookie.OffsetRect(-1, -1);
	pDC->FillRect(rCookie,  &CkBrush);
	pDC->FrameRect(rCookie, &FrameBrush);

	CFont fnt;
	int FntHeight = 12;
	if (fnt.CreateFont(FntHeight,0,0,0,FW_NORMAL,FALSE,FALSE,0,0,OUT_DEFAULT_PRECIS,
		CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_DONTCARE|TMPF_TRUETYPE,NULL))
	{
		pDC->SelectObject(&fnt);
		pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(GetSysColor(COLOR_CAPTIONTEXT));
		if (::GetWindowText(hwnd,Caption,80) == 0)
			lstrcpy(Caption,_T("QuickZoom"));
		pDC->DrawText((LPCSTR)Caption,-1,&rTitle,DT_CENTER|DT_VCENTER);
		fnt.DeleteObject();
	}
	
	pWnd->ReleaseDC(pDC);
}