void CAVICapVideoView::OnDraw()
{
CAVICapVideoDoc * pDoc = GetDocument();
ASSERT_VALID(pDoc); RECT rect;
GetClientRect(&rect);
DrawDibDraw(m_hdd,
        pDC->GetSafeHdc(),
rect.left,
rect.top,
rect.right,
rect.bottom,
((LPBITMAPINFOHEADER)(CMainFrame*)AfxGetMainWnd()->m_dibinfo.Buffer),
NULL,
0,
0,
-1,
-1,
0);
}
报错
C:\Program Files\Microsoft Visual Studio\MyProjects\AVICapVideo\AVICapVideoView.cpp(112) : error C2511: 'OnDraw' : overloaded member function 'void (void)' not found in 'CAVICapVideoView'
        c:\program files\microsoft visual studio\myprojects\avicapvideo\avicapvideoview.h(18) : see declaration of 'CAVICapVideoView''CAVICapVideoView'定义在AVICapVideoView.h如下:
class CAVICapVideoView : public CView
{protected: // create from serialization only

HDRAWDIB m_hdd;
CAVICapVideoView();
DECLARE_DYNCREATE(CAVICapVideoView)
  
// Attributespublic:
CAVICapVideoDoc* GetDocument();// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAVICapVideoView)
public:
virtual void OnDraw(CDC* pDC);  // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CAVICapVideoView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endifprotected:// Generated message map functions
protected:
//{{AFX_MSG(CAVICapVideoView)
// NOTE - the ClassWizard will add and remove member functions here.
//    DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
麻烦大家了。。

解决方案 »

  1.   

    void CAVICapVideoView::OnDraw()
    改为:
    void CAVICapVideoView::OnDraw(CDC* pDC)
      

  2.   

    你这个OnDraw函数怎么出来的?默认的OnDraw是这样的:
    void CShipSurveyView::OnDraw(CDC* pDC)
    {
    CShipSurveyDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    CECView::OnDraw(pDC);
    // TODO: add draw code for native data here
    DrawAll(pDC);
    }
    带CDC参数
      

  3.   

     cnzdgs兄:按这个改貌似不行,
    void CAVICapVideoView::OnDraw(CDC* pDC)
    {
    CAVICapVideoDoc * pDoc = GetDocument();
    ASSERT_VALID(pDoc); RECT rect;
    GetClientRect(&rect);
    DrawDibDraw(m_hdd,
            pDC->GetSafeHdc(),
    rect.left,
    rect.top,
    rect.right,
    rect.bottom,
    ((LPBITMAPINFOHEADER)(CMainFrame*)AfxGetMainWnd()->m_dibinfo.Buffer), NULL,
    0,
    0,
    -1,
    -1,
    0);
    }
    报错如下C:\Program Files\Microsoft Visual Studio\MyProjects\AVICapVideo\AVICapVideoView.cpp(124) : error C2039: 'm_dibinfo' : is not a member of 'CWnd'
            c:\program files\microsoft visual studio\vc98\mfc\include\afxwin.h(1899) : see declaration of 'CWnd'
    C:\Program Files\Microsoft Visual Studio\MyProjects\AVICapVideo\AVICapVideoView.cpp(124) : error C2228: left of '.Buffer' must have class/struct/union type不会又是括号的问题吧。
      

  4.   

    就是括号的问题,->的优先级大于强制类型转换。
    (LPBITMAPINFOHEADER)((CMainFrame*)AfxGetMainWnd())->m_dibinfo.Buffer
      

  5.   

    ((LPBITMAPINFOHEADER)(CMainFrame*)AfxGetMainWnd()->m_dibinfo.Buffer), 
    晕,不是说过了么,强制转换的优先级没有->的优先级高。
      

  6.   

     happyparrot 兄:我试试看
      

  7.   

    cnzdgs兄:按你说的改成如下形式:void CAVICapVideoView::OnDraw(CDC* pDC)
    {
    CAVICapVideoDoc * pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    RECT rect;
    GetClientRect(&rect);
    DrawDibDraw(m_hdd,
            pDC->GetSafeHdc(),
    rect.left,
    rect.top,
    rect.right,
    rect.bottom,
        (LPBITMAPINFOHEADER)((CMainFrame*)AfxGetMainWnd())->m_dibinfo.buffer,
    NULL,
    0,
    0,
    -1,
    -1,
    0);}报错如下:
    AVICapVideoView.obj : error LNK2001: unresolved external symbol _DrawDibOpen@0
    AVICapVideoView.obj : error LNK2001: unresolved external symbol _DrawDibClose@4
    AVICapVideoView.obj : error LNK2001: unresolved external symbol _DrawDibDraw@52
    MainFrm.obj : error LNK2001: unresolved external symbol "protected: __thiscall CMainFrame::CMainFrame(void)" (??0CMainFrame@@IAE@XZ)
    MainFrm.obj : error LNK2001: unresolved external symbol _capCreateCaptureWindowA@32
    Debug/AVICapVideo.exe : fatal error LNK1120: 5 unresolved externals
    Error executing link.exe.
      

  8.   

    happyparrot 兄:这次一定公平和理,童叟无欺,主要昨天忘给cnzdgs兄结贴了-_-"
      

  9.   

    #pragma comment(lib, "Vfw32.lib")这次我想要10分。
      

  10.   

    void CAVICapVideoView::OnDraw(CDC* pDC)
    {
    CAVICapVideoDoc * pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    RECT rect;
    GetClientRect(&rect);
    DrawDibDraw(m_hdd,
            pDC->GetSafeHdc(),
    rect.left,
    rect.top,
    rect.right,
    rect.bottom,
        (LPBITMAPINFOHEADER)((CMainFrame*)AfxGetMainWnd())->m_dibinfo.Buffer,
    NULL,
    0,
    0,
    -1,
    -1,
    0);}
    报错如下:
    C:\Program Files\Microsoft Visual Studio\MyProjects\AVICapVideo\AVICapVideoView.cpp(125) : error C2039: 'Buffer' : is not a member of 'DIBINFO'
            c:\program files\microsoft visual studio\myprojects\avicapvideo\mainfrm.h(15) : see declaration of 'DIBINFO'
      

  11.   

    cnzdgs兄:是这样么?
    void CAVICapVideoView::OnDraw(CDC* pDC)
    {
    #pragma comment(lib, "Vfw32.lib")
    CAVICapVideoDoc * pDoc = GetDocument();
    ASSERT_VALID(pDoc);
         RECT rect;
    GetClientRect(&rect);
    DrawDibDraw(m_hdd,
            pDC->GetSafeHdc(),
    rect.left,
    rect.top,
    rect.right,
    rect.bottom,
        (LPBITMAPINFOHEADER)((CMainFrame*)AfxGetMainWnd())->m_dibinfo.buffer,
    NULL,
    0,
    0,
    -1,
    -1,
    0);}
    报错如下:
    MainFrm.obj : error LNK2001: unresolved external symbol "protected: __thiscall CMainFrame::CMainFrame(void)" (??0CMainFrame@@IAE@XZ)
    Debug/AVICapVideo.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.
      

  12.   

    #pragma comment最好与#include放在一起。CMainFrame的构造函数怎么会没有,是不是被你删除了?CMainFrame::CMainFrame()
    {
    }
      

  13.   

    cnzdgs兄:多谢多谢,已搞定,这就加分!