Example #1
0
void MenuEditorItem::PaintSeparator(CDC& dc, CRect& rect)
{
	// Draw separator

	CRect sep = rect;
	sep.bottom = sep.top + 2;
	dc.FillSolidRect(sep, 0xffffff);
	dc.Draw3dRect(sep,GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_BTNFACE));
	rect.OffsetRect(0, sep.Height()+1);
}
Example #2
0
void CSizingControlBar::OnNcPaint()
{
    // get window DC that is clipped to the non-client area
    CWindowDC dc(this);

    CRect rcClient, rcBar;
    GetClientRect(rcClient);
    ClientToScreen(rcClient);
    GetWindowRect(rcBar);
    rcClient.OffsetRect(-rcBar.TopLeft());
    rcBar.OffsetRect(-rcBar.TopLeft());

    CDC mdc;
    mdc.CreateCompatibleDC(&dc);
    
    CBitmap bm;
    bm.CreateCompatibleBitmap(&dc, rcBar.Width(), rcBar.Height());
    CBitmap* pOldBm = mdc.SelectObject(&bm);

    // draw borders in non-client area
    CRect rcDraw = rcBar;
    DrawBorders(&mdc, rcDraw);

    // erase the NC background
#ifdef _WIN64
    mdc.FillRect(rcDraw, CBrush::FromHandle(
        (HBRUSH) GetClassLong(m_hWnd, GCLP_HBRBACKGROUND)));
#else
    mdc.FillRect(rcDraw, CBrush::FromHandle(
        (HBRUSH) GetClassLong(m_hWnd, GCL_HBRBACKGROUND)));
#endif

    if (m_dwSCBStyle & SCBS_SHOWEDGES)
    {
        CRect rcEdge; // paint the sizing edges
        for (int i = 0; i < 4; i++)
            if (GetEdgeRect(rcBar, GetEdgeHTCode(i), rcEdge))
                mdc.Draw3dRect(rcEdge, ::GetSysColor(COLOR_BTNHIGHLIGHT),
                    ::GetSysColor(COLOR_BTNSHADOW));
    }

    NcPaintGripper(&mdc, rcClient);

    // client area is not our bussiness :)
    dc.IntersectClipRect(rcBar);
    dc.ExcludeClipRect(rcClient);

    dc.BitBlt(0, 0, rcBar.Width(), rcBar.Height(), &mdc, 0, 0, SRCCOPY);

    ReleaseDC(&dc);

    mdc.SelectObject(pOldBm);
    bm.DeleteObject();
    mdc.DeleteDC();
}
Example #3
0
void CChatWnd::OnDrawItem(int /*nIDCtl*/, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
    CDC* pDC = CDC::FromHandle( lpDrawItemStruct->hDC );
    CRect rc( &lpDrawItemStruct->rcItem );

    Emoticons.Draw( pDC, lpDrawItemStruct->itemID - 1, rc.left + 8, rc.top + 3 );

    if ( lpDrawItemStruct->itemState & ODS_SELECTED )
    {
        pDC->Draw3dRect( &rc, CoolInterface.m_crHighlight, CoolInterface.m_crHighlight );
        rc.DeflateRect( 1, 1 );
        pDC->Draw3dRect( &rc, CoolInterface.m_crHighlight, CoolInterface.m_crHighlight );
    }
    else
    {
        pDC->Draw3dRect( &rc, CoolInterface.m_crWindow, CoolInterface.m_crWindow );
        rc.DeflateRect( 1, 1 );
        pDC->Draw3dRect( &rc, CoolInterface.m_crWindow, CoolInterface.m_crWindow );
    }
}
Example #4
0
void CEColorDlg::DrawFillPaint(CDC& dc, CRect rc, WCHAR* fillStr)
{
	if (fillStr)// && wcslen(fillStr) > 0)
	{
		CComPtr<IEXMLDocument> edocument;
		m_viewGroup->get_eXMLDocument(&edocument);

		CRect emptyrc(0,0,0,0);

//		dc.Rectangle(rc.left, rc.top, rc.right, rc.bottom);

		dc.Draw3dRect(&rc, RGB(0,0,0), RGB(0,0,0));
		rc.InflateRect(-1, -1);

		dc.Draw3dRect(&rc, RGB(255,255,255), RGB(255,255,255));
		rc.InflateRect(-1, -1);

		//rc.InflateRect(-2, -2);
		DrawPaint(dc.m_hDC, rc, emptyrc, fillStr, edocument, m_htmlActiveDoc, m_htmlView);
	}
}
void CXTPHeaderCtrlThemeExplorer::OnDrawBackground(LPDRAWITEMSTRUCT lpDIS)
{
	CRect rcItem(lpDIS->rcItem);
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);

	// fill background
	pDC->FillSolidRect(&rcItem, m_cr3DFace);
	rcItem.right += 2;

	// draw 3D borders.
	pDC->Draw3dRect(&rcItem, m_cr3DHighLight, m_cr3DShadow);
}
Example #6
0
void CMonitorWnd::DrawActivePage(BOOL bFlag)
{
	if(!m_pActivePage || m_PageList.GetCount() < 2)
	{
		return;
	}

	CRect rect;
	m_pActivePage->GetWindowRect(&rect);
	ScreenToClient(&rect);
	rect.InflateRect(1,1);

	if(bFlag)
	{
		CDC *pDC = GetDC();
		if(pDC == NULL)
		{
			return;
		}

		pDC->Draw3dRect(&rect,m_clrTopLeft, m_clrBottomRight);	

		ReleaseDC(pDC);
	}
	else
	{
		CDC *pDC = GetDC();
		if(pDC == NULL)
		{
			return;
		}

		pDC->Draw3dRect(&rect, MONITOR_BACK_COLOR, MONITOR_BACK_COLOR);	

		ReleaseDC(pDC);
	}
}
Example #7
0
void CMonitorBarCtrl::DoPaint(CDC* pDC)
{
	CRect rcClient;
	GetClientRect( &rcClient );

	CSize size = rcClient.Size();
	CDC* pMemDC = CoolInterface.GetBuffer( *pDC, size );
	if ( Settings.General.LanguageRTL )
		SetLayout( pMemDC->m_hDC, 0 );

	if ( ! CoolInterface.DrawWatermark( pMemDC, &rcClient, &m_bmWatermark ) )
		pMemDC->FillSolidRect( &rcClient, CoolInterface.m_crMidtone );

	if ( Skin.m_bBordersEnabled )
		DrawBorders( pMemDC, rcClient );
	else
		rcClient.DeflateRect( 2, 3, 2, 1 );

	for ( int nY = rcClient.top + 4 ; nY < rcClient.bottom - 4 ; nY += 2 )
	{
		pMemDC->Draw3dRect( rcClient.left + 3, nY, 4, 1,
			CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
	}

	DrawIconEx( pMemDC->GetSafeHdc(), rcClient.right - 16, rcClient.bottom - 16, m_hUpDown, 16, 16, 0, NULL, DI_NORMAL );

	m_pTxItem->SetHistory( rcClient.Width(), TRUE );
	m_pRxItem->SetHistory( rcClient.Width(), TRUE );

	CRect rcHistory( rcClient.left + 10, rcClient.top + 2, rcClient.right - 15, rcClient.bottom - 6 );
	PaintHistory( pMemDC, &rcHistory );

	CRect rcCurrent( rcClient.right - 7, rcClient.top + 2, rcClient.right - 2, rcClient.bottom - 6 );
	PaintCurrent( pMemDC, &rcCurrent, m_pRxItem );
	rcCurrent.OffsetRect( -6, 0 );
	PaintCurrent( pMemDC, &rcCurrent, m_pTxItem );

	m_rcTrack.SetRect( rcClient.left + 6, rcClient.bottom - 8, rcClient.right, rcClient.bottom - 2 );
	PaintTab( pMemDC );

	GetClientRect( &rcClient );
	pDC->BitBlt( rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(),
		pMemDC, 0, 0, SRCCOPY );
	if ( Settings.General.LanguageRTL )
		SetLayout( pMemDC->m_hDC, LAYOUT_RTL );
}
Example #8
0
void CDownloadMonitorDlg::DoPaint(CDC& dc)
{
	CRect rc;

	m_wndProgress.GetWindowRect( &rc );
	ScreenToClient( &rc );

	DrawProgressBar( &dc, &rc );

	m_wndGraph.GetWindowRect( &rc );
	ScreenToClient( &rc );

	dc.Draw3dRect( &rc, 0, 0 );
	rc.DeflateRect( 1, 1 );

	m_pGraph->BufferedPaint( &dc, &rc );
}
Example #9
0
BOOL CColorEdit::OnEraseBkgnd(CDC* pDC)
{
	CDC* pdcParent = GetParent()->GetDC();

	ui::CClientRect rcThisClient(this);
	ui::CWindowRect rcThisWindow(this);
	if (rcThisClient.Width() == rcThisWindow.Width())
	{
		rcThisWindow.InflateRect(2, 2);
	}

	GetParent()->ScreenToClient(rcThisWindow);
	pdcParent->Draw3dRect(rcThisWindow, m_crBorder, m_crBorder);
	ReleaseDC(pdcParent);

	return TRUE;
}
Example #10
0
void ComicStripPicture::OnPaint()
{
   CRect rect;
   GetClientRect(&rect);
	CPaintDC dc(this);
	CDC* pDC = &dc;
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap memZoomBitmap;
	memZoomBitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height());
	memDC.SelectObject(&memZoomBitmap);

   CDrawer::Draw(this, &memDC, m_pComicStripData);
   memDC.Draw3dRect(rect, RGB(0, 0, 0), RGB(0, 0, 0));
   pDC->BitBlt(0, 0, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);
	memDC.DeleteDC();
	memZoomBitmap.DeleteObject();
}
Example #11
0
void MenuEditorItem::PaintMenu(CDC& dc, CRect& rect)
{
	// draw this item

	dc.FillSolidRect(rect, 0xffffff);
	dc.Draw3dRect(rect,GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_BTNFACE));
	m_rect = rect;

	CRect temp = rect;
	
	if(pEditor->selected == this)
	{
		for(int x = temp.left; x < temp.right; x+=2)
		{
			dc.SetPixel(x,temp.top, 0);
			dc.SetPixel(x + 1- temp.Height()%2,temp.bottom-1, 0);
		}
		for(int y = temp.top; y < temp.bottom; y+=2)
		{
			dc.SetPixel(temp.left,y, 0);
			dc.SetPixel(temp.right-1,y +1- temp.Width()%2, 0);
		}
	}

	temp.DeflateRect(2,2);

	if(pEditor->selected == this)
		dc.FillSolidRect(temp, GetSysColor(COLOR_MENUHILIGHT));
	

	temp.left += 20;
	
	if(inserttext)
		dc.SetTextColor(GetSysColor(COLOR_GRAYTEXT));
	else if(pEditor->selected == this)
		dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
	else
		dc.SetTextColor(GetSysColor(COLOR_MENUTEXT));
	dc.DrawText(m_Text, temp, 0);

	rect.OffsetRect(rect.Width() + 1,0);

}
BOOL CXTPPropertyGridItemPicture::OnDrawItemValue(CDC& dc, CRect rcValue)
{
	COLORREF clr = dc.GetTextColor();
	CRect rcSample(rcValue.left - 2, rcValue.top + 1, rcValue.left - 2 + m_nPreviewWidth, rcValue.bottom - 1);

	m_olePicture.Render(&dc, rcSample, rcSample);
	dc.Draw3dRect(rcSample, clr, clr);

	CRect rcText(rcValue);
	rcText.left += m_nPreviewWidth + 5;

	short type = m_olePicture.GetType();
	CString str = type == PICTYPE_ICON ? _T("(Icon)") :
		type == PICTYPE_BITMAP ? _T("(Bitmap)") : _T("None");

	dc.DrawText(str, rcText, DT_SINGLELINE | DT_VCENTER);

	return TRUE;
}
void COutlook2Ctrl::AnimateToFolder(int f)
{
	m_iSelectedFolder = f;
 	pLastHilink = NULL;
	m_csCaption = GetFolder(f)->csName;

	if (m_iSize > 4)
	{

		CRect rc;
		GetClientRect(rc);

		CDC dc;
		CClientDC cdc(this);
		dc.CreateCompatibleDC(&cdc);
		CBitmap bmp;
		bmp.CreateCompatibleBitmap(&cdc, rc.Width(), rc.Height());
		CBitmap * ob = (CBitmap *) dc.SelectObject(&bmp);

		DrawCaption(&dc, rc);
		CRect rcBdr(rc);
		rc.InflateRect(-1,-1);
		DrawButtons(&dc, rc);
		int iBottomInner = rc.bottom;
		dc.Draw3dRect(rcBdr, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
		rcInnerRect = rc;
		dc.FillSolidRect(rc, m_crBackground);
		if (m_iSelectedFolder >= 0 && m_iSelectedFolder < m_Folders.GetSize())
		{
			COL2Folder * o = (COL2Folder *) m_Folders.GetAt(m_iSelectedFolder);
			DrawItems(&dc, o, rc);
		}

		for (int t = iBottomInner - 10; t > 0; t -= (iBottomInner/8))
		{
			cdc.BitBlt(0,t,rc.Width(), iBottomInner - t, &dc, 0,0, SRCCOPY);
			Sleep(30);
		}
		dc.SelectObject(ob);
	}

	Invalidate();
}
Example #14
0
void CPlayWnd::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	if(nIDEvent ==2)
	{
		if(m_FlagRect == TRUE)
		{
			CDC *pdc = GetDC();
			RECT  rt;
			rt.left =  pointStart.x;
			rt.top =   pointStart.y;		
			rt.right = 	pointEnd.x;
			rt.bottom = pointEnd.y;
			pdc->Draw3dRect(&rt,RGB(255,0,0),RGB(255,0,0));
			ReleaseDC(pdc);
		}
	}
	CWnd::OnTimer(nIDEvent);
}
void CXTPHeaderCtrlThemeOffice2003::OnDrawBackground(LPDRAWITEMSTRUCT lpDIS)
{
	CRect rcItem(lpDIS->rcItem);
	CDC* pDC = CDC::FromHandle(lpDIS->hDC);

	// fill background
	pDC->FillSolidRect(&rcItem, m_cr3DFace);
	rcItem.right += 2;

	// draw 3D borders.
	pDC->Draw3dRect(&rcItem, m_cr3DHighLight, MixColor(m_cr3DFace, m_cr3DShadow, 0.6));

	CXTPPenDC penDC(lpDIS->hDC, MixColor(m_cr3DFace, m_cr3DShadow, 0.4));
	pDC->MoveTo(rcItem.left, rcItem.bottom-2);
	pDC->LineTo(rcItem.right, rcItem.bottom-2);

	penDC.Color(MixColor(m_cr3DFace, m_cr3DShadow, 0.25));
	pDC->MoveTo(rcItem.left, rcItem.bottom-3);
	pDC->LineTo(rcItem.right, rcItem.bottom-3);
}
Example #16
0
void CMLListView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC dcItem;
	dcItem.Attach(lpDrawItemStruct->hDC);
	lpDrawItemStruct->itemState;

	CHeaderCtrl* pHdr = GetListCtrl().GetHeaderCtrl();
	int nColCount = pHdr->GetItemCount();

	CRect rcCell = lpDrawItemStruct->rcItem;
	rcCell.right = 0;

	CRect rcCellText;
	for(int iCol = 0; iCol < nColCount; iCol ++)
	{
		int nWidthCol = GetListCtrl().GetColumnWidth(iCol);
		rcCell.right = rcCell.left + nWidthCol;

		CString strItem;
		GetItemText(lpDrawItemStruct->itemID, iCol, strItem);

		dcItem.FillSolidRect(rcCell, OnGetCellBkColor(lpDrawItemStruct->itemID, iCol));
		rcCellText = rcCell;

		rcCellText.DeflateRect(2, 1, 0, 0);
		dcItem.SelectObject(OnGetCellFont(lpDrawItemStruct->itemID, iCol));
		dcItem.SetTextColor(OnGetCellTextColor(lpDrawItemStruct->itemID, iCol));
		dcItem.DrawText(strItem, rcCellText, DT_EXTERNALLEADING|DT_LEFT);
		rcCell.left = rcCell.right;
	}

	if((lpDrawItemStruct->itemState & ODS_FOCUS) == ODS_FOCUS)
	{
		CRect rcFocus = lpDrawItemStruct->rcItem;
		rcFocus.DeflateRect(0, 0, 0, 1);
		dcItem.Draw3dRect(rcFocus, OnGetItemFocusColor(), OnGetItemFocusColor());
	}

	dcItem.SelectStockObject(SYSTEM_FONT) ;
	dcItem.Detach();
}
Example #17
0
void CUIEditorView::drawAllQuad(void)
{
	CDC* pDC = GetDC();
	INT begin = 0;
	INT end = QC_TYPE_SPLIT;
	if ( !m_bIsShowWindow )
	{
		begin = QC_TYPE_SPLIT + 1;
		end = QC_NUM;
	}
	for (INT i=begin; i<end; i++)
	{
		pDC->Draw3dRect(
			m_nQuadInfo[i].quadRect.left,
			m_nQuadInfo[i].quadRect.top,
			m_nQuadInfo[i].quadRect.right,
			m_nQuadInfo[i].quadRect.bottom,
			m_nQuadInfo[i].quadColor,
			m_nQuadInfo[i].quadColor
			);
	}
	ReleaseDC(pDC);
}
Example #18
0
void CGuiCheckBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC *pDC         = CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect m_rcClient(lpDrawItemStruct->rcItem);
	UINT m_State     = lpDrawItemStruct->itemState;
	CBrush cb;
	CRect m_rcTemp(m_rcClient);
	CPoint pt;
	CSize  m_Csize;
	CString m_szCaption;
	COLORREF m_Over = RGB(255, 193, 111);
	CPen cpOver(PS_SOLID, 1, RGB(255, 193, 111));
	int iMode      = pDC->SetBkMode(TRANSPARENT);
	int iExtile    = GetButtonStyle(); // obtenemos orientación del texto
	CRect m_rcText(m_rcClient);
	GetWindowText(m_szCaption);
	if (m_szCaption.GetLength() > 1)
		m_Csize= pDC->GetTextExtent(m_szCaption);

	// de acuerdo a la alineación del texto prepare la ubicación
	// del texto para Drawtex y DrawState
	
	if (m_rcClient.Height() > 13)
	{
		int Dif = m_rcClient.Height() - 13;
		Dif /= 2;
		m_rcTemp.top = Dif;
		m_rcTemp.bottom = m_rcTemp.top + 13;
	}
	if (iExtile & BS_LEFTTEXT)
	{
		m_rcTemp.left=	m_rcTemp.right - 13;
		pt = CPoint(m_rcTemp.left, m_rcTemp.top + 1);
	}
	else
	{
		m_rcTemp.right=	m_rcTemp.left + 13;
		pt = CPoint(m_rcTemp.right + 2, m_rcTemp.top + 1);
		m_rcText.left = m_rcTemp.right + 1;
	}
	
	// draw frame of checkbox
	pDC->Draw3dRect(m_rcTemp, m_clrHigh, m_clrHigh);
	m_rcTemp.DeflateRect(1, 1);
	DrawOrange(pDC, m_rcTemp);
	m_rcTemp.DeflateRect(1, 1);
	if (lpDrawItemStruct->itemState & ODS_DISABLED)
		pDC->DrawState(pt, m_Csize, m_szCaption, DSS_DISABLED, TRUE, 0, (HBRUSH)NULL);
	else 
	{
		pDC->DrawText(m_szCaption, m_rcText, DT_SINGLELINE | DT_LEFT | DT_VCENTER);			   		
		if (lpDrawItemStruct->itemState & ODS_SELECTED)
		{
			if (m_bOldTemp == TRUE)
				DrawCheck(pDC, m_rcTemp);
		}
		else
		{
			if (m_bCheckBtn == TRUE && m_bPressBtn == FALSE)
				DrawCheck(pDC, m_rcTemp);
			else
			{
				if (m_bOldTemp == TRUE && m_bPressBtn == TRUE)
					DrawCheck(pDC, m_rcTemp);
			}
		}
	}
}
Example #19
0
//*****************************************************************************
//
// Function Name: DrawPushLikeCell( LPDRAWITEMSTRUCT lpDrawItemStruct )
//
// Description:   An application calls the SetCellDimensions member 
//                function to set the height and width of cells in 
//                a grid control. 
//
// Returns:	      None
//
// Exceptions:	   None
//
//*****************************************************************************
void RGridCtrlBase::DrawPushLikeCell( LPDRAWITEMSTRUCT lpDrawItemStruct ) const
{
	CDC dc ;
	dc.Attach( lpDrawItemStruct->hDC ) ;

	RECT& rect = lpDrawItemStruct->rcItem ;
//	CRect rectTemp = rect ;

	//
	// Erase the background
	//
	dc.FillSolidRect( &rect, GetSysColor( COLOR_BTNFACE ) ) ;

	//
	// Draw the cell in a pushlike state
	//
	if (lpDrawItemStruct->itemState & ODS_SELECTED)
	{
		dc.Draw3dRect( rect.left, rect.top,
			(rect.right - rect.left + 1), 
			(rect.bottom - rect.top + 1),
			RGB( 0, 0, 0 ),	GetSysColor( COLOR_BTNHILIGHT ) ) ;

		CPen pen(PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW )) ;
		CPen *pOldPen = dc.SelectObject( &pen ) ;

		dc.MoveTo( rect.left + 1, rect.bottom - 1 ) ;
		dc.LineTo( rect.left + 1, rect.top + 1 ) ;
		dc.LineTo( rect.right, rect.top + 1) ;

		dc.SelectObject( pOldPen ) ;

		// Update the drawing rect
		rect.top += 2 ;	rect.left += 2 ;
		rect.bottom-- ; rect.right-- ;

		try
		{
			/*static*/ CBitmap bmpPattern ;

//			if (!bmpPattern.GetSafeHandle())
//			{
				static BITMAP   bitmap = { 0, 8, 8, 2, 1, 1 } ;
				static WORD wPatternBits[] = 
				{ 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA } ;

				bitmap.bmBits = (LPSTR) wPatternBits ;
				bmpPattern.CreateBitmapIndirect (&bitmap) ;
//			}

			CBrush   brush (&bmpPattern) ;
			COLORREF crOldBackColor = dc.SetBkColor(GetSysColor (COLOR_BTNFACE)) ;
			COLORREF crOldTextColor = dc.SetTextColor(GetSysColor (COLOR_BTNHILIGHT)) ;

			CRect rectTemp(rect.left + 1, rect.top + 1, rect.right, rect.bottom) ;

			dc.FillRect (&rectTemp, &brush) ;
			dc.SetBkColor (crOldBackColor) ;
			dc.SetTextColor (crOldTextColor) ;
		}
		catch (CResourceException& /*e*/)
		{
			// REVIEW: Put some type of error message here?
		}
	}
	else 
	{
		dc.Draw3dRect( &rect, 
			GetSysColor( COLOR_BTNHILIGHT ),
			GetSysColor( COLOR_BTNSHADOW ) ) ;

		dc.MoveTo( rect.left, rect.bottom ) ;
		dc.LineTo( rect.right, rect.bottom ) ;
		dc.LineTo( rect.right, rect.top - 1 ) ;

		// Update the drawing rect
		rect.bottom -= 2 ;	rect.right -= 2 ;
		rect.top++ ; rect.left++ ;
	}

	dc.Detach() ;
}
Example #20
0
void CCoolDialogBar::DrawGripper(CDC & dc)
{
    // no gripper if floating
	if( m_dwStyle & CBRS_FLOATING )
		return;

	// -==HACK==-
	// in order to calculate the client area properly after docking,
	// the client area must be recalculated twice (I have no idea why)
	m_pDockSite->RecalcLayout();
	// -==END HACK==-

	CRect gripper;
	GetWindowRect( gripper );
	ScreenToClient( gripper );
	gripper.OffsetRect( -gripper.left, -gripper.top );
	
	if( m_dwStyle & CBRS_ORIENT_HORZ ) {
		
		// gripper at left
		m_rectGripper.top		= gripper.top + 40;
		m_rectGripper.bottom	= gripper.bottom;
		m_rectGripper.left		= gripper.left;
		m_rectGripper.right	= gripper.left + 20;

		// draw close box
		m_rectClose.left = gripper.left + 7;
		m_rectClose.right = m_rectClose.left + 12;
		m_rectClose.top = gripper.top + 10;
		m_rectClose.bottom = m_rectClose.top + 12;
		dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE);

		// draw docking toggle box
		m_rectUndock = m_rectClose;
		m_rectUndock.OffsetRect(0,13);
		dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX);

		gripper.top += 38;
		gripper.bottom -= 10;
		gripper.left += 10;
		gripper.right = gripper.left+3;
        dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
		
		gripper.OffsetRect(4, 0);
        dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
	}
	
	else {
		
		// gripper at top
		m_rectGripper.top		= gripper.top;
		m_rectGripper.bottom	= gripper.top + 20;
		m_rectGripper.left		= gripper.left;
		m_rectGripper.right		= gripper.right - 40;

		// draw close box
		m_rectClose.right = gripper.right - 10;
		m_rectClose.left = m_rectClose.right - 11;
		m_rectClose.top = gripper.top + 7;
		m_rectClose.bottom = m_rectClose.top + 11;
		dc.DrawFrameControl(m_rectClose, DFC_CAPTION, DFCS_CAPTIONCLOSE);


		// draw docking toggle box
		m_rectUndock = m_rectClose;
		m_rectUndock.OffsetRect(-13,0);
		dc.DrawFrameControl(m_rectUndock, DFC_CAPTION, DFCS_CAPTIONMAX);

		gripper.right -= 38;
		gripper.left += 10;
		gripper.top += 10;
		gripper.bottom = gripper.top+3;
		dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
		
		gripper.OffsetRect(0, 4);
        dc.Draw3dRect( gripper, m_clrBtnHilight, m_clrBtnShadow );
	}

}
Example #21
0
void CLinkButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	// 获取一个CDC指针
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	//定义按钮区域并初始化
	CRect rect(lpDrawItemStruct->rcItem);

	//设置背景模式
	COLORREF oc=RGB(30,123,255);
		//oc = pDC->GetTextColor();
int iObk = pDC->SetBkMode(TRANSPARENT);

	//初始化按钮状态
	UINT state = lpDrawItemStruct->itemState;

	CFont * pOldFont = NULL;

	int iYOffset = 0, iXOffset = 0;

	CString strText;
	GetWindowText(strText);

	rect.top  += iYOffset;
	rect.left += iXOffset;


	if (state & ODS_DISABLED)
	{		
		//按钮置灰(DISABLED)
		CBrush grayBrush;
		grayBrush.CreateSolidBrush (GetSysColor (COLOR_GRAYTEXT));
		CSize sz = pDC->GetTextExtent(strText);
		int x = rect.left + (rect.Width() - sz.cx)/2;
		int y = rect.top + (rect.Height() - sz.cy)/2;
		rect.top  += 2;
		rect.left += 2;
		pDC->SetTextColor(GetSysColor(COLOR_3DHIGHLIGHT));
		pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		rect.top  -= 2;
		rect.left -= 2;
		pDC->SetTextColor(GetSysColor(COLOR_GRAYTEXT));
		pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	}
	else
	{
		if (bHighlight)//光标在按钮上
		{
			if (state & ODS_SELECTED)
			{
				//按下按钮
				pDC->Draw3dRect(rect,RGB(0,0,255), RGB(0,0,255));
			}
			else
			{
				//未按下按钮
				pDC->Draw3dRect(rect,RGB(255,0,0),RGB(255,0,0));			}
			//字体颜色
			pDC->SetTextColor(RGB(0,0,255));

			//加下画线(也可以用其他字体)
			if (fUnderline.GetSafeHandle() == NULL)
			{
				CFont * pFont = GetFont();
				ASSERT(pFont);
				LOGFONT lf;
				pFont->GetLogFont(&lf);
				lf.lfUnderline = TRUE;
				fUnderline.CreateFontIndirect(&lf);		
			}

			pOldFont = pDC->SelectObject(&fUnderline);
		}
		else 
		{
			pDC->SetTextColor(RGB(255,123,30));
			pDC->Draw3dRect(rect,RGB(255,0,0),RGB(255,0,0));	}

		pDC->DrawText(strText, rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
		if (pOldFont) pDC->SelectObject(pOldFont);
	}
}
Example #22
0
void CUploadsCtrl::PaintFile(CDC& dc, const CRect& rcRow, CUploadQueue* /*pQueue*/, CUploadFile* pFile, int nPosition, BOOL bFocus)
{
	ASSUME_LOCK( Transfers.m_pSection );

	CUploadTransfer* pTransfer = pFile->GetActive();
	int nFlagImage = Flags.GetFlagIndex( pTransfer->m_sCountry );
	COLORREF crNatural		= CoolInterface.m_crWindow;
	COLORREF crBack			= pFile->m_bSelected ? CoolInterface.m_crHighlight : crNatural;
	COLORREF crLeftAligned	= crBack;
	COLORREF crBorder		= pFile->m_bSelected ? CoolInterface.m_crFragmentBorderSelected : CoolInterface.m_crFragmentBorder;

	dc.SetBkColor( crBack );
	dc.SetBkMode( OPAQUE );
	
	if ( pFile->m_bSelected )
		dc.SetTextColor( CoolInterface.m_crHiText );
	else if ( pTransfer == NULL || pTransfer->m_nState == upsNull )
		dc.SetTextColor( CoolInterface.m_crDisabled );
	else
		dc.SetTextColor( CoolInterface.m_crText );
	
	int nTextLeft = rcRow.right, nTextRight = rcRow.left;
	HDITEM pColumn = {};
	
	pColumn.mask = HDI_FORMAT | HDI_LPARAM;

	for ( int nColumn = 0 ; m_wndHeader.GetItem( nColumn, &pColumn ) ; nColumn++ )
	{
		CString strText;
		CRect rcCell;
		
		m_wndHeader.GetItemRect( nColumn, &rcCell );
		rcCell.left		+= rcRow.left;
		rcCell.right	+= rcRow.left;
		rcCell.top		= rcRow.top;
		rcCell.bottom	= rcRow.bottom;
		
		crLeftAligned = ( rcRow.left == rcCell.left ? crNatural : crBack ) ;

		switch ( pColumn.lParam )
		{
		case UPLOAD_COLUMN_TITLE:
			dc.FillSolidRect( rcCell.left, rcCell.top, 24, rcCell.Height(), crLeftAligned );
			rcCell.left += 24;
			dc.FillSolidRect( rcCell.left, rcCell.bottom - 1, 16, 1, crLeftAligned );
			ShellIcons.Draw( &dc, ShellIcons.Get( ( lstrcmpi(
				PathFindExtension( pFile->m_sPath ), _T(".partial") ) ?
				pFile->m_sPath : pFile->m_sName ), 16 ), 16,
				rcCell.left, rcCell.top, crBack, pFile->m_bSelected );
			rcCell.left += 16;
			dc.FillSolidRect( rcCell.left, rcCell.top, 1, rcCell.Height(), crLeftAligned );
			rcCell.left += 1;
			strText = pFile->m_sName;
			break;
			
		case UPLOAD_COLUMN_USER:
			if ( pTransfer == NULL )
				strText.Empty();
			else if ( pTransfer->m_sRemoteNick.IsEmpty() )
				strText = pTransfer->m_sAddress;
			else
				strText = pTransfer->m_sRemoteNick + _T(" (") + pTransfer->m_sAddress + _T(")");
			break;
			
		case UPLOAD_COLUMN_SIZE:
			strText = Settings.SmartVolume( pFile->m_nSize );
			break;
			
		case UPLOAD_COLUMN_PROGRESS:
			dc.Draw3dRect( &rcCell, crBack, crBack );
			rcCell.DeflateRect( 1, 1 );
			dc.Draw3dRect( &rcCell, crBack, crBack );
			rcCell.DeflateRect( 0, 1 );
			dc.Draw3dRect( &rcCell, crBorder, crBorder );
			rcCell.DeflateRect( 1, 1 );
			CFragmentBar::DrawUpload( &dc, &rcCell, pFile, crNatural );
			break;
			
		case UPLOAD_COLUMN_SPEED:
			if ( pTransfer == NULL || pTransfer->m_nState == upsNull )
				LoadString( strText, IDS_STATUS_COMPLETED );
			else if ( pTransfer->m_nProtocol == PROTOCOL_BT )
			{
				CUploadTransferBT* pBT = (CUploadTransferBT*)pTransfer;
				
				if ( ! pBT->m_bInterested )
					LoadString( strText, IDS_STATUS_UNINTERESTED );
				else if ( pBT->m_bChoked )
					LoadString( strText, IDS_STATUS_CHOKED );
				else
				{
					DWORD nSpeed = pTransfer->GetMeasuredSpeed();
					if ( nSpeed )
						strText = Settings.SmartSpeed( nSpeed );
				}
			}
			else if ( nPosition > 0 )
			{
				CString strQ;
				LoadString( strQ, IDS_STATUS_Q );
				strText.Format( _T("%s %i"), (LPCTSTR)strQ, nPosition );
			}
			else
			{
				DWORD nSpeed = pTransfer->GetMeasuredSpeed();
				if ( nSpeed )
					strText = Settings.SmartSpeed( nSpeed );
				else
					LoadString( strText, IDS_STATUS_NEXT );
			}
			break;
			
		case UPLOAD_COLUMN_CLIENT:
			if ( pTransfer != NULL ) strText = pTransfer->m_sUserAgent;
			break;
		case UPLOAD_COLUMN_RATING:
			strText.Format(_T("%u"), pTransfer->m_nUserRating );
			break;
		case UPLOAD_COLUMN_COUNTRY:
			dc.FillSolidRect( rcCell.left, rcCell.top, 20, rcCell.Height(), crBack );
			rcCell.left += 2;
			if ( nFlagImage >= 0 )
				Flags.Draw( nFlagImage, dc.GetSafeHdc(), rcCell.left, rcCell.top + 2, CLR_NONE, CLR_DEFAULT, pFile->m_bSelected ? ILD_SELECTED : ILD_NORMAL );

			rcCell.left += 16;
			dc.FillSolidRect( rcCell.left, rcCell.top, 1, rcCell.Height(), crNatural );

			strText = pTransfer->m_sCountry;
			break;
		}
		
		nTextLeft	= min( (LONG)nTextLeft, rcCell.left );
		nTextRight	= max( (LONG)nTextRight, rcCell.right );
		
		if ( pColumn.lParam == UPLOAD_COLUMN_PROGRESS ) continue;
		
		if ( rcCell.Width() < 8 ) strText.Empty();
		
		if ( dc.GetTextExtent( strText ).cx > rcCell.Width() - 8 )
		{
			while ( dc.GetTextExtent( strText + _T('\x2026') ).cx > ( rcCell.Width() - 8 ) && strText.GetLength() > 0 )
			{
				strText.Truncate( strText.GetLength() - 1 );
			}
			
			if ( strText.GetLength() > 0 ) strText += _T('\x2026');
		}
		
		int nWidth		= dc.GetTextExtent( strText ).cx;
		int nPos	= 0;
		
		switch ( pColumn.fmt & LVCFMT_JUSTIFYMASK )
		{
		default:
			nPos = ( rcCell.left + 4 );
			break;
		case LVCFMT_CENTER:
			nPos = ( ( rcCell.left + rcCell.right ) / 2 ) - ( nWidth / 2 );
			break;
		case LVCFMT_RIGHT:
			nPos = ( rcCell.right - 4 - nWidth );
			break;
		}
		
		dc.SetBkColor( crBack );
		dc.ExtTextOut( nPos, rcCell.top + 2, ETO_CLIPPED|ETO_OPAQUE,
			&rcCell, strText, NULL );
	}
	
	if ( nTextRight < rcRow.right )
	{
		CRect rcBlank( nTextRight, rcRow.top, rcRow.right, rcRow.bottom );
		dc.FillSolidRect( &rcBlank, crBack );
	}
	
	if ( bFocus )
	{
		CRect rcFocus( nTextLeft, rcRow.top, max( (int)rcRow.right, nTextRight ), rcRow.bottom );
		dc.Draw3dRect( &rcFocus, CoolInterface.m_crHiBorder, CoolInterface.m_crHiBorder );
	}
}
Example #23
0
void CUploadsCtrl::PaintQueue(CDC& dc, const CRect& rcRow, CUploadQueue* pQueue, BOOL bFocus)
{
	ASSUME_LOCK( UploadQueues.m_pSection );

	COLORREF crNatural	= CoolInterface.m_crWindow;
	COLORREF crBack		= pQueue->m_bSelected ? CoolInterface.m_crHighlight : crNatural;
	COLORREF crLeftAligned = crBack ;

	dc.SetBkColor( crBack );
	dc.SetBkMode( OPAQUE );
	
	if ( pQueue->m_bSelected )
		dc.SetTextColor( CoolInterface.m_crHiText );
	else
		dc.SetTextColor( CoolInterface.m_crText );
	
	int nTextLeft = rcRow.right, nTextRight = rcRow.left;
	HDITEM pColumn = {};
	
	pColumn.mask = HDI_FORMAT | HDI_LPARAM;
	
	dc.SelectObject( &CoolInterface.m_fntBold );
	
	for ( int nColumn = 0 ; m_wndHeader.GetItem( nColumn, &pColumn ) ; nColumn++ )
	{
		CString strText;
		CRect rcCell;
		
		m_wndHeader.GetItemRect( nColumn, &rcCell );
		rcCell.left		+= rcRow.left;
		rcCell.right	+= rcRow.left;
		rcCell.top		= rcRow.top;
		rcCell.bottom	= rcRow.bottom;

		crLeftAligned = ( rcRow.left == rcCell.left ? crNatural : crBack ) ;

		POINT ptHover;
		RECT  rcTick = { rcCell.left+2, rcCell.top+2, rcCell.left+14, rcCell.bottom-2 };
		GetCursorPos(&ptHover);
		ScreenToClient(&ptHover);

		switch ( pColumn.lParam )
		{
		case UPLOAD_COLUMN_TITLE:
			dc.FillSolidRect( rcCell.left, rcCell.bottom - 1, 32, 1, crLeftAligned );

			if ( pQueue->m_bExpanded )
			{
			CoolInterface.Draw( &dc, PtInRect(&rcTick,ptHover) ? IDI_MINUS_HOVER : IDI_MINUS,
					16, rcCell.left, rcCell.top, crLeftAligned );
			}
			else
			{
				CoolInterface.Draw( &dc, PtInRect(&rcTick,ptHover) ? IDI_PLUS_HOVER : IDI_PLUS,
					16, rcCell.left, rcCell.top, crLeftAligned );
			}

			rcCell.left += 16;
			if ( pQueue == UploadQueues.m_pTorrentQueue )
			{
				ImageList_DrawEx( m_gdiProtocols, PROTOCOL_BT, dc.GetSafeHdc(),
						rcCell.left, rcCell.top, 16, 16, crLeftAligned, CLR_DEFAULT, pQueue->m_bSelected ? ILD_SELECTED : ILD_NORMAL );
			}
			else if ( pQueue->m_nProtocols == ( 1 << PROTOCOL_HTTP ) )
			{
				ImageList_DrawEx( m_gdiProtocols, PROTOCOL_HTTP, dc.GetSafeHdc(),
						rcCell.left, rcCell.top, 16, 16, crLeftAligned, CLR_DEFAULT, pQueue->m_bSelected ? ILD_SELECTED : ILD_NORMAL );
			}
			else if ( pQueue->m_nProtocols == ( 1 << PROTOCOL_ED2K ) )
			{
				ImageList_DrawEx( m_gdiProtocols, PROTOCOL_ED2K, dc.GetSafeHdc(),
						rcCell.left, rcCell.top, 16, 16, crLeftAligned, CLR_DEFAULT, pQueue->m_bSelected ? ILD_SELECTED : ILD_NORMAL );
			}
			else
			{
				CoolInterface.Draw( &dc,
					pQueue->m_bExpanded ? IDI_FOLDER_OPEN : IDI_FOLDER_CLOSED, 16,
					rcCell.left, rcCell.top, crLeftAligned, pQueue->m_bSelected );
			}
			rcCell.left += 16;
			dc.FillSolidRect( rcCell.left, rcCell.top, 1, rcCell.Height(), crLeftAligned );
			rcCell.left += 1;
			
			strText = pQueue->m_sName;
			break;
			
		case UPLOAD_COLUMN_SIZE:
			if ( pQueue == UploadQueues.m_pTorrentQueue )
				strText.Format( _T("%u/%u"), pQueue->m_nMinTransfers, pQueue->m_nMaxTransfers ); //No. Clients was loaded into these variables
			else if ( pQueue != UploadQueues.m_pHistoryQueue )
				strText.Format( _T("%u/%u"), pQueue->GetTransferCount(), pQueue->GetQueuedCount() );
			break;
			
		case UPLOAD_COLUMN_SPEED:
			if ( pQueue != UploadQueues.m_pHistoryQueue )
				strText = Settings.SmartSpeed( pQueue->GetMeasuredSpeed() );
			break;
		}
		
		nTextLeft	= min( nTextLeft, (int)rcCell.left );
		nTextRight	= max( nTextRight, (int)rcCell.right );
		
		if ( rcCell.Width() < 8 ) strText.Empty();
		
		if ( dc.GetTextExtent( strText ).cx > rcCell.Width() - 8 )
		{
			while ( dc.GetTextExtent( strText + _T('\x2026') ).cx > ( rcCell.Width() - 8 ) && strText.GetLength() > 0 )
			{
				strText.Truncate( strText.GetLength() - 1 );
			}
			
			if ( strText.GetLength() > 0 ) strText += _T('\x2026');
		}
		
		int nWidth		= dc.GetTextExtent( strText ).cx;
		int nPosition	= 0;
		
		switch ( pColumn.fmt & LVCFMT_JUSTIFYMASK )
		{
		default:
			nPosition = ( rcCell.left + 4 );
			break;
		case LVCFMT_CENTER:
			nPosition = ( ( rcCell.left + rcCell.right ) / 2 ) - ( nWidth / 2 );
			break;
		case LVCFMT_RIGHT:
			nPosition = ( rcCell.right - 4 - nWidth );
			break;
		}
		
		dc.SetBkColor( crBack );
		dc.ExtTextOut( nPosition, rcCell.top + 2, ETO_CLIPPED|ETO_OPAQUE,
			&rcCell, strText, NULL );
	}
	
	if ( nTextRight < rcRow.right )
	{
		CRect rcBlank( nTextRight, rcRow.top, rcRow.right, rcRow.bottom );
		dc.FillSolidRect( &rcBlank, crBack );
	}
	
	dc.SelectObject( &CoolInterface.m_fntNormal );
	
	if ( bFocus )
	{
		CRect rcFocus( nTextLeft, rcRow.top, max( (int)rcRow.right, nTextRight ), rcRow.bottom );
		dc.Draw3dRect( &rcFocus, CoolInterface.m_crHiBorder, CoolInterface.m_crHiBorder );
	}
}
Example #24
0
// draw days of month
int CMiniCalendarCtrl::DrawDays(CDC& _dc,
								int _iY,
								int _iLeftX,
								int _iRow,
								int _iMonth,
								int _iYear)
{
	int iReturn = 0;
	int iStartY = _iY;

	COleDateTime dtStart;
	dtStart.SetDate(_iYear, _iMonth, 1);

	COleDateTime dt(dtStart);
	while (dt.GetDayOfWeek() != m_iFirstDayOfWeek)
		dt -= 1;

	// calculate starting X position
	int iStartX = ((_iLeftX + (m_szMonthSize.cx / 2))) - (((m_iIndividualDayWidth*7) + 30) / 2);
	int iEndX = ((_iLeftX + (m_szMonthSize.cx / 2))) + (((m_iIndividualDayWidth*7) + 30) / 2);

	int iX = iStartX;

	CFont* pOldFont = _dc.SelectObject(m_pFont);
	_dc.SetBkColor(::GetSysColor(COLOR_BTNFACE));
	_dc.SetTextColor(::GetSysColor(COLOR_BTNTEXT));
	_dc.SetBkMode(TRANSPARENT);

	int iDayCounter = 0;

	// we allow up to 6 rows of days.  This is the actual maximum # of calendar
	// weeks that can occur in a month.
	int iRow; 
	for (iRow = 1; iRow <= 6; iRow++)
	{
		int iX = iStartX;

		for (int iDayOfWeek = 1; iDayOfWeek <= 7; iDayOfWeek++)
		{
			if (dt.GetMonth() == dtStart.GetMonth() ||
				(dt > dtStart && _iRow == m_iRows) ||
				(dt < dtStart && _iRow == 1))
			{
				CString strText = CCalendarUtils::LongToString(dt.GetDay());

				COLORREF cTextColor = MINICAL_COLOUR_DAY;
				if (dt.GetMonth() != _iMonth)
				{
					cTextColor = MINICAL_COLOUR_DAY_DIFFERENTMONTH;
				}

				//initialize as a normal date
				pOldFont = _dc.SelectObject(m_pFont);
				_dc.SetTextColor(cTextColor);

				if (IsDateSelected(dt))
				{
					//selected date
					if (m_pCalendarData->IsImportantDate(dt))
					{
						//important date too
						pOldFont = _dc.SelectObject(m_pFontBold);
					}
					else
					{
						pOldFont = _dc.SelectObject(m_pFont);
					}

					_dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
					_dc.FillSolidRect(iX-1, _iY, m_iIndividualDayWidth+3, m_iDaysHeight+1, ::GetSysColor(COLOR_HIGHLIGHT));
				}
				else if (m_pCalendarData->IsImportantDate(dt))
				{
					BOOL bImportantDate = TRUE;

					DWORD dwStyleCompletedTasks = m_pWnd->GetDisplayFlags();
					if (dwStyleCompletedTasks & COMPLETEDTASKS_HIDDEN)
					{
						//completed tasks are hidden. only consider this date important if there is one or more non-hidden tasks
						bImportantDate = FALSE;

						CTaskInfoList listTasks;
						m_pCalendarData->GetTasks(dt, listTasks);
						ASSERT(!listTasks.IsEmpty());

						//look for non-hidden tasks
						for (POSITION pos = listTasks.GetHeadPosition(); (pos != NULL) && !bImportantDate; )
						{
							CTaskInfo ti = listTasks.GetNext(pos);
							if (!ti.IsComplete())
							{
								bImportantDate = TRUE;
							}
						}
					}

					if (bImportantDate)
					{
						//important date
						pOldFont = _dc.SelectObject(m_pFontBold);
						if (m_pWnd->IsDateHidden(dt))
						{
							//hidden weekend date
							_dc.SetTextColor(MINICAL_COLOUR_HIDDEN_WEEKEND_DAY);
						}
						_dc.FillSolidRect(iX-1, _iY, m_iIndividualDayWidth+3, m_iDaysHeight+1, MINICAL_COLOUR_IMPORTANTDAY_BACKGROUND);
					}
				}
				else if (m_pWnd->IsDateHidden(dt))
				{
					//hidden weekend date
					pOldFont = _dc.SelectObject(m_pFont);
					_dc.SetTextColor(MINICAL_COLOUR_HIDDEN_WEEKEND_DAY);
				}

				_dc.DrawText(strText, CRect(iX, _iY, iX+m_iIndividualDayWidth,_iY+m_iDaysHeight), DT_BOTTOM | DT_RIGHT | DT_SINGLELINE);

				//highlight today
				if (IsToday(dt))
					_dc.Draw3dRect(iX-2, _iY, m_iIndividualDayWidth+5, m_iDaysHeight+1, MINICAL_COLOUR_HEADERFONT, MINICAL_COLOUR_HEADERFONT);

				SetHotSpot(_iRow, iDayCounter, dt, CRect(iX-3,_iY,iX-3+m_iIndividualDayWidth+5, _iY+m_iDaysHeight+2));
			}

			dt += 1;
			iX += (m_iIndividualDayWidth + 5);
			iDayCounter++;
		}

		_iY += (2 + m_iDaysHeight);
		iReturn += (2 + m_iDaysHeight);
	}

	_dc.SelectObject(pOldFont);

	// draw the divider line
	if (iRow == m_iRows)
	{
		CPen* pPen = new CPen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW));
		CPen* pOldPen = _dc.SelectObject(pPen);

		_dc.MoveTo(iStartX, _iY);
		_dc.LineTo(iEndX, _iY);

		_dc.SelectObject(pOldPen);
		delete pPen;
	}

	iReturn += 5;

	SetCellPosition(_iRow, CRect(iStartX, iStartY, iEndX, _iY));

	return iReturn;
}
Example #25
0
void CSHListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// This function is called by the control in different 
	// stages during the control drawing process.
	if (!m_bKeyEvent)
		return;

	NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR;
	// By default set the return value to do the default behavior.
	*pResult = 0;
	
	switch( pCD->nmcd.dwDrawStage )
	{
	case  CDDS_PREPAINT:  // First stage (for the whole control)
		// Tell the control we want to receive drawing messages  
		// for drawing items.
		*pResult = CDRF_NOTIFYITEMDRAW;
		// The next stage is handled in the default:
		break;
	case CDDS_ITEMPREPAINT | CDDS_SUBITEM: // Stage three (called for each subitem of the focused item)
		{
			// We don't want to draw anything here, but we need to respond 
			// of DODEFAULT will be the next stage.
			// Tell the control we want to handle drawing after the subitem 
			// is drawn.
			*pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
		}
		break;
	case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM: // Stage four (called for each subitem of the focused item)
		{
			// We do the drawing here (well maybe).
			// This is actually after the control has done its drawing
			// on the subitem.  Since drawing a cell is near instantaneous
			// the user won't notice.
			int subitem = pCD->iSubItem;
			// Only do our own drawing if this subitem has focus at the item level.
			if( (pCD->nmcd.uItemState & CDIS_FOCUS) )
			{
				// If this subitem is the subitem with the current focus,
				// draw it.  Otherwise let the control draw it.  
				CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
				// We have to take into account the possibility that the 
				// columns may be reordered.
				if( subitem == Header_OrderToIndex( pHeader->m_hWnd,  m_CurSubItem ) )
				{
					// POSTERASE
					CDC* pDC = CDC::FromHandle(pCD->nmcd.hdc);
					// Calculate the offset of the text from the right and left of the cell.
					int offset = pDC->GetTextExtent(_T(" "), 1 ).cx*2;
					// The rect for the cell gives correct left and right values.
					CRect rect = pCD->nmcd.rc;
					CRect bounds;
					GetItemRect( pCD->nmcd.dwItemSpec, &bounds, LVIR_BOUNDS );
					// Get the top and bottom from the item itself.
					rect.top = bounds.top;
					rect.bottom = bounds.bottom;
					// Adjust rectangle for horizontal scroll and first column label
					{
						if( subitem == 0 )
						{
							CRect lrect;
							GetItemRect( pCD->nmcd.dwItemSpec, &lrect, LVIR_LABEL );
							rect.left = lrect.left;
							rect.right = lrect.right;
						}
						else
						{
							rect.right += bounds.left;
							rect.left  += bounds.left;
						}
					}
					// Clear the background with button face color
					pDC->FillRect(rect, &CBrush(::GetSysColor(COLOR_3DFACE)));
					// PREPAINT
					CString str;
					str = GetItemText( pCD->nmcd.dwItemSpec, pCD->iSubItem );
					// Deflate the rect by the horizontal offset.
					rect.DeflateRect( offset, 0 );
					// You could also make this column alignment sensitive here.
					pDC->DrawText( str, rect, 
						DT_SINGLELINE|DT_NOPREFIX|DT_LEFT|DT_VCENTER|DT_END_ELLIPSIS);
					// POSTPAINT
					// Draw rounded edge
					rect.InflateRect( offset, 0 );
					pDC->Draw3dRect( &rect, ::GetSysColor(COLOR_3DSHADOW), ::GetSysColor(COLOR_3DFACE) );
					rect.DeflateRect( 1, 1 );
					pDC->Draw3dRect( &rect, ::GetSysColor(COLOR_3DDKSHADOW), ::GetSysColor(COLOR_3DHILIGHT) );
					// Tell the control that we handled the drawing for this subitem.
					*pResult = CDRF_SKIPDEFAULT;
				}
			}
		}
		break;
	default: // Stage two handled here. (called for each item)
		if( !(pCD->nmcd.uItemState & CDIS_FOCUS) )
		{
			// If this item does not have focus, let the 
			// control draw the whole item.
			*pResult = CDRF_DODEFAULT;
		}
		else
		{
			// If this item has focus, tell the control we want
			// to handle subitem drawing.
			*pResult = CDRF_NOTIFYSUBITEMDRAW;
		}
		break;
	}
}
Example #26
0
void CButtonST::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
#ifdef ST_USE_MEMDC
  CDC  *pdrawDC = CDC::FromHandle(lpDIS->hDC);
  CMemDC memDC(pdrawDC);
  CDC  *pDC = &memDC;
#else	
  CDC* pDC = CDC::FromHandle(lpDIS->hDC);
#endif

  if (NULL == pDC)
	  return;

  CPen *pOldPen;
  BOOL bIsPressed  = (lpDIS->itemState & ODS_SELECTED);
  BOOL bIsFocused  = (lpDIS->itemState & ODS_FOCUS);
  BOOL bIsDisabled = (lpDIS->itemState & ODS_DISABLED);

  CRect itemRect = lpDIS->rcItem;

  pDC->SetBkMode(TRANSPARENT);

  if (m_bIsFlat == FALSE)
  {
    if (bIsFocused || (GetDefault() == TRUE))
    {
      CBrush br(RGB(0,0,0));  
      pDC->FrameRect(&itemRect, &br);
      itemRect.DeflateRect(1, 1);
    }
  }

  // Prepare draw... paint button's area with background color
  COLORREF bgColor;
  if ((m_MouseOnButton == TRUE) || (bIsPressed))
    bgColor = GetActiveBgColor();
  else
    bgColor = GetInactiveBgColor();

	CBrush br(bgColor);
	// Draw transparent?
	if (m_bDrawTransparent == TRUE)
	{
		PaintBk(pDC);
	}
	else
	{
		pDC->FillRect(&itemRect, &br);
	}

	// Disegno lo sfondo del bottone
//CBrush br(GetSysColor(COLOR_BTNFACE));  
//pDC->FillRect(&itemRect, &br);

  // Draw pressed button
  if (bIsPressed)
  {
    if (m_bIsFlat == TRUE)
    {
      if (m_bDrawBorder == TRUE)
      {
		  pDC->Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHILIGHT));
/*
	    CPen penBtnHiLight(PS_SOLID, 0, GetSysColor(COLOR_BTNHILIGHT)); // Bianco
        CPen penBtnShadow(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW));   // Grigio scuro

        // Disegno i bordi a sinistra e in alto
        // Dark gray line
        pOldPen = pDC->SelectObject(&penBtnShadow);
        pDC->MoveTo(itemRect.left, itemRect.bottom-1);
        pDC->LineTo(itemRect.left, itemRect.top);
        pDC->LineTo(itemRect.right, itemRect.top);
        // Disegno i bordi a destra e in basso
        // White line
        pDC->SelectObject(penBtnHiLight);
        pDC->MoveTo(itemRect.left, itemRect.bottom-1);
        pDC->LineTo(itemRect.right-1, itemRect.bottom-1);
        pDC->LineTo(itemRect.right-1, itemRect.top-1);
        //
        pDC->SelectObject(pOldPen);
*/
      }
    }
    else    
    {
      CBrush brBtnShadow(GetSysColor(COLOR_BTNSHADOW));
      pDC->FrameRect(&itemRect, &brBtnShadow);
    }
  }
  else // ...else draw non pressed button
  {
    CPen penBtnHiLight(PS_SOLID, 0, GetSysColor(COLOR_BTNHILIGHT)); // White
    CPen pen3DLight(PS_SOLID, 0, GetSysColor(COLOR_3DLIGHT));       // Light gray
    CPen penBtnShadow(PS_SOLID, 0, GetSysColor(COLOR_BTNSHADOW));   // Dark gray
    CPen pen3DDKShadow(PS_SOLID, 0, GetSysColor(COLOR_3DDKSHADOW)); // Black

    if (m_bIsFlat == TRUE)
    {
      if (m_MouseOnButton == TRUE && m_bDrawBorder == TRUE)
      {
		  pDC->Draw3dRect(itemRect, ::GetSysColor(COLOR_BTNHILIGHT), ::GetSysColor(COLOR_BTNSHADOW));
/*
  	    // Disegno i bordi a sinistra e in alto
        // White line
        pOldPen = pDC->SelectObject(&penBtnHiLight);
        pDC->MoveTo(itemRect.left, itemRect.bottom-1);
        pDC->LineTo(itemRect.left, itemRect.top);
        pDC->LineTo(itemRect.right, itemRect.top);
        // Disegno i bordi a destra e in basso
        // Dark gray line
        pDC->SelectObject(penBtnShadow);
        pDC->MoveTo(itemRect.left, itemRect.bottom-1);
        pDC->LineTo(itemRect.right-1, itemRect.bottom-1);
        pDC->LineTo(itemRect.right-1, itemRect.top-1);
        //
        pDC->SelectObject(pOldPen);
*/
      }
    }
    else
    {
      // Disegno i bordi a sinistra e in alto
      // White line
      pOldPen = pDC->SelectObject(&penBtnHiLight);
      pDC->MoveTo(itemRect.left, itemRect.bottom-1);
      pDC->LineTo(itemRect.left, itemRect.top);
      pDC->LineTo(itemRect.right, itemRect.top);
      // Light gray line
      pDC->SelectObject(pen3DLight);
      pDC->MoveTo(itemRect.left+1, itemRect.bottom-1);
      pDC->LineTo(itemRect.left+1, itemRect.top+1);
      pDC->LineTo(itemRect.right, itemRect.top+1);
      // Disegno i bordi a destra e in basso
      // Black line
      pDC->SelectObject(pen3DDKShadow);
      pDC->MoveTo(itemRect.left, itemRect.bottom-1);
      pDC->LineTo(itemRect.right-1, itemRect.bottom-1);
      pDC->LineTo(itemRect.right-1, itemRect.top-1);
      // Dark gray line
      pDC->SelectObject(penBtnShadow);
      pDC->MoveTo(itemRect.left+1, itemRect.bottom-2);
      pDC->LineTo(itemRect.right-2, itemRect.bottom-2);
      pDC->LineTo(itemRect.right-2, itemRect.top);
      //
      pDC->SelectObject(pOldPen);
    }
  }

  // Read the button's title
  CString sTitle;
  GetWindowText(sTitle);

  // If we don't want the title displayed
  if (m_bShowText == FALSE) sTitle.Empty();

  CRect captionRect = lpDIS->rcItem;

  // Draw the icon
  if (m_hIconIn != NULL)
  {
    DrawTheIcon(pDC, &sTitle, &lpDIS->rcItem, &captionRect, bIsPressed, bIsDisabled);
  }

  // Write the button title (if any)
  if (sTitle.IsEmpty() == FALSE)
  {
    // Disegno la caption del bottone
    // Se il bottone e' premuto muovo la captionRect di conseguenza
    if (bIsPressed)
      captionRect.OffsetRect(1, 1);
    
    // ONLY FOR DEBUG 
    // Evidenzia il rettangolo in cui verra' centrata la caption 
    //CBrush brBtnShadow(RGB(255, 0, 0));
    //pDC->FrameRect(&captionRect, &brBtnShadow);

#ifdef ST_USE_MEMDC
	// Get dialog's font
    CFont *pCurrentFont = GetFont(); 
    CFont *pOldFont = pDC->SelectObject(pCurrentFont);
#endif
    if ((m_MouseOnButton == TRUE) || (bIsPressed)) 
	{
      pDC->SetTextColor(GetActiveFgColor());
      pDC->SetBkColor(GetActiveBgColor());
    } 
	else 
	{
      pDC->SetTextColor(GetInactiveFgColor());
      pDC->SetBkColor(GetInactiveBgColor());
    }
    // Center text
    CRect centerRect = captionRect;
    pDC->DrawText(sTitle, -1, captionRect, DT_SINGLELINE|DT_CALCRECT);
    captionRect.OffsetRect((centerRect.Width() - captionRect.Width())/2, (centerRect.Height() - captionRect.Height())/2);
	/* RFU
    captionRect.OffsetRect(0, (centerRect.Height() - captionRect.Height())/2);
    captionRect.OffsetRect((centerRect.Width() - captionRect.Width())-4, (centerRect.Height() - captionRect.Height())/2);
	*/

	pDC->SetBkMode(TRANSPARENT);
    pDC->DrawState(captionRect.TopLeft(), captionRect.Size(), (LPCTSTR)sTitle, (bIsDisabled ? DSS_DISABLED : DSS_NORMAL), 
                   TRUE, (int)_tcslen(sTitle), (CBrush*)NULL);
#ifdef ST_USE_MEMDC
    pDC->SelectObject(pOldFont);
#endif
  }

  if (m_bIsFlat == FALSE || (m_bIsFlat == TRUE && m_bDrawFlatFocus == TRUE))
  {
    // Draw the focus rect
    if (bIsFocused)
    {
      CRect focusRect = itemRect;
      focusRect.DeflateRect(3, 3);
      pDC->DrawFocusRect(&focusRect);
    }
  }
} // End of DrawItem
Example #27
0
void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
{
    LPNMCUSTOMDRAW pNMCD = reinterpret_cast<LPNMCUSTOMDRAW>(pNMHDR);

    LRESULT lr = CDRF_DODEFAULT;

    if (m_fSelfDrawn)
        switch (pNMCD->dwDrawStage) {
            case CDDS_PREPAINT:
                lr = CDRF_NOTIFYITEMDRAW;
                break;

            case CDDS_ITEMPREPAINT:
                if (pNMCD->dwItemSpec == TBCD_CHANNEL) {
                    CDC dc;
                    dc.Attach(pNMCD->hdc);

                    CRect channelRect;
                    GetChannelRect(channelRect);
                    CRect thumbRect;
                    GetThumbRect(thumbRect);

                    CopyRect(&pNMCD->rc, CRect(channelRect.left, thumbRect.top + 2, channelRect.right - 2, thumbRect.bottom - 2));
                    CPen shadow(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
                    CPen light(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
                    CPen* old = dc.SelectObject(&light);
                    dc.MoveTo(pNMCD->rc.right, pNMCD->rc.top);
                    dc.LineTo(pNMCD->rc.right, pNMCD->rc.bottom);
                    dc.LineTo(pNMCD->rc.left, pNMCD->rc.bottom);
                    dc.SelectObject(&shadow);
                    dc.LineTo(pNMCD->rc.right, pNMCD->rc.top);
                    dc.SelectObject(old);

                    dc.Detach();
                    lr = CDRF_SKIPDEFAULT;
                } else if (pNMCD->dwItemSpec == TBCD_THUMB) {
                    CDC dc;
                    dc.Attach(pNMCD->hdc);
                    pNMCD->rc.bottom--;
                    CRect r(pNMCD->rc);
                    r.DeflateRect(0, 0, 1, 0);

                    COLORREF shadow = GetSysColor(COLOR_3DSHADOW);
                    COLORREF light = GetSysColor(COLOR_3DHILIGHT);
                    dc.Draw3dRect(&r, light, 0);
                    r.DeflateRect(0, 0, 1, 1);
                    dc.Draw3dRect(&r, light, shadow);
                    r.DeflateRect(1, 1, 1, 1);
                    dc.FillSolidRect(&r, GetSysColor(COLOR_BTNFACE));
                    dc.SetPixel(r.left + 7, r.top - 1, GetSysColor(COLOR_BTNFACE));

                    dc.Detach();
                    lr = CDRF_SKIPDEFAULT;
                }

                break;
        };

    pNMCD->uItemState &= ~CDIS_FOCUS;

    *pResult = lr;
}
Example #28
0
void CCoolMenu::OnDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	CRect rcItem, rcText;
	CString strText;
	int nIcon = -1;
	CDC dc;
	
	BOOL	bSelected	= lpDrawItemStruct->itemState & ODS_SELECTED;
	BOOL	bChecked	= lpDrawItemStruct->itemState & ODS_CHECKED;
	BOOL	bDisabled	= lpDrawItemStruct->itemState & ODS_GRAYED;
	BOOL	bKeyboard	= FALSE;
	BOOL	bEdge		= TRUE;
	
	dc.Attach( lpDrawItemStruct->hDC );
	
	if ( CWnd* pWnd = dc.GetWindow() )
	{
		CRect rcScreen( &lpDrawItemStruct->rcItem );
		CPoint ptCursor;
		
		GetCursorPos( &ptCursor );
		pWnd->ClientToScreen( &rcScreen );
		
		bKeyboard = ! rcScreen.PtInRect( ptCursor );
	}
	
	rcItem.CopyRect( &lpDrawItemStruct->rcItem );
	rcItem.OffsetRect( -rcItem.left, -rcItem.top );
	if ( m_hMsgHook != NULL ) rcItem.bottom += ( bEdge = m_bPrinted );
	
	rcText.CopyRect( &rcItem );
	rcText.left += 32;
	rcText.right -= 2;
	
	CDC* pDC = CoolInterface.GetBuffer( dc, rcItem.Size() );
	
	if ( m_bmWatermark.m_hObject != NULL )
	{
		DrawWatermark( pDC, &rcItem, lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top );
	}
	else
	{
		pDC->FillSolidRect( rcItem.left, rcItem.top, 24, rcItem.Height(), CoolInterface.m_crMargin );
		pDC->FillSolidRect( rcItem.left + 24, rcItem.top, rcItem.Width() - 24, rcItem.Height(), CoolInterface.m_crBackNormal );
	}
	
	if ( m_pStrings.Lookup( lpDrawItemStruct->itemData, strText ) == FALSE )
	{
		int nMiddle = rcText.top + 1;
		
		pDC->FillSolidRect( rcText.left, nMiddle, rcText.Width() + 2, 1, CoolInterface.m_crDisabled );
		
		dc.BitBlt( lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top,
			rcItem.Width(), rcItem.Height(), pDC, 0, 0, SRCCOPY );
		dc.Detach();
		
		return;
	}
	
	if ( bSelected )
	{
		if ( ! bDisabled )
		{
			pDC->Draw3dRect( rcItem.left + 1, rcItem.top + 1,
				rcItem.Width() - 2, rcItem.Height() - 1 - bEdge,
				CoolInterface.m_crBorder, CoolInterface.m_crBorder );
			pDC->FillSolidRect( rcItem.left + 2, rcItem.top + 2,
				rcItem.Width() - 4, rcItem.Height() - 3 - bEdge,
				CoolInterface.m_crBackSel );
			
			pDC->SetBkColor( CoolInterface.m_crBackSel );
		}
		else if ( bKeyboard )
		{
			pDC->Draw3dRect( rcItem.left + 1, rcItem.top + 1,
				rcItem.Width() - 2, rcItem.Height() - 1 - bEdge,
				CoolInterface.m_crBorder, CoolInterface.m_crBorder );
			pDC->FillSolidRect( rcItem.left + 2, rcItem.top + 2,
				rcItem.Width() - 4, rcItem.Height() - 3 - bEdge,
				CoolInterface.m_crBackNormal );
			
			pDC->SetBkColor( CoolInterface.m_crBackNormal );
		}
	}
	else
	{
		pDC->SetBkColor( CoolInterface.m_crBackNormal );
	}
	
	if ( bChecked )
	{
		pDC->Draw3dRect( rcItem.left + 2, rcItem.top + 2, 20, rcItem.Height() - 3 - bEdge,
			CoolInterface.m_crBorder, CoolInterface.m_crBorder );
		pDC->FillSolidRect( rcItem.left + 3, rcItem.top + 3, 18, rcItem.Height() - 5 - bEdge,
			( bSelected && !bDisabled ) ? CoolInterface.m_crBackCheckSel : CoolInterface.m_crBackCheck );
	}
	
	nIcon = CoolInterface.ImageForID( (DWORD)lpDrawItemStruct->itemID );
	
	if ( bChecked && nIcon < 0 ) nIcon = m_nCheckIcon;
	
	if ( nIcon >= 0 )
	{
		CPoint pt( rcItem.left + 4, rcItem.top + 4 );
		
		if ( bDisabled )
		{
			ImageList_DrawEx( CoolInterface.m_pImages.m_hImageList, nIcon, pDC->GetSafeHdc(),
				pt.x, pt.y, 0, 0, CLR_NONE, CoolInterface.m_crDisabled, CM_DISABLEDBLEND );
		}
		else if ( bChecked )
		{
			CoolInterface.m_pImages.Draw( pDC, nIcon, pt, ILD_TRANSPARENT );
		}
		else if ( bSelected )
		{
			pt.Offset( 1, 1 );
			pDC->SetTextColor( CoolInterface.m_crShadow );
			CoolInterface.m_pImages.Draw( pDC, nIcon, pt, ILD_MASK );
			pt.Offset( -2, -2 );
			CoolInterface.m_pImages.Draw( pDC, nIcon, pt, ILD_TRANSPARENT );
		}
		else
		{
			ImageList_DrawEx( CoolInterface.m_pImages.m_hImageList, nIcon, pDC->GetSafeHdc(),
				pt.x, pt.y, 0, 0, CLR_NONE, CoolInterface.m_crMargin, ILD_BLEND25 );
		}
	}
	
	CFont* pOld = (CFont*)pDC->SelectObject(
					( lpDrawItemStruct->itemState & ODS_DEFAULT ) && ! bDisabled ?
					&CoolInterface.m_fntBold : &CoolInterface.m_fntNormal );
	
	pDC->SetBkMode( TRANSPARENT );
	pDC->SetTextColor( bDisabled ? CoolInterface.m_crDisabled :
		( bSelected ? CoolInterface.m_crCmdTextSel : CoolInterface.m_crCmdText ) );
	DrawMenuText( pDC, &rcText, strText );
	
	pDC->SelectObject( pOld );
	
	dc.BitBlt( lpDrawItemStruct->rcItem.left, lpDrawItemStruct->rcItem.top,
		rcItem.Width(), rcItem.Height(), pDC, 0, 0, SRCCOPY );
	dc.Detach();
}
Example #29
0
LRESULT CALLBACK CCoolMenu::MenuProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	WNDPROC pWndProc = (WNDPROC)::GetProp( hWnd, wpnOldProc );
	
	switch ( uMsg )
	{
	case WM_NCCALCSIZE:
		{
			NCCALCSIZE_PARAMS* pCalc = (NCCALCSIZE_PARAMS*)lParam;
			pCalc->rgrc[0].left ++;
			pCalc->rgrc[0].top ++;
			pCalc->rgrc[0].right --;
			pCalc->rgrc[0].bottom --;
		}
		return 0;
		
	case WM_WINDOWPOSCHANGING:
		if ( WINDOWPOS* pWndPos = (WINDOWPOS*)lParam )
		{
			DWORD nStyle	= GetWindowLong( hWnd, GWL_STYLE );
			DWORD nExStyle	= GetWindowLong( hWnd, GWL_EXSTYLE );
			CRect rc( 0, 0, 32, 32 );
			
			AdjustWindowRectEx( &rc, nStyle, FALSE, nExStyle );
			
			pWndPos->cx -= ( rc.Width() - 34 );
			pWndPos->cy -= ( rc.Height() - 34 ) - 1;
			
			if ( pWndPos->x != m_nEdgeLeft || pWndPos->y != m_nEdgeTop )
				pWndPos->x ++;
		}
		break;
		
	case WM_PRINT:
		if ( ( lParam & PRF_CHECKVISIBLE ) && ! IsWindowVisible( hWnd ) ) return 0;
		if ( lParam & PRF_NONCLIENT )
		{
			CWnd* pWnd = CWnd::FromHandle( hWnd );
			CDC* pDC = CDC::FromHandle( (HDC)wParam );
			CRect rc;
			
			pWnd->GetWindowRect( &rc );
			BOOL bEdge = ( rc.left == m_nEdgeLeft && rc.top == m_nEdgeTop );
			rc.OffsetRect( -rc.left, -rc.top );
			
			pDC->Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
			if ( bEdge ) pDC->FillSolidRect( rc.left + 1, rc.top, min( rc.Width(), m_nEdgeSize ) - 2, 1, CoolInterface.m_crBackNormal );
		}
		if ( lParam & PRF_CLIENT )
		{
			CWnd* pWnd = CWnd::FromHandle( hWnd );
			CDC* pDC = CDC::FromHandle( (HDC)wParam );
			CBitmap bmBuf, *pbmOld;
			CDC dcBuf;
			CRect rc;
			
			pWnd->GetClientRect( &rc );
			dcBuf.CreateCompatibleDC( pDC );
			bmBuf.CreateCompatibleBitmap( pDC, rc.Width(), rc.Height() );
			pbmOld = (CBitmap*)dcBuf.SelectObject( &bmBuf );
			
			m_bPrinted = TRUE;
			dcBuf.FillSolidRect( &rc, GetSysColor( COLOR_MENU ) );
			SendMessage( hWnd, WM_PRINTCLIENT, (WPARAM)dcBuf.GetSafeHdc(), 0 );
			
			pDC->BitBlt( 1, 1, rc.Width(), rc.Height(), &dcBuf, 0, 0, SRCCOPY );
			dcBuf.SelectObject( pbmOld );
		}
		return 0;
		
	case WM_NCPAINT:
		{
			CWnd* pWnd = CWnd::FromHandle( hWnd );
			CWindowDC dc( pWnd );
			CRect rc;
			
			pWnd->GetWindowRect( &rc );
			BOOL bEdge = ( rc.left == m_nEdgeLeft && rc.top == m_nEdgeTop );
			rc.OffsetRect( -rc.left, -rc.top );
			
			dc.Draw3dRect( &rc, CoolInterface.m_crDisabled, CoolInterface.m_crDisabled );
			if ( bEdge ) dc.FillSolidRect( rc.left + 1, rc.top, min( rc.Width(), m_nEdgeSize ) - 2, 1, CoolInterface.m_crBackNormal );
		}
		return 0;
		
	case WM_PAINT:
		m_bPrinted = FALSE;
		break;
		
	case WM_NCDESTROY:
		::RemoveProp( hWnd, wpnOldProc );
		break;
	}
	
	return CallWindowProc( pWndProc, hWnd, uMsg, wParam, lParam );
}
void CXTPSyntaxEditColorComboBox::DrawItem(LPDRAWITEMSTRUCT lpDIS)
{
	CDC*  pDC       = CDC::FromHandle(lpDIS->hDC);
	UINT  itemState = lpDIS->itemState;
	UINT  itemID    = lpDIS->itemID;
	CRect rcItem    = lpDIS->rcItem;

	if (itemID == (UINT)-1)
	{
		return;
	}

	BOOL bDisabled = ((itemState & ODS_DISABLED) == ODS_DISABLED);
	BOOL bSelected = ((itemState & ODS_SELECTED) == ODS_SELECTED);
	BOOL bFocus    = ((itemState & ODS_FOCUS)    == ODS_FOCUS);

	// draw background.
	if (bDisabled)
	{
		pDC->SetTextColor(GetXtremeColor(COLOR_GRAYTEXT));
		pDC->SetBkColor(GetXtremeColor(COLOR_3DFACE));
		pDC->FillSolidRect(&rcItem, GetXtremeColor(COLOR_3DFACE));
	}
	else
	{
		if (bSelected)
		{
			pDC->SetTextColor(GetXtremeColor(COLOR_HIGHLIGHTTEXT));
			pDC->SetBkColor(GetXtremeColor(COLOR_WINDOW));
			pDC->FillSolidRect(&rcItem, GetXtremeColor(COLOR_HIGHLIGHT));
		}
		else
		{
			pDC->SetTextColor(GetXtremeColor(COLOR_WINDOWTEXT));
			pDC->SetBkColor(GetXtremeColor(COLOR_WINDOW));
			pDC->FillSolidRect(&rcItem, GetXtremeColor(COLOR_WINDOW));
		}

		// draw focus rectangle.
		if (bFocus)
		{
			pDC->DrawFocusRect(&rcItem);
		}
	}

	// determine the size of the color rectangle.
	CRect rColor(rcItem);
	rColor.DeflateRect(2,2);
	rColor.right = rColor.left + COLOR_ITEM_WIDTH;
	rColor.bottom = rColor.top + COLOR_ITEM_WIDTH;

	// draw color rectangle.
	pDC->FillSolidRect(rColor,
		bDisabled? GetXtremeColor(COLOR_3DFACE): (COLORREF)lpDIS->itemData);

	pDC->Draw3dRect(rColor,
		GetXtremeColor(bDisabled? COLOR_GRAYTEXT: COLOR_WINDOWTEXT),
		GetXtremeColor(bDisabled? COLOR_GRAYTEXT: COLOR_WINDOWTEXT));

	// determine the size of the text display.
	CRect rText(rColor);
	rText.top -= 2;
	rText.bottom = rText.top + (::GetSystemMetrics(SM_CYVTHUMB)-::GetSystemMetrics(SM_CYEDGE));
	rText.left = rText.right + 4;
	rText.right = rcItem.right;

	// draw text.
	CString csItemText;
	GetLBText(itemID, csItemText);
	if (!csItemText.IsEmpty())
	{
		pDC->SetBkMode(TRANSPARENT);
		pDC->DrawText(csItemText, rText, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
	}
}