Example #1
0
//创建字体
bool __cdecl CSkinResource::CreateDefaultFont(CFont & Font)
{
	//释放对象
	ASSERT(Font.GetSafeHandle()==NULL);
	if (Font.GetSafeHandle()!=NULL) Font.DeleteObject();

	//创建字体
	Font.CreateFont(-12,0,0,0,400,0,0,0,134,3,2,1,2,TEXT("宋体"));
	ASSERT(Font.GetSafeHandle()!=NULL);

	return (Font.GetSafeHandle()!=NULL);
}
Example #2
0
/*

* Method preamble ************************************************************
*
* CLASS:            TFXDataTip
* NAME:             Initialise
*
* DESCRIPTION:      This method initialise the DataTip class. It creates the
*                   default font used for DataTips, the brush used to paint
*                   windows background, and registers the window class. 
*
*                   If there is currently no hook procedure instaklled for
*                   the class it alos installs a keyboard hook procedure.
*
* PARAMETERS:       none
*
* RETURN TYPE:      void
*
******************************************************************************
*                                  REVISION HISTORY                                                               
*
******************************************************************************
*/
void TFXDataTip::Initialise( )
{
    if (_font.GetSafeHandle( ) == NULL)
    {
        // create the default tip font
        LOGFONT lFont;
        GetObject(GetStockObject(ANSI_FIXED_FONT), sizeof lFont, &lFont);
        _font.CreateFontIndirect(&lFont);

        // create the other GDI objects
        //_brush = new CBrush(::GetSysColor(COLOR_INFOBK));
        _brush = new CBrush( RGB(32,32,32) );
    }

    // register the window class
    RegisterWnd( );

    // install the keyboard hook procedure
    if (_hookProc == NULL)
    {
        _hookProc = ::SetWindowsHookEx(WH_KEYBOARD, 
                                       (HOOKPROC)KeyboardHookCallback,
                                       NULL,
                                       ::GetCurrentThreadId( ));
    }
}
Example #3
0
LRESULT CProgressCtrlX::OnGetFont(WPARAM, LPARAM)
{
	CFont* pFont = CProgress::GetFont();
	if(!pFont)
		return NULL;
	return (LRESULT)pFont->GetSafeHandle();
}
Example #4
0
/////////////////////////////////////////////////////////////////////////////////
//// PreSubclassWindow
void CxStatic::PreSubclassWindow()
{
	//TRACE(_T("in CxStatic::PreSubclassWindow\n"));
	
	m_dwTxtFlags = GetStyle();
	ModifyStyle(SS_TYPEMASK, SS_OWNERDRAW);
	// get current font
	CFont* pFont = GetFont();
	if (!pFont)
	{
		HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		if (hFont == NULL)
			hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
		if (hFont)
			pFont = CFont::FromHandle(hFont);
	}
	ASSERT(pFont);
	ASSERT(pFont->GetSafeHandle());

	// create the font for this control
	LOGFONT lf;
	pFont->GetLogFont(&lf);
	m_font.CreateFontIndirect(&lf);

	this->GetWindowText(m_strText);

	DragAcceptFiles(TRUE);

	Invalidate();
}
Example #5
0
void CQnStatic::PreSubclassWindow() 
{
    // We want to get mouse clicks via STN_CLICKED
    DWORD dwStyle = GetStyle();
    ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
   
	CFont* pFont = GetFont();
	if (!pFont)
	{
		HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		if (hFont == NULL)
			hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
		if (hFont)
			pFont = CFont::FromHandle(hFont);
	}
	ASSERT(pFont->GetSafeHandle());

    // Create the underline font
    LOGFONT lf;
    pFont->GetLogFont(&lf);
	lf.lfHeight = m_nFontSize;
	lf.lfWeight = m_bBold?FW_BOLD:FW_NORMAL;
	m_StdFont.CreateFontIndirect(&lf);
    SetFont(&m_StdFont);

	lf.lfUnderline = (BYTE) TRUE;
    m_UnderlineFont.CreateFontIndirect(&lf);

    SetDefaultCursor();      // Try and load up a "hand" cursor

    CStatic::PreSubclassWindow();
}
Example #6
0
void CPmwStatusBar::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
   CFont* pFont = GetFont();
   CRect rcItem = lpDrawItemStruct->rcItem;

   HDC hDC = lpDrawItemStruct->hDC;

   CString csText;
   GetPaneText(lpDrawItemStruct->itemID, csText);

   int nBitmapIndex = lpDrawItemStruct->itemID-1;
   if (m_Indicators[nBitmapIndex].m_fValid)
   {
      // We have a bitmap to draw.
      CDC dcBitmap;
      if (dcBitmap.CreateCompatibleDC(CDC::FromHandle(hDC)))
      {
         CBitmap* pOldBitmap = dcBitmap.SelectObject(&m_Indicators[nBitmapIndex].m_Bitmap);
         if (pOldBitmap != NULL)
         {
            CRect r;

            CSize Size = m_Indicators[nBitmapIndex].m_Size;
            r.left = rcItem.left + 2;
            r.right = r.left + Size.cx;
            r.top = (lpDrawItemStruct->rcItem.top + lpDrawItemStruct->rcItem.bottom - Size.cy)/2;
            r.bottom = r.top + Size.cy;
            ::BitBlt(hDC,
                     r.left,
                     r.top,
                     r.Width(),
                     r.Height(),
                     dcBitmap.GetSafeHdc(),
                     0,
                     0,
                     SRCCOPY);
            dcBitmap.SelectObject(pOldBitmap);

            rcItem.left = r.right + 2;
         }
         dcBitmap.DeleteDC();
      }
   }

   HFONT hOldFont = (HFONT)::SelectObject(hDC, pFont->GetSafeHandle());
   if (hOldFont != NULL)
   {
      int nOldMode = SetBkMode(hDC, TRANSPARENT);
      ::DrawText(hDC,
                 csText,
                 csText.GetLength(),
                 &rcItem,
                 DT_CENTER | DT_SINGLELINE | DT_VCENTER);
      SetBkMode(hDC, nOldMode);
      ::SelectObject(hDC, hOldFont);
   }
}
Example #7
0
CFont& GraphicsMisc::Marlett()
{
	static CFont font;
				
	if (!font.GetSafeHandle())
		font.Attach(CreateFont(_T("Marlett"), -1, GMFS_SYMBOL));

	return font;
}
Example #8
0
CFont& GraphicsMisc::WingDings()
{
	static CFont font;
				
	if (!font.GetSafeHandle())
		font.Attach(CreateFont(_T("Wingdings"), -1, GMFS_SYMBOL));

	return font;
}
BOOL CXTPSyntaxEditPropertiesPageFont::CreateSafeFontIndirect(CFont& editFont, const LOGFONT& lf)
{
	if (editFont.GetSafeHandle())
		editFont.DeleteObject();

	if (!editFont.CreateFontIndirect(&lf))
		return FALSE;

	return TRUE;
}
Example #10
0
void CQListCtrl::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
	TEXTMETRIC tm;
	HDC hDC = ::GetDC(NULL);
	CFont* pFont = GetFont();
	HFONT hFontOld = (HFONT)SelectObject(hDC, pFont->GetSafeHandle());
	GetTextMetrics(hDC, &tm);
	lpMeasureItemStruct->itemHeight = ((tm.tmHeight + tm.tmExternalLeading) * m_linesPerRow) + ROW_BOTTOM_BORDER;
	SelectObject(hDC, hFontOld);
	::ReleaseDC(NULL, hDC);
}
///////////////////////////////////////////////////////////////////////////////
// PreSubclassWindow
void CXHyperLink::PreSubclassWindow() 
{
	// We want to get mouse clicks via STN_CLICKED
	DWORD dwStyle = GetStyle();
	::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
	
	// Set the URL as the window text
	if (m_strURL.IsEmpty())
		GetWindowText(m_strURL);

	// Check that the window text isn't empty. If it is, set it as the URL.
	CString strWndText;
	GetWindowText(strWndText);
	if (strWndText.IsEmpty()) 
	{
		ASSERT(!m_strURL.IsEmpty());	// Window and URL both NULL. DUH!
		SetWindowText(m_strURL);
	}

	CFont* pFont = GetFont();
	if (!pFont)
	{
		HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		if (hFont == NULL)
			hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
		if (hFont)
			pFont = CFont::FromHandle(hFont);
	}
	ASSERT(pFont->GetSafeHandle());

	// Create the underline font
	LOGFONT lf;
	pFont->GetLogFont(&lf);
	m_StdFont.CreateFontIndirect(&lf);
	lf.lfUnderline = (BYTE) TRUE;
	m_UnderlineFont.CreateFontIndirect(&lf);

	PositionWindow();		// Adjust size of window to fit URL if necessary
	SetDefaultCursor();		// Try and load up a "hand" cursor
	SetUnderline();

	// Create the tooltip
	if (m_bToolTip)
	{
		CRect rect; 
		GetClientRect(rect);
		m_ToolTip.Create(this);
		m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);
	}

	CStatic::PreSubclassWindow();
}
Example #12
0
BOOL CPropertyPageHost::EnsurePageCreated(int nIndex)
{
	if (nIndex < 0 || nIndex >= m_aPages.GetSize())
		return FALSE;

	CPropertyPage* pPage = m_aPages[nIndex].pPage;

	if (!pPage)
		return FALSE;

	if (pPage->GetSafeHwnd() == NULL) // first time only
	{
		if (!pPage->Create(pPage->m_psp.pszTemplate, this))
			return FALSE;

		// make sure we can into/out of the page
		pPage->ModifyStyleEx(0, WS_EX_CONTROLPARENT | DS_CONTROL);

		// make sure the page is a child and modify it if necessary
		pPage->ModifyStyle(WS_POPUPWINDOW | WS_OVERLAPPEDWINDOW, 0);

		if (!(pPage->GetStyle() & WS_CHILD))
		{
			pPage->ModifyStyle(0, WS_CHILD);
			pPage->SetParent(this);
			ASSERT (pPage->GetParent() == this);
		}

		// set font to our parent's font
		CWnd* pOurParent = GetParent();
		ASSERT (pOurParent);

		CFont* pFont = pOurParent->GetFont();

		if (pFont)
			CDialogHelper::SetFont(pPage, (HFONT)pFont->GetSafeHandle(), FALSE);

		// and our parent
		pPage->SetParent(this);

		// snapshot the pages original size
		CRect rOrg;
		pPage->GetClientRect(rOrg);
		m_aPages[nIndex].sizeOrg = rOrg.Size();

		// then fit to the current Host size
		UpdatePageSize(nIndex);
	}

	return (pPage->GetSafeHwnd() != NULL);
}
BOOL CXTPSyntaxEditPropertiesPageFont::GetSafeLogFont(LOGFONT& lf)
{
	if (m_editFont.GetSafeHandle())
	{
		m_editFont.GetLogFont(&lf);
		return TRUE;
	}

	CFont* pFont = GetPaintManager() ? GetPaintManager()->GetFont() : NULL;
	if (pFont && pFont->GetSafeHandle())
	{
		pFont->GetLogFont(&lf);
		return TRUE;
	}

	return FALSE;
}
Example #14
0
void CHyperLink::PreSubclassWindow() 
{
    // Enable notifications - CStatic has this disabled by default
    DWORD dwStyle = GetStyle();
    ::SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle | SS_NOTIFY);
    
    // By default use the label text as the URL
    if (m_strURL.IsEmpty())
        GetWindowText(m_strURL);

    CString strWndText;
    GetWindowText(strWndText);
    if (strWndText.IsEmpty()) 
    {
        SetWindowText(m_strURL);
    }

	CFont* pFont = GetFont();
	if (!pFont)
	{
		HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
		if (hFont == NULL)
			hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
		if (hFont)
			pFont = CFont::FromHandle(hFont);
	}
	ASSERT(pFont->GetSafeHandle());

    LOGFONT lf;
    pFont->GetLogFont(&lf);
	m_StdFont.CreateFontIndirect(&lf);
    lf.lfUnderline = (BYTE) TRUE;
    m_UnderlineFont.CreateFontIndirect(&lf);

    SetDefaultCursor();      // try loading a "hand" cursor
    SetUnderline();

    CRect rect; 
    GetClientRect(rect);
    m_ToolTip.Create(this);
    m_ToolTip.AddTool(this, m_strURL, rect, TOOLTIP_ID);

    CStatic::PreSubclassWindow();
}
///////////////////////////////////////////////////////////////////////////////
// PreSubclassWindow
void CXColorStatic::PreSubclassWindow()
{
    TRACE(_T("in CXColorStatic::PreSubclassWindow\n"));

    // get current font
    CFont* pFont = GetFont();
    if (!pFont)
    {
        HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
        if (hFont == NULL)
            hFont = (HFONT) GetStockObject(ANSI_VAR_FONT);
        if (hFont)
            pFont = CFont::FromHandle(hFont);
    }
    ASSERT(pFont);
    ASSERT(pFont->GetSafeHandle());

    // create the font for this control
    LOGFONT lf;
    pFont->GetLogFont(&lf);
    m_font.CreateFontIndirect(&lf);
}
void CXTPFlowGraphDrawContext::DrawWatermarkBackground(CRect rc)
{

	LOGFONT lf = {0};
	lf.lfHeight = LONG(rc.Width() * 80 / 1000);

	lf.lfWeight = FW_BOLD;
	STRCPY_S(lf.lfFaceName, LF_FACESIZE, _T("Myraid Pro"));

	CFont font;
	font.CreateFontIndirect(&lf);

	HFONT hOldFont = (HFONT)SelectObject(m_hDC, font.GetSafeHandle());


	SetTextColor(RGB(102, 102, 102));

	::SetBkMode(m_hDC, TRANSPARENT);
	::DrawText(m_hDC, _T("Codejock Chart Pro Trial"), -1, rc, DT_VCENTER | DT_CENTER | DT_SINGLELINE);

	SelectObject(m_hDC, hOldFont);

}
int CXTPTabPaintManager::DrawSingleButtonIconAndText(CDC* pDC, CXTPTabManagerItem* pItem, CRect rcItem, BOOL bDraw)
{
	CXTPTabManager* pManager = pItem->GetTabManager();

	XTPTabLayoutStyle layout = pManager->GetLayout();

	BOOL bVertical = !pManager->IsHorizontalPosition();
	if (layout == xtpTabLayoutRotated) bVertical = !bVertical;

	CString strItem = pItem->GetCaption();

	CFont* pFont = m_bBoldSelected && pItem->IsSelected() && pManager->IsActive() ? GetBoldFont(bVertical) : GetFont(bVertical);
	CXTPFontDC fnt(pDC, pFont);


	CSize szIcon(m_szIcon);
	BOOL bDrawIcon = pManager->DrawIcon(pDC, 0, pItem, FALSE, szIcon);
	BOOL bDrawText = layout != xtpTabLayoutCompressed || pItem->IsSelected();

	int nNavigateButtonsLength = 0;
	if (bDrawText && pItem->GetNavigateButtons()->GetSize() > 0)
	{
		nNavigateButtonsLength = 0;
		for (int i = 0; i < (int)pItem->GetNavigateButtons()->GetSize(); i++)
		{
			CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i);
			if (pManager->IsNavigateButtonVisible(pButton))
			{
				CSize sz = pButton->GetSize();
				nNavigateButtonsLength += bVertical ? sz.cy : sz.cx;
			}
		}

		if (nNavigateButtonsLength > 0) nNavigateButtonsLength += 3;
	}


	if (bDraw)
	{
		if (nNavigateButtonsLength > 0)
		{
			m_pColorSet->SetTextColor(pDC, pItem);

			if (bVertical) rcItem.bottom -= 3; else rcItem.right -= 3;

			for (int i = (int)pItem->GetNavigateButtons()->GetSize() - 1; i >= 0; i--)
			{
				CXTPTabManagerNavigateButton* pButton = pItem->GetNavigateButtons()->GetAt(i);
				if (pManager->IsNavigateButtonVisible(pButton))
				{
					CSize szButton = pButton->GetSize();
					if (!bVertical)
					{
						pButton->SetRect(CRect(rcItem.right - szButton.cx,
							rcItem.CenterPoint().y + szButton.cy / 2 - szButton.cy, rcItem.right,
							rcItem.CenterPoint().y + szButton.cy / 2));
						rcItem.right -= szButton.cx;
					}
					else
					{
						pButton->SetRect(CRect(rcItem.CenterPoint().x - szButton.cx / 2,
							rcItem.bottom - szButton.cy, rcItem.CenterPoint().x - szButton.cx / 2 + szButton.cx, rcItem.bottom));
						rcItem.bottom -= szButton.cy;
					}
					pItem->GetNavigateButtons()->GetAt(i)->Draw(pDC);
				}
			}
		}

		m_pColorSet->SetTextColor(pDC, pItem);

		CRect rcFocus(rcItem);

		if (bVertical)
		{
			int nAvailLength = pItem->GetButtonLength() - pItem->GetContentLength();
			if (nAvailLength > 0)
			{
				rcItem.DeflateRect(0, nAvailLength / 2);
			}

			rcItem.top += m_rcButtonTextPadding.left + m_rcButtonMargin.left;
			if (pManager->GetPosition() == xtpTabPositionRight)
				rcItem.DeflateRect(m_rcButtonMargin.bottom, 0, m_rcButtonMargin.top, 0);
			else
				rcItem.DeflateRect(m_rcButtonMargin.top, 0, m_rcButtonMargin.bottom, 0);

			if (bDrawIcon)
			{
				CPoint pt(rcItem.CenterPoint().x - szIcon.cx/2, rcItem.top - 1);
				if (rcItem.Height() > szIcon.cy) pManager->DrawIcon(pDC, pt, pItem, TRUE, szIcon);
				rcItem.top += szIcon.cy + 2;
			}
			if (bDrawText && rcItem.bottom > rcItem.top + 8)
			{
				CSize szText = pDC->GetTextExtent(strItem);
				rcItem.left = rcItem.right - (rcItem.Width() - szText.cy - (pManager->GetPosition() == xtpTabPositionRight ? 1 : 0)) / 2;
				rcItem.right = rcItem.left + rcItem.Height();
				rcItem.bottom -= m_rcButtonMargin.right + max(0, m_rcButtonTextPadding.right - 4);

				if (!m_bDrawTextNoPrefix)
					StripMnemonics(strItem);

				if (m_bDrawTextPathEllipsis)
				{
					DrawTextPathEllipsis(pDC, pManager, strItem, rcItem, DT_SINGLELINE | DT_NOCLIP | DT_NOPREFIX);
				}
				else
				{
					m_pAppearanceSet->DrawText(pDC, pManager, strItem, &rcItem, DT_SINGLELINE | DT_NOCLIP |
						DT_NOPREFIX | (m_bDrawTextEndEllipsis ? DT_END_ELLIPSIS : 0));
				}
			}

		}
		else
		{
			int nAvailLength = pItem->GetButtonLength() - pItem->GetContentLength();
			if (nAvailLength > 0)
			{
				rcItem.DeflateRect(nAvailLength / 2, 0);
			}

			rcItem.left += m_rcButtonTextPadding.left + m_rcButtonMargin.left;

			if (pManager->GetPosition() == xtpTabPositionBottom)
				rcItem.DeflateRect(0, m_rcButtonMargin.bottom, 0, m_rcButtonMargin.top);
			else
				rcItem.DeflateRect(0, m_rcButtonMargin.top, 0, m_rcButtonMargin.bottom);

			if (bDrawIcon)
			{
				CPoint pt(rcItem.left - 1, rcItem.CenterPoint().y - szIcon.cy/2);
				if (rcItem.Width() > szIcon.cx) pManager->DrawIcon(pDC, pt, pItem, TRUE, szIcon);
				rcItem.left += szIcon.cx + 2;
			}

			if (bDrawText && rcItem.right > rcItem.left)
			{
				rcItem.right -= m_rcButtonTextPadding.right + m_rcButtonMargin.right - (bDrawIcon ? 2 : 0);

				if (pItem->GetMarkupUIElement())
				{
					XTPMarkupSetDefaultFont(pItem->GetTabManager()->GetMarkupContext(), (HFONT)pFont->GetSafeHandle(), pDC->GetTextColor());

					CRect rcText(rcItem);

					if (m_nDrawTextFormat & DT_VCENTER)
					{
						CSize szText = XTPMarkupMeasureElement(pItem->GetMarkupUIElement());
						rcText.top = (rcText.top + rcText.bottom - szText.cy) / 2;
						rcText.bottom = rcText.top + szText.cy;
					}

					XTPMarkupRenderElement(pItem->GetMarkupUIElement(), pDC->GetSafeHdc(), rcText);
				}
				else if (m_bDrawTextPathEllipsis)
				{
					DrawTextPathEllipsis(pDC, pManager, strItem, rcItem, DT_SINGLELINE | m_nDrawTextFormat | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0));
				}
				else
				{
					if (m_bDrawTextHidePrefix)
						StripMnemonics(strItem);

					m_pAppearanceSet->DrawText(pDC, pManager, strItem, rcItem, DT_SINGLELINE | m_nDrawTextFormat |
						(m_bDrawTextHidePrefix || m_bDrawTextNoPrefix ? DT_NOPREFIX : 0) | (m_bDrawTextEndEllipsis ? DT_END_ELLIPSIS : 0));
				}
			}
		}

		if (pItem->IsFocused())
		{
			DrawFocusRect(pDC, pItem, rcFocus);
		}
		return 0;
	}
	else
	{
		if (layout == xtpTabLayoutFixed)
		{
			return _GetButtonLength(m_nFixedTabWidth, m_nMinTabWidth, m_nMaxTabWidth);
		}

		if (layout == xtpTabLayoutCompressed)
		{
			if (!bDrawText)
				return _GetButtonLength(8 + (bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth) ;

			CXTPFontDC fntItems(pDC, m_bBoldSelected && pManager->IsActive() ? GetBoldFont(bVertical) : GetFont(bVertical));

			int nLength = 0;

			for (int i = 0; i < pManager->GetItemCount(); i++)
			{
				CRect rcItemText(0, 0, 0, 0);
				m_pAppearanceSet->DrawText(pDC, pManager, pManager->GetItem(i)->GetCaption(), rcItemText, DT_SINGLELINE | DT_CALCRECT | DT_NOCLIP | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0));
				nLength = max(nLength, rcItemText.Width());
			}
			return _GetButtonLength(nNavigateButtonsLength + nLength + m_rcButtonTextPadding.left + m_rcButtonTextPadding.right +
				(!bDrawIcon ? 0: bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth);
		}

		CSize szText(0);
		if (pItem->GetMarkupUIElement())
		{
			XTPMarkupSetDefaultFont(pManager->GetMarkupContext(), (HFONT)pFont->GetSafeHandle(), pDC->GetTextColor());
			szText = XTPMarkupMeasureElement(pItem->GetMarkupUIElement());
		}
		else
		{
			m_pAppearanceSet->DrawText(pDC, pManager, strItem, rcItem, DT_SINGLELINE | DT_CALCRECT | DT_NOCLIP | (m_bDrawTextNoPrefix ? DT_NOPREFIX : 0));
			szText = rcItem.Size();
		}

		return _GetButtonLength(nNavigateButtonsLength + szText.cx + m_rcButtonTextPadding.left + m_rcButtonTextPadding.right +
			(!bDrawIcon ? 0: bVertical ? szIcon.cy : szIcon.cx), m_nMinTabWidth, m_nMaxTabWidth);
	}
}
void CTDLFindResultsListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	*pResult = CDRF_DODEFAULT;
	LPNMLVCUSTOMDRAW pLVCD = (LPNMLVCUSTOMDRAW)pNMHDR;

	int nItem = (int)pLVCD->nmcd.dwItemSpec;
	int nSubItem = (int)pLVCD->iSubItem;

	switch (pLVCD->nmcd.dwDrawStage)
	{
	case CDDS_PREPAINT:
		*pResult = (CDRF_NOTIFYITEMDRAW | CDRF_NOTIFYPOSTPAINT);
		break;

	case CDDS_ITEMPREPAINT:
		{
			const FTDRESULT* pRes = (FTDRESULT*)pLVCD->nmcd.lItemlParam;
			ASSERT(pRes);

			// background
			BOOL bHot = IsResultHot(pLVCD->nmcd.rc);
			BOOL bSelected = IsItemSelected(nItem);
			
			if (bSelected || bHot)
			{
				CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
				BOOL bFocused = (GetFocus() == this);

				CRect rRow(pLVCD->nmcd.rc);
				
				// extra for XP
				if (OsIsXP())
					GetItemRect(nItem, rRow, LVIR_BOUNDS);

				GM_ITEMSTATE nState = ((bFocused && bSelected) ? GMIS_SELECTED : GMIS_SELECTEDNOTFOCUSED);
				GraphicsMisc::DrawExplorerItemBkgnd(pDC, *this, nState, rRow, GMIB_THEMECLASSIC);
			}
			
			// set the font once per item
			CFont* pFont = GetResultFont(pRes, bHot);
			ASSERT(pFont);

			if (pFont)
			{
				::SelectObject(pLVCD->nmcd.hdc, pFont->GetSafeHandle());
				*pResult = CDRF_NEWFONT;
			}

			// hide text because we will draw it in SUBITEMPREPAINT
			pLVCD->clrTextBk = pLVCD->clrText = GetSysColor(COLOR_WINDOW);
		}
		*pResult |= CDRF_NOTIFYSUBITEMDRAW;
		break;
		
	case (CDDS_ITEMPREPAINT | CDDS_SUBITEM):
		{
			const FTDRESULT* pRes = (FTDRESULT*)pLVCD->nmcd.lItemlParam;
			ASSERT(pRes);

			if (pRes)
			{
				CDC* pDC = CDC::FromHandle(pLVCD->nmcd.hdc);
				BOOL bHot = IsResultHot(pLVCD->nmcd.rc);
				BOOL bSelected = IsItemSelected(nItem);

				COLORREF crText = GetResultTextColor(pRes, bSelected, bHot);
				pDC->SetTextColor(crText);

				CRect rRow(pLVCD->nmcd.rc);
				
				// extra for XP
				if (OsIsXP())
					GetSubItemRect(nItem, nSubItem, LVIR_LABEL, rRow);

				pDC->DrawText(GetItemText(nItem, nSubItem), rRow, (DT_SINGLELINE | DT_LEFT | DT_VCENTER | DT_END_ELLIPSIS));

				// references
				if ((nSubItem == 0) && (pLVCD->nmcd.rc.top > 0) && pRes->IsReference())
				{
					ShellIcons::DrawIcon(pDC, ShellIcons::SI_SHORTCUT, CRect(pLVCD->nmcd.rc).TopLeft());
				}
			}

			*pResult = CDRF_SKIPDEFAULT;
		}
		break;

	default:
		break;
	}
}