Exemplo n.º 1
0
CString HZ2FirstPY(IN std::string szHZ)
{
	std::string str = GetFirstLetter(szHZ.c_str());
	CString cstr = util::stringToCString(str, CP_ACP);

	return cstr;
}
Exemplo n.º 2
0
void bservKeyboardEvent(int code1, WPARAM wParam, LPARAM lParam)
{
    if (getOverlayPage() != _myPage)
        return;

	if (code1 >= 0 && code1==HC_ACTION && lParam & 0x80000000) {
        if (wParam == 0x39) { // 9 - left 
            if (_ball_iter == _balls.begin())
                _ball_iter = _balls.end();
            else
                _ball_iter--;
        }
        else if (wParam == 0x30) { // 0 - right
            if (_ball_iter == _balls.end())
                _ball_iter = _balls.begin();
            else
                _ball_iter++;
        }
        else if (wParam == 0x37) { // 7 - reset to game choice
            _ball_iter = _balls.end();
        }
        else if (wParam == 0x38) { // 8 - random
            LARGE_INTEGER num;
            QueryPerformanceCounter(&num);
            int iterations = num.LowPart % MAX_ITERATIONS;
            ball_iter_t iter = _ball_iter;
            for (int j=0;j<iterations;j++) {
                if (iter == _balls.end()) 
                    iter = _balls.begin();
                else
                    iter++;
                if (iter == _balls.end()) 
                    iter = _balls.begin();
            }
            _ball_iter = iter;
        }
        else if (wParam == 0xbd) { // "-"
            // go to previous letter
            wchar_t currLetter = L'\0';
            ball_iter_t iter = _ball_iter;
            if (iter != _balls.end())
                currLetter = GetFirstLetter(iter);
            do {
                if (iter == _balls.begin())
                    iter = _balls.end();
                else
                    iter--;
                if (iter == _balls.end())
                    break;
            } while (currLetter == GetFirstLetter(iter));
            _ball_iter = iter;
        }
        else if (wParam == 0xbb) { // "="
            // go to next letter
            wchar_t currLetter = L'\0';
            ball_iter_t iter = _ball_iter;
            if (iter != _balls.end())
                currLetter = GetFirstLetter(iter);
            do {
                if (iter == _balls.end())
                    iter = _balls.begin();
                else
                    iter++;
                if (iter == _balls.end())
                    break;
            } while (currLetter == GetFirstLetter(iter));
            _ball_iter = iter;
        }
    }	
}