Advertisement
| 07.28.2008 at 09:10PM PDT, ID: 23602878 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: |
void CMyBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
ASSERT(lpDrawItemStruct->CtlType == ODT_COMBOBOX);
// 1 - Get combobox item ID
UINT id = (UINT) (WORD) lpDrawItemStruct->itemID;
// Consistency checks
ASSERT(id == lpDrawItemStruct->itemID);
// 2 - Get device context & item rectangle
CDC dc;
dc.Attach(lpDrawItemStruct->hDC);
CRect rcItem = lpDrawItemStruct->rcItem;
int nCurrentX = rcItem.left;
// 3 - Select background and foreground
// colors depending on item selected state
COLORREF crBack, crFore;
if(lpDrawItemStruct->itemState & ODS_SELECTED)
{
crBack = ::GetSysColor(COLOR_HIGHLIGHT);
crFore = ::GetSysColor(COLOR_HIGHLIGHTTEXT);
}
else
{
crBack = ::GetSysColor(COLOR_WINDOW);
crFore = ::GetSysColor(COLOR_WINDOWTEXT);
}
// 4 - Fill item background
CRect rcBack(nCurrentX, rcItem.top, rcItem.right, rcItem.bottom);
CBrush brFill(crBack);
dc.FillRect(&rcBack, &brFill);
// 5 - Draw item color rectangle
CBrush brColor(::GetSysColor(COLOR_WINDOWTEXT));
CBrush* pOldBrush = dc.SelectObject(&brColor);
CRect rcColor(nCurrentX, rcItem.top, nCurrentX, rcItem.bottom);
dc.Rectangle(rcColor);
dc.SelectObject(pOldBrush);
// 6 - Draw item text
COLORREF crOldTextColor = dc.SetTextColor(crFore);
int nOldBkMode = dc.SetBkMode(TRANSPARENT);
CString str;
this->GetLBText(id, str);
dc.DrawText(str, -1, rcItem, DT_LEFT|DT_WORDBREAK);
dc.DrawTextEx
dc.SetTextColor(crOldTextColor);
dc.SetBkMode(nOldBkMode);
dc.Detach();
}
void CMyBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
/*DWORD dwStyle = ::GetWindowLong( m_hWnd, GWL_STYLE );*/
/*ASSERT( dwStyle & CBS_DROPDOWNLIST );*/
CFont* pFont = GetFont();
CFont* pOldFont = 0;
CString str;
CDC* pDC = GetDC();
pOldFont = pDC->SelectObject(pFont);
// Get text from combo box
this->GetLBText(lpMeasureItemStruct->itemID, str);
// Obtain rectangle that text is originally in
CRect rc;
GetClientRect(&rc);
//GetWindowRect(&rc);
rc.left = 0;
rc.top = 0;
rc.bottom = 0;
// With the inclusion of DT_CALCRECT
// this DrawText does not draw the text
// it just measures the rectangle
pDC->DrawText(str, str.GetLength(), &rc, DT_CALCRECT|DT_LEFT|DT_WORDBREAK);
lpMeasureItemStruct->itemHeight = rc.bottom;
pDC->SelectObject(pOldFont);
ReleaseDC(pDC);
}
|
Advertisement