win32 sdk绘制ListBox控件
时间:2014-05-01 11:24:03
收藏:0
阅读:512
1》产生:
2》指定size:
- case WM_MEASUREITEM://ODT_LISTBOX
- 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));//yellow
- FillRect(pDI->hDC,&pDI->rcItem,brsh);
- DeleteObject(brsh);
- // text
- 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,
评论(0)