Beispiel #1
0
void CDComView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    WORD wCh;
    char szInput[2];
    if (m_bBlockUserin == false)
    {
        memset(m_kbState, 0, sizeof(m_kbState));
        GetKeyboardState(m_kbState);
        if ((ToAscii(nChar, MapVirtualKey(nChar, MAPVK_VK_TO_CHAR), m_kbState, &wCh, 0) == 1) &&
                ((myisprint((char)wCh)) || ((char)wCh == VK_ESCAPE) || (GetKeyState(VK_CONTROL) & 0x8000)))
        {
            szInput[0] = (char)wCh;
            szInput[1] = 0;
            AddUserInput(szInput, 1);
        }
        else
        {
            CMainFrame *pMainFrm = (CMainFrame *)AfxGetMainWnd();
            char *pText;
            if (pMainFrm)
            {
                pText = pMainFrm->GetKeyString(nChar,
                                               (GetKeyState(VK_CONTROL) & 0x8000) ? true : false,
                                               (GetKeyState(VK_SHIFT  ) & 0x8000) ? true : false);
                if (pText)
                {
                    AddUserInput(pText, strlen(pText));
                }
            }
        }
    }
    CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Beispiel #2
0
void CScrollBufL1::FindNextToken(char *szText, int nTextLen, ETextType *eTextType, int *nLineLen)
{
    char *pTargetChar;
    bool bPrintable = myisprint(*szText);
    (*eTextType) = bPrintable ? LINEBUF_TEXT : LINEBUF_NON_PRINTABLE;

    pTargetChar = findchartype(szText, nTextLen, !bPrintable);
    if (pTargetChar)
    {
        (*nLineLen) = (int)pTargetChar - (int)szText;
    }
    else
    {
        (*nLineLen) = nTextLen;
    }

    pTargetChar = mystrnstr(szText, (*nLineLen), m_szSearchStr);
    if (pTargetChar)
    {
        (*nLineLen) = (int)pTargetChar - (int)szText;
    }
}