出现这种问题怎样解决呀?
error C2509: 'OnNcHitTest' : member function not declared in 'CRound1Dlg'

解决方案 »

  1.   

    估计是你的OnNcHitTest函数的返回值有问题,一般是返回基类的处理:
    CDialog::OnNcHitTest(...);
      

  2.   

    以下是所有代码,大虾们帮我看看到底应该怎样解决 。 马上散分!// round1Dlg.cpp : implementation file
    //#include "stdafx.h"
    #include "round1.h"
    #include "round1Dlg.h"
    #include <winuser.h>
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
    {
    public:
    CAboutDlg();// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    enum { IDD = IDD_ABOUTBOX };
    //}}AFX_DATA // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected:
    //{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
    {
    //{{AFX_DATA_INIT(CAboutDlg)
    //}}AFX_DATA_INIT
    }void CAboutDlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
    }BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
    // No message handlers
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CRound1Dlg dialogCRound1Dlg::CRound1Dlg(CWnd* pParent /*=NULL*/)
    : CDialog(CRound1Dlg::IDD, pParent)
    {
    //{{AFX_DATA_INIT(CRound1Dlg)
    // NOTE: the ClassWizard will add member initialization here
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    }void CRound1Dlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CRound1Dlg)
    // NOTE: the ClassWizard will add DDX and DDV calls here
    //}}AFX_DATA_MAP
    }BEGIN_MESSAGE_MAP(CRound1Dlg, CDialog)
    //{{AFX_MSG_MAP(CRound1Dlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CRound1Dlg message handlersBOOL CRound1Dlg::OnInitDialog()
    {
    CDialog::OnInitDialog(); CRect rcDialog;
    GetClientRect(&rcDialog);
    CRgn rgn;
    rgn.CreateEllipticRgn(0,0,rcDialog.Width(),rcDialog.Height());
    SetWindowRgn((HRGN)rgn,TRUE);
    return TRUE;
    }
    void CRound1Dlg::OnPaint() 
    {
    if (IsIconic())
    {
    CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
    CPaintDC dc(this);
    dc.SelectStockObject(NULL_PEN);
    CRect rect;
    GetClientRect(rect);
    CBrush brush;
            CBrush *PBrushOld;
    brush.CreateSolidBrush(RGB(0,0,255));
    PBrushOld=dc.SelectObject(&brush);
    dc.Ellipse(rect);
    dc.SelectObject(PBrushOld);
    }
    }// The system calls this to obtain the cursor to display while the user drags
    //  the minimized window.
    HCURSOR CRound1Dlg::OnQueryDragIcon()
    {
    return (HCURSOR) m_hIcon;
    }
    UINT CRound1Dlg::OnNcHitTest(CPoint point)
     
    {
    UNIT nHitTest=CDialog::OnNcHitTest(Point);
    return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
    }
      

  3.   

    UINT CRound1Dlg::OnNcHitTest(CPoint point)
     
    {
    UNIT nHitTest=CDialog::OnNcHitTest(Point);
    return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
    }这个函数的声明在.h文件里有吧!你是怎么加这个函数的,应该用类向导
      

  4.   

    改正楼主几个错误:
    1. protected:
    //{{AFX_MSG(CAboutDlg)
    //}}AFX_MSG
    afx_msg UINT OnNcHitTest( CPoint point );//在这个地方加入消息declare(头文件中)
    DECLARE_MESSAGE_MAP()
    2.BEGIN_MESSAGE_MAP(CRound1Dlg, CDialog)
    //{{AFX_MSG_MAP(CRound1Dlg)
    ON_WM_NCHITTEST()//在这里加入消息映射。
    //}}AFX_MSG_MAP
      END_MESSAGE_MAP()
    3.
    UINT CRound1Dlg::OnNcHitTest(CPoint point)
    {
    /*UNIT nHitTest=CDialog::OnNcHitTest(Point);//这句有误,楼主可加上上面后测试*/
    UINT nHitTest=CDialog::OnNcHitTest(point);//正确的。
    return(nHitTest==HTCLIENT)?HTCAPTION:nHitTest;
    }
      

  5.   

    十分感谢erzichang的细心帮助,我已经把您指正的3处错误改正了,可是错误提示还是没有改变:error C2509: 'OnNcHitTest' : member function not declared in 'CRound1Dlg'
    round1.exe - 1 error(s), 0 warning(s)