如果采用ShowCursor(FALSE)只能隐藏本窗口的鼠标,我需要隐藏系统是鼠标。请问各位高手如何入手。

解决方案 »

  1.   

    或者使用
    ClipCursor(CRect(0,0,0,0));
    ShowCursor(FALSE);//
      

  2.   

    一种比较常见的方法,创建一个线程。在线程中一直响应mouse_event消息,强制将鼠标移到(0,0)点。这种方法实现简单
    但很占CPU。
    实例代码为:
    /**
     * 隐藏鼠标的线程
     */
    DWORD WINAPI HideMouseThread(PVOID param)
    {
    POINT cursorNew;
    while(1){
    GetCursorPos(&cursorNew);
    ::mouse_event(MOUSEEVENTF_MOVE,cursorNew.x,cursorNew.y,0,0);
    }
    }
    一种方法为设置一个全局钩子。在钩子中将鼠标的位置移到(0,0)坐标。这种方法需要写动态链接库,因为全局钩子需要
    放在动态库中,占用的资源较少。实例代码为:
    /**
     * 隐藏鼠标钩子的回调函数
     */
    LRESULT CALLBACK HideMouseHookProc(int nCode ,WPARAM wParam,LPARAM lParam);/**
     * 安装隐藏鼠标钩子
     */
    DLLEXPORT int CALLBACK InstallHideMouseHook()
    {
    theApp.m_hMouseHook = SetWindowsHookEx(WH_MOUSE,HideMouseHookProc,theApp.m_hInstance,0);

    return 1;
    }/**
     * 卸载隐藏鼠标钩子
     */
    DLLEXPORT int CALLBACK UnInstallMouseHideHook()
    {
    if (theApp.m_hMouseHook)
    {
    UnhookWindowsHookEx(theApp.m_hMouseHook);
    } theApp.m_hMouseHook = NULL; return TRUE;
    }
    /**
     * 窗口消息过滤钩子的回调函数
     */
    LRESULT CALLBACK HideMouseHookProc(int nCode ,WPARAM wParam,LPARAM lParam)
    {
    POINT cursorNew; GetCursorPos(&cursorNew);
    ::mouse_event(MOUSEEVENTF_MOVE,cursorNew.x,cursorNew.y,0,0); return CallNextHookEx(theApp.m_hMouseHook,nCode,wParam,lParam);
    }
      

  3.   

    删除系统全部的*.cur之类的文件如何?
      

  4.   

    HCURSOR   hCursor; 
    hCursor   =   AfxGetApp()-> LoadCursor(IDC_MOUSE); 
    SystemParametersInfo(SPI_SETMOUSEVANISH,...)
         
      

  5.   

    绘制个透明的鼠标,使用 setsystemcursor替换系统鼠标,然后启用个钩子,拦截鼠标消息。