为什么不执行DrawItem?
class CMixerListBox : public CListBox
.
.
.
void CMixerListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
.
.
.
CMixerListBox mixer;
.
.
.
int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rectDummy (0, 0, 200, 200);
mixer.Create(WS_VISIBLE|WS_BORDER,rectDummy, this, 1);
return 0;
}
但为么如此建立的ListBox,却不能执行其中改写的DrawItem函数?而我把放到模式对话框中却能执行?
问题点数:40、回复次数:3Top
1 楼kingcom_xu(冷羽)回复于 2003-01-12 00:58:46 得分 20
LBS_OWNERDRAWFIXED The owner of the list box is responsible for drawing its contents; the items in the list box are the same height.
LBS_OWNERDRAWVARIABLE The owner of the list box is responsible for drawing its contents; the items in the list box are variable in height.Top
2 楼qrlvls( 空 气 )回复于 2003-01-12 15:07:13 得分 0
up,在PreCreateWindow 的时候将风格改成 OwnerDrawTop
3 楼zwvista(球迷程序员)回复于 2003-01-12 15:27:56 得分 20
派生控件子类时,如果要确保控件具有某style,应该将改变style的代码写在PreSubclassWindow虚函数中
virtual void PreSubclassWindow();
void CMixerListBox::PreSubclassWindow()
{
ModifyStyle(0, LBS_OWNERDRAWFIXED);
CListBox::PreSubclassWindow();
}Top




