zoukankan      html  css  js  c++  java
  • Visual C++ 光标

    2.7 如何获得光标的坐标

    在鼠标相关事件中获取坐标

    void CDemoView::OnMouseMove(UINT nFlags, CPoint point) 
    {
        //保存光标坐标
        m_Point    = point;
    
        //刷新客户区
        Invalidate();
    
        CView::OnMouseMove(nFlags, point);
    }
    

    2.8 如何限制光标的移动范围

    ClipCursor方法

    void CDemoView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
        //获得客户区坐标
        CRect rect;
        GetClientRect(rect);
    
        rect.left = rect.left + rect.Width() / 4;
        rect.right = rect.right - rect.Width() / 4;
        rect.top = rect.top + rect.Height() / 4;
        rect.bottom = rect.bottom - rect.Height() / 4;
    
        //映射屏幕坐标
        ClientToScreen(rect);
    
        //限制光标移动范围
        ClipCursor(&rect);
    
        CView::OnLButtonDown(nFlags, point);
    }
    

    2.9 如何使用预定义光标

    1. LoadStandardCursor同LoadCursor
    2. SetCursor
    3. GetCursor
    void CDemoView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
        //加载光标
         m_hCursor = AfxGetApp()->LoadStandardCursor(IDC_CROSS);
        
        //设置光标
        ::SetCursor(m_hCursor);
    
        CView::OnLButtonDown(nFlags, point);
    }
    
    void CDemoView::OnLButtonUp(UINT nFlags, CPoint point) 
    {
        //加载光标
        m_hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE);
    
        //设置光标
         ::SetCursor(m_hCursor);
    
        CView::OnLButtonUp(nFlags, point);
    }
    
    

    2.10 如何使用自定义光标

    同上,只不过光标属性是自定义的资源,使用LoadCursor方法载入

    image

    void CDemoView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
        //加载光标
         m_hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR2);
    
        //设置光标
        ::SetCursor(m_hCursor);
    
        CView::OnLButtonDown(nFlags, point);
    }
    
    void CDemoView::OnLButtonUp(UINT nFlags, CPoint point) 
    {
        //加载光标
        m_hCursor = AfxGetApp()->LoadCursor(IDC_CURSOR1);
    
        //设置光标
         ::SetCursor(m_hCursor);
    
        CView::OnLButtonUp(nFlags, point);
    }
    

    2.11 如何使用等待光标

    使用BeginWaitCursor和EndWaitCursor方法

    void CDemoView::OnLButtonDown(UINT nFlags, CPoint point) 
    {
        //启动等待光标
        BeginWaitCursor();
    
        //休眠
        Sleep(2000);
    
        //结束等待光标
        EndWaitCursor();
    
        CView::OnLButtonDown(nFlags, point);
    }
    

    参考:

    image

  • 相关阅读:
    大型高并发高负载网站的系统架构(转)
    亿级数据的高并发通用搜索引擎架构设计(转-张宴)
    VMware12版虚拟机怎么安装win7系统(详细教程
    Linux-CentOS7 安装VMware Workstation 12
    IntelliJ IDEA 12创建Maven管理的Java Web项目(图解)
    idea 创建maven工程(入门)
    SQL中inner join、outer join和cross join的区别
    OLTP和OLAP有何区别?
    HAWQ 官方文档创建filespace,tablespace,database,table
    DQL、DML、DDL、DCL的概念与区别
  • 原文地址:https://www.cnblogs.com/Clingingboy/p/2005794.html
Copyright © 2011-2022 走看看