1》產生:html
2》指定size:
- case WM_MEASUREITEM:
- if((UINT) wParam==IDC_LISTBOX)
- {
- LPMEASUREITEMSTRUCT lpmis = (LPMEASUREITEMSTRUCT) lParam;
- lpmis->itemWidth=400;
- lpmis->itemHeight=22;
- }
- break;
3》畫:
- case WM_DRAWITEM:
-
- if((UINT) wParam==IDC_LISTBOX)
- {
- LPDRAWITEMSTRUCT pDI=(LPDRAWITEMSTRUCT) lParam;
- HBRUSH brsh=CreateSolidBrush(RGB(255-30*pDI->itemID, 128+40*pDI->itemID, 128+40*pDI->itemID));
- FillRect(pDI->hDC,&pDI->rcItem,brsh);
- DeleteObject(brsh);
-
- SetBkMode(pDI->hDC,TRANSPARENT);
- char szText[260];
- SendMessage(m_hListBox,LB_GETTEXT,pDI->itemID,(LPARAM)szText);
- const DWORD dwStyle = DT_LEFT | DT_SINGLELINE | DT_VCENTER | DT_NOPREFIX | DT_END_ELLIPSIS;
- DrawText(pDI->hDC, szText, strlen(szText), &pDI->rcItem, dwStyle);
- }
- break;
4》要點:| LBS_OWNERDRAWFIXED | LBS_HASSTRINGS,
http://www.cnblogs.com/lidabo/p/3701607.htmlspa