先将屏幕坐标转换成客户区坐标
ScreenToClient(&point);如果要转换成窗口坐标写个函数就是了
void CMainFrame::ScreenToWindow(LPPOINT lpPoint)
{
   CRect rc;
   GetWindowRect(&rc);
   lpPoint->x -= rc.left;
   lpPoint->y -= rc.top;
}

解决方案 »

  1.   

    个人观点:
    在MainFrame 里面响应鼠标点击??我觉得应该在 View 里面去响应把!
      

  2.   

    但是我这个是用win32 application建立的项目,并不是用mfc,按说我就没有考虑生成CView对象,如果是用mfc生成的sdi或者mdi,那第一个捕获鼠标的是view,可是我这个压根就没有view,难到只要用框架类就得必须有视图类吗?即使是用win32 application生成的也不例外。还请各位高手帮忙看看。拜托!
      

  3.   

    BOOL CMyApp::InitInstance()
    {
    CFrameWnd* p=new CFrameWnd;
    p->Create(0,"yang");
    p->ShowWindow(SW_SHOWDEFAULT);
    p->UpdateWindow();
    //AfxGetApp()->m_pMainWnd=p;
    this->m_pMainWnd=p;
    return TRUE;
    }
    --------------------
    不明白你为什么要这样写,这样的 P还有什么用呢?这个函数退出后,指针就失效了,而且你还造成了内存泄漏
      

  4.   

    而且怎么能够this->m_pMainWnd=p  ??这样写呢??真是强
      

  5.   

    #include<afxwin.h> //MFC code and standard components
    class CMinApp:public CWinApp
    {public: virtual BOOL InitInstance();};
    class CMainWnd:public CFrameWnd
    {protected:
       afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
       afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    public:  DECLARE_MESSAGE_MAP();
    };BEGIN_MESSAGE_MAP(CMainWnd, CFrameWnd)
    ON_WM_LBUTTONDOWN()
    ON_WM_RBUTTONDOWN()
    END_MESSAGE_MAP()void CMainWnd::OnLButtonDown(UINT nFlags, CPoint point)
    {  CString szAboutLeft="This is a minimal WIndows MFC program.\n"
                                "You've pressed the left mouse button!";
    ::MessageBeep(MB_ICONINFORMATION);
    ::MessageBox(GetSafeHwnd(),szAboutLeft,"About",MB_OK|MB_ICONINFORMATION);
    CFrameWnd::OnLButtonDown(nFlags,point);
    }void CMainWnd::OnRButtonDown(UINT nFlags, CPoint point)
    { CString szAboutRight="This is a minimal Windows MFC program.\n"
                              "You've pressed the right mouse button!";
    ::MessageBeep(MB_ICONINFORMATION);
    ::MessageBox(GetSafeHwnd(),szAboutRight,"About",
     MB_OK|MB_ICONINFORMATION);
    CFrameWnd::OnRButtonDown(nFlags,point);
    }BOOL CMinApp::InitInstance()
    {  CFrameWnd* pFrame=new CFrameWnd;
       pFrame->Create(0,_T("Another Minimal MFC Program"));
       pFrame->ShowWindow(SW_SHOWMAXIMIZED);
       pFrame->UpdateWindow();
       AfxGetApp()->m_pMainWnd=pFrame;
       return TRUE;
    }
    CMinApp MyApp;
    ///////////////////////////////////////////////////////////
    请大侠帮忙,用SPY++看时,有消息产生,但没有运行显示相应的对话框?