初始化对话框时:
// TODO: Add extra initialization here
SendMessage(WM_DRAWITEM);
return TRUE;  // return TRUE  unless you set the focus to a control
}void CListDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
// TODO: Add your message handler code here and/or call default
CRect rect;
switch(lpDrawItemStruct->CtlID)
{
    case IDOK:
        GetDlgItem(IDOK)->GetClientRect(&rect);
Transfer(&lpDrawItemStruct->hDC,&rect); break;
case IDCANCEL:
        GetDlgItem(IDOK)->GetClientRect(&rect);
Transfer(&lpDrawItemStruct->hDC,&rect); break;
}
CDialog::OnDrawItem(nIDCtl, lpDrawItemStruct);
}void CListDlg::Transfer(HDC *dc, CRect *rect)
{}

解决方案 »

  1.   

    SendMessage这句话写在哪里的?
      

  2.   


    BOOL CListDlg::OnInitDialog()
      

  3.   

    具体看看是那一句代码造成的这个access null ptr
      

  4.   

        switch(lpDrawItemStruct->CtlID)
    这一句吧,为甚麽去不去治呢?
      

  5.   

    void CListDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct) 
    LPDRAWITEMSTRUCT 你有初始化这句吗?错误提示说入口错了,我想应该是这句了建议: problem have to resolved by some changes in settings as given below
            project properties -> general -> Project Defaults->Use of MFC
             To set the properties "Use MFC In A Shared DLL "
      

  6.   

    WM_DRAWITEM消息好像绘制控件的吧?
    好像是每个控件的每次绘制都会有这么一个消息,然后调用相应回调函数,根据参数
    int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct
    来识别控件对象和相应绘制的属性等
    这里没有参数传过去,所以会在switch的时候出错吧?