• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetKeyState函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GetKeyState函数的典型用法代码示例。如果您正苦于以下问题:C++ GetKeyState函数的具体用法?C++ GetKeyState怎么用?C++ GetKeyState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetKeyState函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Q_Q

void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event)
{
    Q_Q(QDockWidget);

    int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);

    QRect geo = q->geometry();
    QRect titleRect = q->frameGeometry();
#ifdef Q_WS_MAC
    if ((features & QDockWidget::DockWidgetVerticalTitleBar)) {
        titleRect.setTop(geo.top());
        titleRect.setBottom(geo.bottom());
        titleRect.setRight(geo.left() - 1);
    } else
#endif
    {
        titleRect.setLeft(geo.left());
        titleRect.setRight(geo.right());
        titleRect.setBottom(geo.top() - 1);
        titleRect.adjust(0, fw, 0, 0);
    }

    switch (event->type()) {
        case QEvent::NonClientAreaMouseButtonPress:
            if (!titleRect.contains(event->globalPos()))
                break;
            if (state != 0)
                break;
            if (qobject_cast<QMainWindow*>(parent) == 0)
                break;
            if (isAnimating())
                break;
            initDrag(event->pos(), true);
            if (state == 0)
                break;
#ifdef Q_WS_WIN
            // On Windows, NCA mouse events don't contain modifier info
            state->ctrlDrag = GetKeyState(VK_CONTROL) & 0x8000;
#else
            state->ctrlDrag = event->modifiers() & Qt::ControlModifier;
#endif
            startDrag();
            break;
        case QEvent::NonClientAreaMouseMove:
            if (state == 0 || !state->dragging)
                break;

#ifndef Q_OS_MAC
            if (state->nca) {
                endDrag();
            }
#endif
            break;
        case QEvent::NonClientAreaMouseButtonRelease:
#ifdef Q_OS_MAC
                        if (state)
                                endDrag();
#endif
                        break;
        case QEvent::NonClientAreaMouseButtonDblClick:
            _q_toggleTopLevel();
            break;
        default:
            break;
    }
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:66,代码来源:qdockwidget.cpp


示例2: switch


//.........这里部分代码省略.........
			FmtForShow();
		}
		break;
	case VK_HOME:
		m_nCaretPos = 0;
		FmtForShow();
		break;
	case VK_END:
		m_nCaretPos = m_nTextLen;
		FmtForShow();
		break;
	case VK_UP:
		if (MULTI_LINE && m_nCaretLineIndex)
		{
			int nCharPerLine = (m_Width * 2) / m_nFontSize;
			int nLineHead = 0, nLineEnd = 0;
			for (nRet = 0; nRet < m_nCaretLineIndex; nRet++)
			{
				nLineHead = nLineEnd;
				nLineEnd = nLineHead + SplitStringLine(&m_pText[nLineHead], 1, nCharPerLine);
			}

			m_nCaretPos = nLineHead + TSplitString(&m_pText[nLineHead],
				(m_nCaretPos - nLineEnd), false);
			if (m_nCaretPos >= nLineEnd && nLineEnd)
			{
				m_nCaretPos = nLineEnd;
				if(m_pText[nLineEnd - 1] == KTC_ENTER)
					m_nCaretPos--;
			}
			FmtForShow();
		}
		else if (m_pParentWnd)
			nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_UP);
		break;
	case VK_DOWN:
		if (MULTI_LINE)
		{
			int nCharPerLine = (m_Width * 2) / m_nFontSize;
			int nLineHead = 0, nLineEnd = 0;
			for (nRet = 0; nRet <= m_nCaretLineIndex; nRet++)
			{
				nLineHead = nLineEnd;
				nLineEnd = nLineHead + SplitStringLine(&m_pText[nLineHead], 1, nCharPerLine);
			}

			m_nCaretPos = nLineEnd + TSplitString(&m_pText[nLineEnd],
				(m_nCaretPos - nLineHead), false);
			nLineHead = nLineEnd;
			nLineEnd = nLineHead + SplitStringLine(&m_pText[nLineHead], 1, nCharPerLine);
			if (m_nCaretPos >= nLineEnd && nLineEnd)
			{
				m_nCaretPos = nLineEnd;
				if(m_pText[nLineEnd - 1] == KTC_ENTER)
					m_nCaretPos--;
			}
			FmtForShow();
		}
		else if (m_pParentWnd)
			nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_DOWN);
		break;
	case VK_TAB:
	case VK_PRIOR:
	case VK_NEXT:
	case VK_ESCAPE:
		if (m_pParentWnd)
			nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, nKeyCode);
		break;
	case VK_RETURN:
		if (m_pParentWnd)
		{
			if ((m_Flag & WNDEDIT_ES_MULTI_LINE) == 0)
				nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_RETURN);
			else if ((GetKeyState(VK_CONTROL) & 0x8000) == 0 && (GetKeyState(VK_SHIFT) & 0x8000) == 0)
				nRet = m_pParentWnd->WndProc(WND_N_EDIT_SPECIAL_KEY_DOWN, (unsigned int)(KWndWindow*)this, VK_RETURN);
			else if (InsertChar(0x0a, 0))
			{
				UpdateData();
				nRet = 1;
			}
		}
		break;
	case 'V':	//粘帖
		if ((GetKeyState(VK_CONTROL) & 0x8000) && Paste())
			nRet = 1;
		break;
	case 'C':	//复制
		if ((GetKeyState(VK_CONTROL) & 0x8000) && Copy())
			nRet = 1;
		break;
	default:
		if ((nKeyCode < '0' || nKeyCode > '9') &&
			(nKeyCode < 'A' || nKeyCode > 'Z') &&
			(nKeyCode < VK_NUMPAD0 || nKeyCode > VK_DIVIDE))
		{
			nRet = 0;
		}
	}
	return nRet;
}
开发者ID:viticm,项目名称:pap2,代码行数:101,代码来源:WndEdit.cpp


示例3: ConsoleFunc


//.........这里部分代码省略.........
      lpmmi->ptMaxSize=lpmmi->ptMaxTrackSize;
    } /* if */
    break;

  case WM_SYSKEYDOWN:
  case WM_KEYDOWN:
    if ((con=Hwnd2Console(hwnd))!=NULL) {
      TCHAR str[20];
      int i;
      str[0]=__T('\0');
      switch (LOWORD(wParam)) {
      case VK_F1:
      case VK_F2:
      case VK_F3:
      case VK_F4:
      case VK_F5:
      case VK_F6:
      case VK_F7:
      case VK_F8:
      case VK_F9:
      case VK_F10:
      case VK_F11:
      case VK_F12:
        if (LOWORD(wParam)<=VK_F5)
          _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F1+11);
        else if (LOWORD(wParam)==VK_F10)
          _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F6+17);
        else
          _stprintf(str,__T("\033[%d~\n"),LOWORD(wParam)-VK_F11+23);
        break;
      case VK_ADD:
      case VK_SUBTRACT:
        /* check Ctrl key */
        if ((GetKeyState(VK_CONTROL) & 0x8000)!=0) {
          POINT pt;
          int newheight=con->cheight;
          int oldheight=newheight;
          int incr= (LOWORD(wParam)==VK_SUBTRACT) ? -1 : 1;
          do {
            newheight+=incr;
            /* make a new font, re-create a caret and redraw everything */
            SetConsoleFont(con,newheight);
          } while (newheight>5 && (oldheight==con->cheight || con->hfont==NULL));
          if (con->hfont==NULL) /* reset to original on failure */
            SetConsoleFont(con,oldheight);
          GetClientRect(hwnd,&rect);
          DestroyCaret();
          CreateCaret(hwnd,NULL,con->cwidth,2);
          RefreshCaretPos(con);
          /* redraw the window */
          InvalidateRect(hwnd,NULL,TRUE);
          /* resize the window */
          SetRect(&rect,0,0,con->cwidth*con->columns,con->cheight*con->winlines);
          AdjustWindowRect(&rect,GetWindowLong(hwnd,GWL_STYLE),FALSE);
          pt.x=pt.y=0;
          ClientToScreen(hwnd,&pt);
          OffsetRect(&rect,pt.x,pt.y);
          ClampToScreen(&rect);
          SetWindowPos(hwnd,NULL,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,
                       SWP_NOZORDER);
        } /* if */
        break;
      case VK_UP:
        _tcscpy(str,__T("\033[A"));
        break;
      case VK_DOWN:
开发者ID:CmaThomas,项目名称:Vault-Tec-Multiplayer-Mod,代码行数:67,代码来源:termwin.c


示例4: switch

LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
	PAINTSTRUCT ps;

	switch (message)
	{
	case WM_LBUTTONDOWN:
		if (m_pDelegate && m_pTouch && MK_LBUTTON == wParam)
		{
            POINT pt = {(short)LOWORD(lParam), (short)HIWORD(lParam)};
            if (PtInRect(&m_rcViewPort, pt))
            {
                m_bCaptured = true;
                SetCapture(m_hWnd);
                m_pTouch->SetTouchInfo((float)(pt.x - m_rcViewPort.left) / m_fScreenScaleFactor,
                    (float)(pt.y - m_rcViewPort.top) / m_fScreenScaleFactor);
                m_pSet->addObject(m_pTouch);
                m_pDelegate->touchesBegan(m_pSet, NULL);
            }
		}
		break;

	case WM_MOUSEMOVE:
		if (MK_LBUTTON == wParam && m_bCaptured)
		{
            m_pTouch->SetTouchInfo((float)((short)LOWORD(lParam)- m_rcViewPort.left) / m_fScreenScaleFactor,
                (float)((short)HIWORD(lParam) - m_rcViewPort.top) / m_fScreenScaleFactor);
            m_pDelegate->touchesMoved(m_pSet, NULL);
		}
		break;

	case WM_LBUTTONUP:
		if (m_bCaptured)
		{
			m_pTouch->SetTouchInfo((float)((short)LOWORD(lParam)- m_rcViewPort.left) / m_fScreenScaleFactor,
                (float)((short)HIWORD(lParam) - m_rcViewPort.top) / m_fScreenScaleFactor);
			m_pDelegate->touchesEnded(m_pSet, NULL);
			m_pSet->removeObject(m_pTouch);
            ReleaseCapture();
			m_bCaptured = false;
		}
		break;
	case WM_SIZE:
		switch (wParam)
		{
		case SIZE_RESTORED:
			CCApplication::sharedApplication().applicationWillEnterForeground();
			break;
		case SIZE_MINIMIZED:
			CCApplication::sharedApplication().applicationDidEnterBackground();
			break;
		}
		break;
	case WM_KEYDOWN:
		if (wParam == VK_F1 || wParam == VK_F2)
		{
			if (GetKeyState(VK_LSHIFT) < 0 ||  GetKeyState(VK_RSHIFT) < 0 || GetKeyState(VK_SHIFT) < 0)
				CCKeypadDispatcher::sharedDispatcher()->dispatchKeypadMSG(wParam == VK_F1 ? kTypeBackClicked : kTypeMenuClicked);
		}
		if ( m_lpfnAccelerometerKeyHook!=NULL )
		{
			(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
		}
		break;
	case WM_KEYUP:
		if ( m_lpfnAccelerometerKeyHook!=NULL )
		{
			(*m_lpfnAccelerometerKeyHook)( message,wParam,lParam );
		}
		break;
    case WM_CHAR:
        {
            if (wParam < 0x20)
            {
                if (VK_BACK == wParam)
                {
                    CCIMEDispatcher::sharedDispatcher()->dispatchDeleteBackward();
                }
                else if (VK_RETURN == wParam)
                {
                    CCIMEDispatcher::sharedDispatcher()->dispatchInsertText("\n", 1);
                }
                else if (VK_TAB == wParam)
                {
                    // tab input
                }
                else if (VK_ESCAPE == wParam)
                {
                    // ESC input
					CCDirector::sharedDirector()->end();
                }
            }
            else if (wParam < 128)
            {
                // ascii char
                CCIMEDispatcher::sharedDispatcher()->dispatchInsertText((const char *)&wParam, 1);
            }
            else
            {
                char szUtf8[8] = {0};
//.........这里部分代码省略.........
开发者ID:alexzzp,项目名称:cocos2dx-wince,代码行数:101,代码来源:CCEGLView_win32.cpp


示例5: switch

bool Chkdraft::DlgKeyListener(HWND hWnd, UINT &msg, WPARAM wParam, LPARAM lParam)
{
    switch ( msg )
    {
        case WM_KEYDOWN:
            {
                switch ( wParam )
                {
                    case VK_TAB:
                        if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() ||
                             GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() )
                        {
                            msg = WM_NULL; // Dirty fix to prevent tabs from being focused
                            trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.ProcessKeyDown(wParam, lParam);
                            return true;
                        }
                        else if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() ||
                            GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() )
                        {
                            msg = WM_NULL; // Dirty fix to prevent tabs from being focused
                            trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.ProcessKeyDown(wParam, lParam);
                            return true;
                        }
                        break;
                    case VK_RETURN:
                        if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() ||
                             GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.getHandle() )
                        {
                            trigEditorWindow.triggersWindow.trigModifyWindow.conditionsWindow.ProcessKeyDown(wParam, lParam);
                            return true;
                        }
                        else if ( GetParent(GetParent(hWnd)) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() ||
                            GetParent(hWnd) == trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.getHandle() )
                        {
                            trigEditorWindow.triggersWindow.trigModifyWindow.actionsWindow.ProcessKeyDown(wParam, lParam);
                            return true;
                        }
                        if ( GetParent(hWnd) == unitWindow.getHandle() )
                        {
                            unitWindow.DestroyThis();
                            return true;
                        }
                        else if ( GetParent(hWnd) == locationWindow.getHandle() )
                        {
                            locationWindow.DestroyThis();
                            return true;
                        }
                        else if ( GetParent(hWnd) == enterPasswordWindow.getHandle())
                        {
                            enterPasswordWindow.ButtonLogin();
                            return true;
                        }
                        break;
                    case VK_DELETE:
                        if ( GetParent(hWnd) == unitWindow.getHandle() )
                        {
                            SendMessage(unitWindow.getHandle(), WM_COMMAND, MAKEWPARAM(IDC_BUTTON_DELETE, 0), 0);
                            return true;
                        }
                        break;
                    case 'Z': case 'Y': case 'X': case 'C': case 'V':
                        if ( GetKeyState(VK_CONTROL) & 0x8000 )
                        {
                            KeyListener(hWnd, msg, wParam, lParam);
                            return true;
                        }
                        break;
                }
            }
            break;
        case WM_KEYUP:
            if ( wParam == VK_SPACE && CM != nullptr && maps.clipboard.isPasting() )
            {
                UnlockCursor();
                return true;
            }
            break;
    }
    return false;
}
开发者ID:RElesgoe,项目名称:Chkdraft,代码行数:80,代码来源:Chkdraft.cpp


示例6: switch

BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG :
        {
			_fileListView.init(_hInst, _hSelf, _hImaLst);
			_fileListView.initList();
			_fileListView.display();

            return TRUE;
        }

		case WM_NOTIFY:
		{
			switch (((LPNMHDR)lParam)->code)
			{
				case NM_DBLCLK:
				{
					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					int i = lpnmitem->iItem;
					if (i == -1)
					{
						::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0);
					}
					return TRUE;
				}

				case NM_CLICK:
				{
					if ((0x80 & GetKeyState(VK_CONTROL)) || (0x80 & GetKeyState(VK_SHIFT)))
						return TRUE;

					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					int nbItem = ListView_GetItemCount(_fileListView.getHSelf());
					int i = lpnmitem->iItem;
					if (i == -1 || i >= nbItem)
						return TRUE;

					LVITEM item;
					item.mask = LVIF_PARAM;
					item.iItem = i;	
					ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
					TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;

					activateDoc(tlfs);
					return TRUE;
				}

				case NM_RCLICK :
				{
					// Switch to the right document
					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					int nbItem = ListView_GetItemCount(_fileListView.getHSelf());

					if (nbSelectedFiles() == 1)
					{
						int i = lpnmitem->iItem;
						if (i == -1 || i >= nbItem)
 							return TRUE;

						LVITEM item;
						item.mask = LVIF_PARAM;
						item.iItem = i;	
						ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
						TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;

						activateDoc(tlfs);
					}
					// Redirect NM_RCLICK message to Notepad_plus handle
					NMHDR	nmhdr;
					nmhdr.code = NM_RCLICK;
					nmhdr.hwndFrom = _hSelf;
					nmhdr.idFrom = ::GetDlgCtrlID(nmhdr.hwndFrom);
					::SendMessage(_hParent, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
					return TRUE;
				}

				case LVN_GETINFOTIP:
				{
					LPNMLVGETINFOTIP pGetInfoTip = (LPNMLVGETINFOTIP)lParam;
					int i = pGetInfoTip->iItem;
					if (i == -1)
						return TRUE;
					generic_string fn = getFullFilePath((size_t)i);
					lstrcpyn(pGetInfoTip->pszText, fn.c_str(), pGetInfoTip->cchTextMax);
					return TRUE;
				}

				case LVN_COLUMNCLICK:
				{
					LPNMLISTVIEW pnmLV = (LPNMLISTVIEW)lParam;
					setHeaderOrder(pnmLV);
					ListView_SortItemsEx(pnmLV->hdr.hwndFrom, ListViewCompareProc,(LPARAM)pnmLV);
					return TRUE;
				}
				case LVN_KEYDOWN:
				{
					switch (((LPNMLVKEYDOWN)lParam)->wVKey)
					{
//.........这里部分代码省略.........
开发者ID:BrunoReX,项目名称:notepad-plus,代码行数:101,代码来源:VerticalFileSwitcher.cpp


示例7: DescribeKey

void DescribeKey(WPARAM wParam, char *keyw)
{
	char vkc = 0; /* virtual key code */

	vkc = /* maintain alphabet case */
		((GetKeyState(VK_SHIFT) < 0)&&(
		!(GetKeyState(VK_CAPITAL) < 0)))
		? toupper((char)(wParam))
		: tolower((char)(wParam));

	/* numeric pad keys 0 to 10 */
	if((wParam >= VK_NUMPAD0)&&
	   (wParam <= VK_NUMPAD9))
	{
		sprintf(keyw,"[NumPad:%u]",(wParam-0x60));
	}

	/* keys from 0 to 9 , A to Z and space */
	else if(((wParam >= 0x30) 
	       &&(wParam <= 0x5A)) 
	       ||(wParam == 0x20))
	{
		keyw[0] = vkc;
		keyw[1] = 0;
	}

	else switch(wParam)
	{
	case VK_CANCEL:
		strcpy(keyw,"[CTRL-BRK]");
		break;
	case VK_BACK:
		strcpy(keyw,"[BACK]");
		break;
	case VK_TAB:
		strcpy(keyw,"[TAB]");
		break;
	case VK_CLEAR:
		strcpy(keyw,"[CLEAR]");
		break;
	case VK_RETURN:
		strcpy(keyw,"[ENTER]\r\n");
		break;
	case VK_SHIFT:
		strcpy(keyw,"[SHIFT]");
		break;
	case VK_CONTROL:
		strcpy(keyw,"[CTRL]");
		break;
	case VK_MENU:
		strcpy(keyw,"[ALT]");
		break;
	case VK_PAUSE:
		strcpy(keyw,"[PAUSE]");
		break;
	case VK_CAPITAL:
		strcpy(keyw,"[CapsLock]");
		break;
	case VK_ESCAPE:
		strcpy(keyw,"[ESC]");
		break;
	case VK_PRIOR:
		strcpy(keyw,"[PageUp]");
		break;
	case VK_NEXT:
		strcpy(keyw,"[PageDown]");
		break;
	case VK_END:
		strcpy(keyw,"[END]");
		break;
	case VK_HOME:
		strcpy(keyw,"[HOME]");
		break;
	case VK_LEFT:
		strcpy(keyw,"[LEFT]");
		break;
	case VK_UP:
		strcpy(keyw,"[UP]");
		break;
	case VK_RIGHT:
		strcpy(keyw,"[RIGHT]");
		break;
	case VK_DOWN:
		strcpy(keyw,"[DOWN]");
		break;
	case VK_SELECT:
		strcpy(keyw,"[SELECT]");
		break;
	case VK_EXECUTE:
		strcpy(keyw,"[EXECUTE]");
		break;
	case VK_SNAPSHOT:
		strcpy(keyw,"[PrintScreen]");
		break;
	case VK_INSERT:
		strcpy(keyw,"[INSERT]");
		break;
	case VK_DELETE:
		strcpy(keyw,"[DELETE]");
		break;
//.........这里部分代码省略.........
开发者ID:hansongjing,项目名称:Old-Projects,代码行数:101,代码来源:24.cpp


示例8: ContinueExecution

void ContinueExecution()
{
	static BOOL pageflipping    = 0; //?

	const double fUsecPerSec        = 1.e6;
#if 1
	const UINT nExecutionPeriodUsec = 1000;		// 1.0ms
//	const UINT nExecutionPeriodUsec = 100;		// 0.1ms
	const double fExecutionPeriodClks = g_fCurrentCLK6502 * ((double)nExecutionPeriodUsec / fUsecPerSec);
#else
	const double fExecutionPeriodClks = 1800.0;
	const UINT nExecutionPeriodUsec = (UINT) (fUsecPerSec * (fExecutionPeriodClks / g_fCurrentCLK6502));
#endif

	//

	bool bScrollLock_FullSpeed = g_uScrollLockToggle
									? g_bScrollLock_FullSpeed
									: (GetKeyState(VK_SCROLL) < 0);

	g_bFullSpeed = ( (g_dwSpeed == SPEED_MAX) || 
					 bScrollLock_FullSpeed ||
					 (DiskIsSpinning() && enhancedisk && !Spkr_IsActive() && !MB_IsActive()) );

	if(g_bFullSpeed)
	{
		// Don't call Spkr_Mute() - will get speaker clicks
		MB_Mute();
		SysClk_StopTimer();

		g_nCpuCyclesFeedback = 0;	// For the case when this is a big -ve number
	}
	else
	{
		// Don't call Spkr_Demute()
		MB_Demute();
		SysClk_StartTimerUsec(nExecutionPeriodUsec);
	}

	//

	int nCyclesToExecute = (int) fExecutionPeriodClks + g_nCpuCyclesFeedback;
	if(nCyclesToExecute < 0)
		nCyclesToExecute = 0;

	DWORD dwExecutedCycles = CpuExecute(nCyclesToExecute);

	g_dwCyclesThisFrame += dwExecutedCycles;

	//

	cyclenum = dwExecutedCycles;

	DiskUpdatePosition(dwExecutedCycles);
	JoyUpdatePosition();
	VideoUpdateVbl(g_dwCyclesThisFrame);

	SpkrUpdate(cyclenum);
	sg_SSC.CommUpdate(cyclenum);
	PrintUpdate(cyclenum);

	//

	const DWORD CLKS_PER_MS = (DWORD)g_fCurrentCLK6502 / 1000;

	emulmsec_frac += dwExecutedCycles;
	if(emulmsec_frac > CLKS_PER_MS)
	{
		emulmsec += emulmsec_frac / CLKS_PER_MS;
		emulmsec_frac %= CLKS_PER_MS;
	}

	//
	// DETERMINE WHETHER THE SCREEN WAS UPDATED, THE DISK WAS SPINNING,
	// OR THE KEYBOARD I/O PORTS WERE BEING EXCESSIVELY QUERIED THIS CLOCKTICK
	VideoCheckPage(0);
	BOOL screenupdated = VideoHasRefreshed();
	BOOL systemidle    = 0;	//(KeybGetNumQueries() > (clockgran << 2));	//  && (!ranfinegrain);	// TO DO

	if(screenupdated)
		pageflipping = 3;

	//

	if(g_dwCyclesThisFrame >= dwClksPerFrame)
	{
		g_dwCyclesThisFrame -= dwClksPerFrame;

		if(g_nAppMode != MODE_LOGO)
		{
			VideoUpdateFlash();

			static BOOL  anyupdates     = 0;
			static DWORD lastcycles     = 0;
			static BOOL  lastupdates[2] = {0,0};

			anyupdates |= screenupdated;

			//

//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:applewin-svn,代码行数:101,代码来源:Applewin.cpp


示例9: PreTranslateMessage

BOOL CSiteGroupsTree::PreTranslateMessage(MSG *msg)
{
    if (msg->message == WM_KEYDOWN) {
		// When an item is being edited make sure the edit control
		// receives certain important key strokes
		if (GetEditControl() && (msg->wParam == VK_RETURN || msg->wParam == VK_DELETE || msg->wParam == VK_ESCAPE || GetKeyState(VK_CONTROL))) {
			::TranslateMessage(msg);
			::DispatchMessage(msg);
			return TRUE; // Do NOT process further
		}
    }

    return CTreeCtrl::PreTranslateMessage(msg);
}
开发者ID:death,项目名称:webwatch,代码行数:14,代码来源:SiteGroupsTree.cpp


示例10: _window_proc

static LRESULT CALLBACK _window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) {    
  TRACKMOUSEEVENT tme = {0};

  switch ( msg ) {
    case APP_WINDOW_CREATE: {
      RECT rect;
      GetClientRect(hwnd, &rect);
      window.w = rect.right-rect.left;
      window.h = rect.bottom-rect.top;
      window.created = 1;
      pushL_windowevent("create");      
      return 0;
                            }

    case WM_ACTIVATEAPP:
      if ( wparam ) {
        window.activated = 1;
        SetForegroundWindow(hwnd);
        LockSetForegroundWindow( LSFW_LOCK );
        InvalidateRect(hwnd, 0, 0);
        if (window.created) pushL_windowevent("activate");
      }
      else {
        window.activated = 0;
        if (window.created) pushL_windowevent("deactivate");
      }          
      return 0;

    case APP_TICK:  
	  window.timerposted = 0;
      pushL_tick();      
      return 0;

    case WM_DESTROY:      
      PostQuitMessage(0);
      return 0;

    case WM_SHOWWINDOW:
      if (wparam) {
        if (window.created) pushL_windowevent("show");
      } 
      else {
        if (window.created) pushL_windowevent("hide");
      }
      return 0;

    case WM_MOVE:
      if ( !IsIconic( hwnd ) ) {
        window.x = (int)(short)LOWORD( lparam );
        window.y = (int)(short)HIWORD( lparam );
        if (window.created) pushL_windowevent("move");        
      }
      return 0;    

    case WM_SIZE:
      if ( SIZE_MAXIMIZED == wparam || SIZE_RESTORED == wparam ) {
        window.w = LOWORD( lparam );
        window.h = HIWORD( lparam );
        if (window.created) {
          pushL_windowevent("resize");              
          pushL_draw();        
          SwapBuffers(window.hdc);  
        }
      }
      return 0;

    case WM_ERASEBKGND:
      return 1;

    case WM_PAINT:
      if ( GetUpdateRect(hwnd, 0, FALSE) ) {
        ValidateRect(hwnd, 0 );
        pushL_draw();        
        SwapBuffers(window.hdc);  
      }
      return 0;

    case WM_APPCOMMAND:
      switch ( GET_APPCOMMAND_LPARAM( lparam ) ) {
        case APPCOMMAND_COPY: 
          pushL_command("copy");
          break;
        case APPCOMMAND_CUT:   
          pushL_command("cut");
          break;
        case APPCOMMAND_PASTE: 
          pushL_command("paste");
          break;
        default:
          return DefWindowProc(hwnd, msg, wparam, lparam);
      }
      return 1;
    
    case WM_MBUTTONDBLCLK:
      pushL_mousedblclick(GET_X_LPARAM( lparam ), GET_Y_LPARAM( lparam ), "middle", 
        GetKeyState( VK_MENU ) & 0x8000, 
        GetKeyState( VK_CONTROL ) & 0x8000, 
        GetKeyState( VK_SHIFT ) & 0x8000);
      return 0;

//.........这里部分代码省略.........
开发者ID:matthewburk,项目名称:cel-reactor,代码行数:101,代码来源:reactor.c


示例11: Position

void CCamera::CheckForMovement()
{	
	// Once we have the frame interval, we find the current speed
	float speed = (float)(kSpeed * g_FrameInterval);

	// Store the last position and view of the camera
	CVector3 vOldPosition = Position();
	CVector3 vOldView = View();

	// Use a flag to see if we movement backwards or not
	bool bMovedBack = false;


/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// Here is where we subtract the gravity acceleration from our velocity vector.
	// We then add that velocity vector to our camera to effect our camera (or player)
	// This is also how we handle the jump velocity when we hit space bar.
	// Notice that we multiply the gravity by the frame interval (dt).  This makes
	// it so faster video cards don't do a 2 frame jump, while TNT2 cards do 20 frames :)
	// This is necessary to make every computer use the same movement and jump speed.
	g_vVelocity.y -= (float)(kGravity * g_FrameInterval);
	m_vPosition = m_vPosition + g_vVelocity;

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *


	// Check if we hit the Up arrow or the 'w' key
	if(GetKeyState(VK_UP) & 0x80 || GetKeyState('W') & 0x80) {				

		// Move our camera forward by a positive SPEED
		MoveCamera(speed);				
	}

	// Check if we hit the Down arrow or the 's' key
	if(GetKeyState(VK_DOWN) & 0x80 || GetKeyState('S') & 0x80) {			

		// Move our camera backward by a negative SPEED
		MoveCamera(-speed);	
		bMovedBack = true;
	}

	// Check if we hit the Left arrow or the 'a' key
	if(GetKeyState(VK_LEFT) & 0x80 || GetKeyState('A') & 0x80) {			

		// Strafe the camera left
		StrafeCamera(-speed);
	}

	// Check if we hit the Right arrow or the 'd' key
	if(GetKeyState(VK_RIGHT) & 0x80 || GetKeyState('D') & 0x80) {			

		// Strafe the camera right
		StrafeCamera(speed);
	}	

	// Now that we moved, let's get the current position and test our movement
	// vector against the level data to see if there is a collision.
	CVector3 vCurrentPosition = Position();

	// Check for collision with AABB's and grab the new position
	CVector3 vNewPosition = g_Level.TraceBox(vOldPosition, vCurrentPosition,
		                                     CVector3(-20, -50, -20), CVector3(20, 50, 20));

	// Check if we collided and we moved backwards
	if(g_Level.Collided() && bMovedBack)
	{
		// If or x or y didn't move, then we are backed into a wall so restore the view vector
		if(vNewPosition.x == vOldPosition.x || vNewPosition.z == vOldPosition.z)
			m_vView = vOldView;		
	}

	// Set the new position that was returned from our trace function
	m_vPosition = vNewPosition;


/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

	// After we check for collision, we only want to add the velocity vector to
	// our view vector when we are falling.  If we aren't on the ground then
	// we don't want to push the the camera view down to the ground.  It's okay
	// if the position goes down because the collision detection fixes that so
	// we don't go through the ground, however, it's not natural to push the view
	// down too.  Well, assuming is strong enough to push our face down to the ground :)
	if(!g_Level.IsOnGround())
		m_vView = m_vView + g_vVelocity;
	else
	{
		// If we ARE on the ground, we want to get rid of the jump acceleration
		// that we add when the user hits the space bar.  Below we check to see
		// if our velocity is below 0 then we are done with our jump and can just
		// float back to the ground by the gravity.  We do also add our gravity
		// acceleration to the velocity every frame, so this resets this to zero
		// for that as well.
		if(g_vVelocity.y < 0)
			g_vVelocity.y = 0;
	}

/////// * /////////// * /////////// * NEW * /////// * /////////// * /////////// *

//.........这里部分代码省略.........
开发者ID:88er,项目名称:tutorials,代码行数:101,代码来源:Camera.cpp


示例12: PreTranslateMessage

BOOL CTreeFileCtrl::PreTranslateMessage(MSG* pMsg) 
{
  // When an item is being edited make sure the edit control
  // receives certain important key strokes
  if (GetEditControl())
  {
    ::TranslateMessage(pMsg);
    ::DispatchMessage(pMsg);
    return TRUE; // DO NOT process further
  }

  //Context menu via the keyboard
	if ((((pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN) && // If we hit a key and
    	(pMsg->wParam == VK_F10) && (GetKeyState(VK_SHIFT) & ~1)) != 0) ||   // it's Shift+F10 OR
		  (pMsg->message == WM_CONTEXTMENU))						                   	   // Natural keyboard key
	{
		CRect rect;
		GetItemRect(GetSelectedItem(), rect, TRUE);
		ClientToScreen(rect);
		OnContextMenu(NULL, rect.CenterPoint());
		return TRUE;
	}
  //Hitting the Escape key, Cancelling drag & drop
	else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE && IsDragging())
  {
    EndDragging(TRUE);
    return TRUE;
  }
  //Hitting the Alt-Enter key combination, show the properties sheet 
	else if (pMsg->message == WM_SYSKEYDOWN && pMsg->wParam == VK_RETURN)
  {
    OnFileProperties();
    return TRUE;
  }
  //Hitting the Enter key, open the item
	else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
  {
    OnFileOpen();
    return TRUE;
  }
  //Hitting the delete key, delete the item
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE)
  {
    OnFileDelete();
    return TRUE;
  }
  //hitting the backspace key, go to the parent folder
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_BACK)
  {
    UpOneLevel();
    return TRUE;
  }
  //hitting the F2 key, being in-place editing of an item
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F2)
  {
    OnFileRename();
    return TRUE;
  }
  //hitting the F5 key, force a refresh of the whole tree
  else if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_F5)
  {
    OnViewRefresh();
    return TRUE;
  }

  //Let the parent class do its thing
	return CTreeCtrl::PreTranslateMessage(pMsg);
}
开发者ID:5432935,项目名称:genesis3d,代码行数:68,代码来源:FileTreeCtrl.cpp


示例13: KillTimer

void CTreeFileCtrl::EndDragging(BOOL bCancel)
{
  if (IsDragging())
  {
    KillTimer(m_nTimerID);

    CImageList::DragLeave(this);
    CImageList::EndDrag();
    ReleaseCapture();

    delete m_pilDrag;
    m_pilDrag = NULL;

    //Remove drop target highlighting
    SelectDropTarget(NULL);

    m_hItemDrop = GetDropTarget(m_hItemDrop);
    if (m_hItemDrop == NULL)
      return;

    if (!bCancel)
    {
      //Also need to make the change on disk
      CString sFromPath = ItemToPath(m_hItemDrag);
      CString sToPath = ItemToPath(m_hItemDrop);

      int nFromLength = sFromPath.GetLength();
      int nToLength = sToPath.GetLength();
      SHFILEOPSTRUCT shfo;
      ZeroMemory(&shfo, sizeof(SHFILEOPSTRUCT));
      shfo.hwnd = GetSafeHwnd();

      if ((GetKeyState(VK_CONTROL) & 0x8000))
        shfo.wFunc = FO_COPY;
      else
        shfo.wFunc = FO_MOVE;

      shfo.fFlags = FOF_SILENT | FOF_NOCONFIRMMKDIR;
      //Undo is not allowed if the SHIFT key is held down
      if (!(GetKeyState(VK_SHIFT) & 0x8000))
        shfo.fFlags |= FOF_ALLOWUNDO;

      TCHAR* pszFrom = new TCHAR[nFromLength + 2];
      _tcscpy(pszFrom, sFromPath);
      pszFrom[nFromLength+1] = _T('\0');
      shfo.pFrom = pszFrom;

      TCHAR* pszTo = new TCHAR[nToLength + 2];
      _tcscpy(pszTo, sToPath);
      pszTo[nToLength+1] = _T('\0');
      shfo.pTo = pszTo;

      //Let the shell perform the actual deletion
      BOOL bSuccess = ((SHFileOperation(&shfo) == 0) && (shfo.fAnyOperationsAborted == FALSE));

      //Free up the memory we had allocated
      delete [] pszFrom;
      delete [] pszTo;

      if (bSuccess)
      {
        //Only copy the item in the tree if there is not an item with the same
        //text under m_hItemDrop
        CString sText = GetItemText(m_hItemDrag);
        if (!HasChildWithText(m_hItemDrop, sText))
        {
          //Do the actual copy
          BOOL bHadChildren = (GetChildItem(m_hItemDrop) != NULL);
          CopyBranch(m_hItemDrag, m_hItemDrop);

          //Update the children indicator for the folder we just dropped into
          if (!bHadChildren)
          {
            TV_ITEM tvItem;
            tvItem.hItem = m_hItemDrop;
            tvItem.mask = TVIF_CHILDREN;  
            tvItem.cChildren = 1;
            SetItem(&tvItem);
          }
        }

        BOOL bExpanded = (GetChildItem(m_hItemDrop) != NULL); 
        if (shfo.wFunc == FO_MOVE)
        {
          //Get the parent of the item we moved prior to deleting it
          HTREEITEM hParent = GetParentItem(m_hItemDrag);

          //Delete the item we just moved
          DeleteItem(m_hItemDrag);

          //Update the children indicator for the item we just dragged from
          BOOL bHasChildren = (GetChildItem(hParent) != NULL);
          if (hParent && !bHasChildren)
          {
            TV_ITEM tvItem;
            tvItem.hItem = hParent;
            tvItem.mask = TVIF_CHILDREN;  
            tvItem.cChildren = 0;
            SetItem(&tvItem);
          }
//.........这里部分代码省略.........
开发者ID:5432935,项目名称:genesis3d,代码行数:101,代码来源:FileTreeCtrl.cpp


示例14: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
    HDC hDC, hGenDC;
    HBRUSH hBrush;
    BOOL bNeedsMovement;
    const long SROLLUP = 120;
    const long SROLLDOWN = 65416;
    COLORREF crRandom;

    switch(nMsg)
    {
    case WM_CTLCOLORSTATIC:
        hGenDC = (HDC) wParam;
        SetTextColor(hGenDC, RGB(0, 0xFF, 0xFF));
        SetBkColor(hGenDC, crWndColor);
        hBrush = CreateSolidBrush(crWndColor);
        return (INT_PTR)hBrush;

    case WM_CLOSE:
        ReleaseDC(hLblHelp, hGenDC);
        DeleteObject(hBrush);
        KillTimer(hWnd, nIDTmr);
        DestroyWindow(hWnd);
        PostQuitMessage(0);
        return TRUE;

    case WM_SETCURSOR:
        if(wParam == (WPARAM)hLblHelp)
            SetCursor(LoadCursor(NULL, IDC_HAND));
        else
            SetCursor(LoadCursor(NULL, IDC_ARROW));
        return TRUE;

    case WM_COMMAND:
    {
        if((HWND)lParam == hLblHelp)
            DialogBox(NULL, MAKEINTRESOURCE(IDD_DLG), hWnd, DlgProc);
        return TRUE;
    }
    case WM_KEYDOWN:
    {
        bNeedsMovement = FALSE;
        if(wParam == VK_X && (GetKeyState(VK_CONTROL ) & 8000))
        {
            ReleaseDC(hLblHelp, hGenDC);
            DeleteObject(hBrush);
            //KillTimer(hWnd, nIDTmr);
            DestroyWindow(hWnd);
            PostQuitMessage(0);
            return TRUE;
        }
        if(wParam == VK_UP && (GetKeyState(VK_CONTROL ) & 8000))
        {
            POSY = POSY > -1 ? POSY - 1 : POSY;
            bNeedsMovement = TRUE;
        }
        if(wParam == VK_DOWN && (GetKeyState(VK_CONTROL ) & 8000))
        {
            POSY = POSY < 1 ? POSY + 1 : POSY;
            bNeedsMovement = TRUE;
        }
        if(wParam == VK_LEFT && (GetKeyState(VK_CONTROL ) & 8000))
        {
            POSX = POSX > -1 ? POSX - 1 : POSX;
            bNeedsMovement = TRUE;
        }
        if(wParam == VK_RIGHT && (GetKeyState(VK_CONTROL ) & 8000))
        {
            POSX = POSX < 1 ? POSX + 1 : POSX;
            bNeedsMovement = TRUE;
        }
        if(GetKeyState(VK_LCONTROL ) & 8000 && (wParam > 48 && wParam < 58))
        {
            crDigitColor = PRESETS[(long)wParam - 49];
            crColonColor = PRESETS[(long)wParam - 49];
            fnParseTime(hWnd);
        }
        if(GetKeyState(VK_RCONTROL ) & 8000 && (wParam > 48 && wParam < 58))
        {
            crColonColor = PRESETS[(long)wParam - 49];
            fnParseTime(hWnd);
        }

        if(GetKeyState(VK_LCONTROL ) & 8000 && wParam == VK_0)
        {
            crRandom = RGB(fnRandom(255), fnRandom(255), fnRandom(255));
            crDigitColor = crRandom;
            crColonColor = crRandom;
            fnParseTime(hWnd);
        }
        if(GetKeyState(VK_RCONTROL ) & 8000 && wParam == VK_0)
        {
            crColonColor = RGB(fnRandom(255), fnRandom(255), fnRandom(255));
            fnParseTime(hWnd);
        }
        if(GetKeyState(VK_CONTROL ) & 8000 && wParam == VK_H)
        {
            HELP = !HELP;
            if(HELP)
                ShowWindow(hLblHelp, SW_SHOWNORMAL);
//.........这里部分代码省略.........
开发者ID:kineticpsychology,项目名称:windows.win32.apps,代码行数:101,代码来源:clk.c


示例15: key_callback

bool CConsoleInput::key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
	if (key == GLFW_KEY_TAB && action == GLFW_RELEASE)
	{
		gSys->pInput->removeListener(this);
		gSys->Log("=== Console inactive ===");
		text = "";
	}

	if (key == GLFW_KEY_ENTER && action == GLFW_RELEASE)
	{
		const char* str = text.c_str();
		gSys->pConsoleSystem->handleCommand(str);
		gSys->Log(str);
		gSys->Log("=== Console inactive ===");
		gSys->pInput->removeListener(this);
		text = "";
	}	

	if (glfwGetKey(window, GLFW_KEY_CAPS_LOCK) == GLFW_RELEASE) // CAPS functionality
	{
		caps = (GetKeyState(VK_CAPITAL) & 0x0001) != 0; // caps = !caps fails because this gets called when keys are repeated, wierd indeed...
	}
	
	char character = -1;
	if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key >= GLFW_KEY_A && key <= GLFW_KEY_Z) // Letters, capital too
	{
		if ((glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS) != caps) // Shift key capitalizes
		{
			character = key;
		}
		else
		{
			character = key + 32;
		}
	}
	else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key >= GLFW_KEY_0 && key <= GLFW_KEY_9) // Numbers
	{
		character = key;
	}
	else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key == GLFW_KEY_SPACE)
	{
		character = ' ';
	}
	else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key == GLFW_KEY_SLASH) // '-' + shift => '_'
	{
		if (glfwGetKey(window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
		{
			character = '_';
		}
	}
	else if ((action == GLFW_RELEASE || action == GLFW_REPEAT) && key == GLFW_KEY_BACKSPACE) // Deleting text
	{
		text = text.substr(0, text.length() - 1);
	}

	if (character == -1) // Check if accepted key was pressed
		return true;

	text += character;
	
	return true;
}
开发者ID:MergHQ,项目名称:shine,代码行数:63,代码来源:ConsoleInput.cpp


示例16: test_key

static bool test_key(unsigned k)
{
	return (GetKeyState(k) & 0x8000) ? true : false;
}
开发者ID:thenfour,项目名称:WMircP,代码行数:4,代码来源:menu_manager.cpp


示例17: caps

CConsoleInput::CConsoleInput()
	: caps((GetKeyState(VK_CAPITAL) & 0x0001) != 0) // Uses Windows API
{
}
开发者ID:MergHQ,项目名称:shine,代码行数:4,代码来源:ConsoleInput.cpp


示例18: WindowProc


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetKeyboardLayout函数代码示例发布时间:2022-05-30
下一篇:
C++ GetKeyName函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap