您的位置:首页 > 其它

为了突破MFC限制,作了两天摸索结果。。以及他的掘墓人Fancy controls

2009-02-18 16:50 369 查看
/*
void CRFAutoTesterView::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your message handler code here and/or call default

ASSERT(lpDrawItemStruct->CtlType == ODT_LISTBOX);
LPCTSTR lpszText = (LPCTSTR) lpDrawItemStruct->itemData;
ASSERT(lpszText != NULL);
CDC dc;

dc.Attach(lpDrawItemStruct->hDC);

// Save these value to restore them when done drawing.
COLORREF crOldTextColor = dc.GetTextColor();
COLORREF crOldBkColor = dc.GetBkColor();

// If this item is selected, set the background color
// and the text color to appropriate values. Also, erase
// rect by filling it with the background color.
if ((lpDrawItemStruct->itemAction | ODA_SELECT) &&
(lpDrawItemStruct->itemState & ODS_SELECTED))
{
//	dc.SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
//	dc.SetBkColor(::GetSysColor(COLOR_HIGHLIGHT));
//dc.FillSolidRect(&lpDrawItemStruct->rcItem,
//	::GetSysColor(COLOR_HIGHLIGHT));

dc.SetTextColor(RGB(138, 43, 29)); //my set
dc.SetBkColor(RGB(255, 255, 0));
dc.FillSolidRect(&lpDrawItemStruct->rcItem,
RGB(255, 255, 0));
}
else
{
dc.FillSolidRect(&lpDrawItemStruct->rcItem, crOldBkColor);
}

// If this item has the focus, draw a red frame around the
// item's rect.
if ((lpDrawItemStruct->itemAction | ODA_FOCUS) &&
(lpDrawItemStruct->itemState & ODS_FOCUS))
{
CBrush br(RGB(255, 255, 0));
dc.FrameRect(&lpDrawItemStruct->rcItem, &br);
}

LOGFONT lf;
dc.GetCurrentFont()->GetLogFont(&lf);
CFont font, *pOldFont;
lstrcpy(lf.lfFaceName,_T("System"));
lf.lfHeight=15; //
lf.lfWidth=0;
lf.lfWeight=1000;
font.CreateFontIndirect(&lf);
pOldFont=dc.SelectObject(&font);

// Draw the text.

dc.SetTextColor(RGB(138,43,226));
UpdateData(TRUE);
if (m_list_box!="")
{
dc.DrawText(lpszText,(int)_tcslen(lpszText),&lpDrawItemStruct->rcItem,DT_LEFT|DT_SINGLELINE|DT_VCENTER);

}

// Reset the background color and the text color back to their
// original values.

dc.SetBkColor(crOldBkColor);

dc.Detach();

}
*//*
void CRFAutoTesterView::OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
// TODO: Add your message handler code here and/or call default
ASSERT(lpMeasureItemStruct->CtlType == ODT_LISTBOX);
LPCTSTR lpszText = (LPCTSTR) lpMeasureItemStruct->itemData;
ASSERT(lpszText != NULL);
CSize   sz;
CDC*    pDC = GetDC();

sz = pDC->GetTextExtent(lpszText);

ReleaseDC(pDC);

lpMeasureItemStruct->itemHeight = 1.5*sz.cy;

//	CFormView::OnMeasureItem(nIDCtl, lpMeasureItemStruct);
}*/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: