zoukankan      html  css  js  c++  java
  • 键盘事件响应

     

    1、创建基于单文档工程:KeyInput

    2、在CKeyInputView中添加成员函数:

    public:

    bool m_bShiftDown;

    CPoint m_ptCharacter;

    3、CKeyInputView()中初始化:

    m_bShiftDown = ture;

    m_ptCharacter.x = 0;

    m_ptCharacter.y = 0;

    4、CKeyInputView()中添加消息响应函数:

    WM_KEYDOWN  、 WM_CHAR  、WM_SETFOCUS

    5、OnKeyDown中:

    if(nChar == VK_SHIFT)

    {

        m_bShiftDown = m_bShiftDown ? false:ture;

    }

    6、OnSetFocus中:

    CreateSolidCaret(3,18);//建立光标

        SetCaretPos(m_ptCharacter);//设定光标位置

        ShowCaret();//显示光标

    7、OnChar中:

    if(m_bShiftDown)

        {

           if(nChar == 13)//回车

           {

               m_ptCharacter.x = 0;

               m_ptCharacter.y += 25;

               SetCaretPos(m_ptCharacter);

               ShowCaret();

           }else{

               CClientDC dc(this);

               HideCaret();

               dc.TextOut(m_ptCharacter.x,m_ptCharacter.y,

    (LPCTSTR)&nChar);

               CSize textsize;

               textsize = dc.GetTextExtent((LPCTSTR)&nChar);

               m_ptCharacter.x += textsize.cx;

               SetCaretPos(m_ptCharacter);

               ShowCaret();

           }

        }

    注:

    GetDlgItem(IDC_INPUT)->SetWindowText(“模拟输入”);

    GetDlgItem(IDC_INPUT)->SetWindowText(“停止输入”);

    SetTimer(1,500,NULL);

    OnTimer(){}

  • 相关阅读:
    pytest学习(2)
    pytest学习(1)
    facets学习(1):什么是facets
    window10下部署flask系统(apache和wsgi)
    python tips:列表推导
    python的一致性(1)sorted和len
    THULAC:一个高效的中文词法分析工具包(z'z)
    EAScript 2016的新增语法(1)
    python的property的用法
    python算法:LinkedList(双向线性链表)的实现
  • 原文地址:https://www.cnblogs.com/lxshanye/p/3088584.html
Copyright © 2011-2022 走看看