在msdn上查了半天也没找到:(
什么样的情况会触发WM_DRAWITEM消息呀
什么样的情况会触发WM_DRAWITEM消息呀
解决方案 »
- vc++ 2005 有方法把open txt和save txt分開嗎
- 采集卡
- 没有遗忘的都来报道吧
- 关于connect连接不上的延时问题
- 创建一个不会获得焦点的窗口,类似输入法里的软键盘
- 请教 FlashGet 的图表/日志 中那些滚动的点是怎么实现啊?
- 高手在哪!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- 本人在MFC中使用最简单的对话框,用类向导完成申明,定义,但是怎么也显示不出来 DoModal()?
- 想做一个集中式配置的程序
- 我刚刚自学C++,有些问题请指教.
- MFC有没有现成的队列类和链表类?请解答,谢谢!!
- VC71上用SkinMagic1.7b1的问题,Build失败。
This method is called by the framework for the owner of an owner-draw button control, combo-box control, list-box control, or menu when a visual aspect of the control or menu has changed. afx_msg void OnDrawItem(
int nIDCtl,
LPDRAWITEMSTRUCT lpDrawItemStruct ); 也就是说,如果你的ListCtrl如果是具有Owner Draw属性的,就会在窗体就会在这个ListCtrl需要重画的任何时候响应OnDrawItem
在这里边可以处理
ODT_BUTTON Owner-drawn button
ODT_COMBOBOX Owner-drawn combo box
ODT_LISTBOX Owner-drawn list box
ODT_MENU Owner-drawn menu
ODT_LISTVIEW List view control
ODT_STATIC Owner-drawn static control
ODT_TAB Tab control
等类型的具有Owner Draw属性的控件。
然后添加代码:
void CListCtrlOwnerDrawDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
// TODO: Add your message handler code here and/or call default if (lpDrawItemStruct->CtlType == ODT_LISTBOX)
{
HBRUSH hBrush ;
hBrush=CreateSolidBrush(RGB(213,192,228));
hBrush=(HBRUSH) SelectObject (lpDrawItemStruct->hDC,hBrush);
SetBkColor(lpDrawItemStruct->hDC,RGB(213,192,228));
SetTextColor(lpDrawItemStruct->hDC,RGB(0,0,255));
Rectangle(lpDrawItemStruct->hDC,lpDrawItemStruct->rcItem.left,lpDrawItemStruct->rcItem.top,lpDrawItemStruct->rcItem.right,lpDrawItemStruct->rcItem.bottom);
DeleteObject(SelectObject(lpDrawItemStruct->hDC,hBrush));
}}点一下ListCtrl就可以看到结果了,这只是一个简单的示例,具体要你自己实现。
ListCtrl的Item不为空就可以进去了。