LRESULT WINAPI MouseProc(int nCode,WPARAM wParam,LPARAM lParam)

解决方案 »

  1.   

    你不能用类的成员呀,除非是静态的,
    CChildView::MouseProc(this,int nCode,WPARAM wParam,LPARAM lParam)
    其实还有一个隐含的参数,this.
    因些会和要的原型不匹配,.
      

  2.   

    改为LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)最好不要声明为类的成员函数。声明成全局的会静态成员函数。
    普通成员函数在类没有实例化前还没有确定的地址。
      

  3.   

    向下面这样声明:
    LRESULT CALLBACK MouseProc(
      int nCode,      // hook code
      WPARAM wParam,  // message identifier
      LPARAM lParam   // mouse coordinates
    );CALLBACK 声明的是回调函数,这种函数由系统通过其函数指针来调用,因此必须是全局或静态函数,不能作为类成员。
    所有的钩子函数都是回调函数。
      

  4.   

    我不活了,还是报错!
    // ChildView.cpp : implementation of the CChildView class
    //#include "stdafx.h"
    #include "mousehook.h"
    #include "ChildView.h"#ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CChildView
    LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)
    {

    //return CallNextHookEx(hHook,nCode,wParam,lParam);
    }
    CChildView::CChildView()
    {
    pView=this;
    hHook=SetWindowsHookEx(WH_MOUSE,MouseProc,0,GetCurrentThreadId());
    }CChildView::~CChildView()
    {
    if(hHook)
    UnhookWindowsHookEx(hHook);
    }
    BEGIN_MESSAGE_MAP(CChildView,CWnd )
    //{{AFX_MSG_MAP(CChildView)
    ON_WM_PAINT()
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    /////////////////////////////////////////////////////////////////////////////
    // CChildView message handlersBOOL CChildView::PreCreateWindow(CREATESTRUCT& cs) 
    {
    if (!CWnd::PreCreateWindow(cs))
    return FALSE; cs.dwExStyle |= WS_EX_CLIENTEDGE;
    cs.style &= ~WS_BORDER;
    cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS, 
    ::LoadCursor(NULL, IDC_ARROW), HBRUSH(COLOR_WINDOW+1), NULL); return TRUE;
    }void CChildView::OnPaint() 
    {
    CPaintDC dc(this); // device context for painting

    // TODO: Add your message handler code here
    char str[256];
    sprintf(str,"x=%d,y=%d",point.x,point.y);
    dc.TextOut(0,0,str);
    // Do not call CWnd::OnPaint() for painting messages
    }
      

  5.   

    : cannot convert parameter 2 from 'long (int,unsigned int,long)' to 'long (__stdcall *)(int,unsigned int,long)'
      

  6.   

    我的网站上有一个keylock的源代码,也许你可以去下载来看一下====================
          VC天堂网
      www.vcheaven.net
    ====================
      

  7.   

    LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam)改为
    LRESULT WINAPI MouseProc(int nCode,WPARAM wParam,LPARAM lParam)