当前位置: 首页>>代码示例>>C++>>正文


C++ GetCursorPos函数代码示例

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


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

示例1: ReleaseCapture

//鼠标消息
VOID CPasswordKeyboard::OnLButtonUp(UINT nFlags, CPoint Point)
{
	__super::OnLButtonUp(nFlags,Point);

	//取消捕获
	if (m_bMouseDown==true)
	{
		//取消捕获
		ReleaseCapture();

		//设置变量
		m_bMouseDown=false;

		//获取光标
		CPoint MousePoint;
		GetCursorPos(&MousePoint);
		ScreenToClient(&MousePoint);

		//更新位置
		WORD wHoverRow=m_wHoverRow;
		WORD wHoverLine=m_wHoverLine;
		SetCurrentStation(MousePoint);

		//点击处理
		if ((m_wHoverRow==wHoverRow)&&(m_wHoverLine==wHoverLine))
		{
			//关闭按钮
			if ((m_wHoverLine==LINE_FUNCTION)&&(m_wHoverRow==ROW_CLOSE_KEY))
			{
				//设置焦点
				CONTAINING_RECORD(this,CPasswordControl,m_PasswordKeyboard)->m_edPassword.SetFocus();

				//销毁窗口
				DestroyWindow();

				return;
			}

			//虚拟编码
			WORD wViraulCode=GetVirualKeyCode(m_wHoverLine,m_wHoverRow);

			//按钮处理
			switch (wViraulCode)
			{
			case VK_SHIFT:		//切换按钮
				{
					//设置变量
					m_bShiftStatus=!m_bShiftStatus;

					break;
				}
			case VK_CAPITAL:	//大写按钮
				{
					//变量定义
					INPUT Input[2];
					ZeroMemory(Input,sizeof(Input));

					//设置变量
					Input[1].ki.dwFlags=KEYEVENTF_KEYUP;   
					Input[0].type=Input[1].type=INPUT_KEYBOARD;
					Input[0].ki.wVk=Input[1].ki.wVk=wViraulCode;

					//模拟输入
					SendInput(CountArray(Input),Input,sizeof(INPUT));

					break;
				}
			default:			//默认按钮
				{
					//设置变量
					m_bShiftStatus=(GetKeyState(VK_SHIFT)&0xF0)>0;

					//发送消息
					CPasswordControl * pPasswordControl=CONTAINING_RECORD(this,CPasswordControl,m_PasswordKeyboard);
					if (pPasswordControl!=NULL) pPasswordControl->m_edPassword.SendMessage(WM_CHAR,wViraulCode,0L);

					break;
				}
			}
		}

		//更新界面
		RedrawWindow(NULL,NULL,RDW_FRAME|RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASENOW);
	}

	return;
}
开发者ID:lonyzone,项目名称:oathx-ogrex-editor,代码行数:88,代码来源:PasswordControl.cpp

示例2: dc

void CBrushPaletteWnd::OnPaint() 
{
  {
  CPaintDC dc(this); // device context for painting
  }
  // skip if already drawing
  extern BOOL _bInTestGame; 
	if( _bInTestGame) return;

  if( m_iTimerID == -1)
  {
    m_iTimerID = (int) SetTimer( 1, 10, NULL);
  }

  POINT ptMouse;
  GetCursorPos( &ptMouse); 
  ScreenToClient( &ptMouse);

  // if there is a valid drawport, and the drawport can be locked
  if( m_pDrawPort != NULL ) {
    m_pDrawPort->SetAsCurrent();

    CWorldEditorView *pWorldEditorView = theApp.GetActiveView();
    ASSERT( pWorldEditorView != NULL);
    // clear background
    m_pDrawPort->Fill( C_lGRAY|CT_OPAQUE);
    // erase z-buffer
    m_pDrawPort->FillZBuffer(ZBUF_BACK);
    // for all brushes
    for( INDEX iBrush=0; iBrush<CT_BRUSHES; iBrush++)
    {
      // get current brush's box in pixels inside window
      PIXaabbox2D boxBrush = GetBrushBBox( iBrush);
      RenderBrushShape( iBrush, boxBrush, m_pDrawPort);

      TIME tm=_pTimer->GetRealTimeTick();
      // if we are drawing selected brush
      if(iBrush==theApp.m_fCurrentTerrainBrush)
      {
        m_pDrawPort->SetAsCurrent();
        FLOAT fFactor=sin(tm*8)/2.0f+0.5f;
        COLOR colSelected=LerpColor(C_lGRAY,C_RED,fFactor);
        m_pDrawPort->DrawBorder(boxBrush.Min()(1)-1, boxBrush.Min()(2)-1, 
                                boxBrush.Max()(1)-boxBrush.Min()(1)+2, boxBrush.Max()(2)-boxBrush.Min()(2)+2,
                                colSelected|CT_OPAQUE);
      }
      PIXaabbox2D boxPoint( PIX2D( ptMouse.x, ptMouse.y), PIX2D(ptMouse.x, ptMouse.y) );
      if( (boxBrush & boxPoint) == boxPoint)
      {
        m_pDrawPort->SetAsCurrent();
        INDEX iRot=((ULONG)(tm*25.0f))&7;
        ULONG ulLineType=0x0f0f0f0f<<iRot;
        m_pDrawPort->DrawBorder(boxBrush.Min()(1)-1, boxBrush.Min()(2)-1, 
                                boxBrush.Max()(1)-boxBrush.Min()(1)+2, boxBrush.Max()(2)-boxBrush.Min()(2)+2,
                                C_BLUE|CT_OPAQUE, ulLineType);
      }
    }

    // if there is a valid viewport
    if (m_pViewPort!=NULL)
    {
      m_pViewPort->SwapBuffers();
    }
  }
}
开发者ID:rdrago,项目名称:LCSource,代码行数:65,代码来源:BrushPaletteWnd.cpp

示例3: switch

void CQListCtrl::OnTimer(UINT_PTR nIDEvent) 
{
	//http://support.microsoft.com/kb/200054
	//OnTimer() Is Not Called Repeatedly for a List Control
	bool callBase = true;

	switch(nIDEvent)
	{
		case TIMER_SHOW_PROPERTIES:
			{
				if( theApp.m_bShowingQuickPaste )
					ShowFullDescription(true);
				KillTimer(TIMER_SHOW_PROPERTIES);

				callBase = false;
			}
			break;

		case TIMER_HIDE_SCROL:
			{
				CPoint cursorPos;
				GetCursorPos(&cursorPos);

				CRect crWindow;
				this->GetWindowRect(&crWindow);

				

				//check and see if they moved out of the scroll area
				//If they did tell our parent so
				if(MouseInScrollBarArea(crWindow, cursorPos) == false)
				{
					StopHideScrollBarTimer();
				}

				callBase = false;
			}
			break;

		case TIMER_SHOW_SCROLL:
			{
				CPoint cursorPos;
				GetCursorPos(&cursorPos);

				CRect crWindow;
				this->GetWindowRect(&crWindow);

				//Adjust for the v-scroll bar being off of the screen
				crWindow.right -= theApp.m_metrics.ScaleX(GetSystemMetrics(SM_CXVSCROLL));
				crWindow.bottom -= theApp.m_metrics.ScaleX(::GetSystemMetrics(SM_CXHSCROLL));

				//Check and see if we are still in the cursor area
				if(MouseInScrollBarArea(crWindow, cursorPos))
				{
					m_timerToHideScrollAreaSet = true;
					GetParent()->SendMessage(NM_SHOW_HIDE_SCROLLBARS, 1, 0);

					//Start looking to hide the scroll bars
					SetTimer(TIMER_HIDE_SCROL, 1000, NULL);
				}

				KillTimer(TIMER_SHOW_SCROLL);

				callBase = false;
			}
			break;
	}
	
	if(callBase)
	{
		CListCtrl::OnTimer(nIDEvent);
	}
}
开发者ID:erdincay,项目名称:ditto-clipboard,代码行数:73,代码来源:QListCtrl.cpp

示例4: IN_MouseMove

/*
===========
IN_MouseMove
===========
*/
void IN_MouseMove (usercmd_t *cmd)
{
	int					mx, my;
	HDC					hdc;
	int					i;
	DIDEVICEOBJECTDATA	od;
	DWORD				dwElements;
	HRESULT				hr;

	if (!mouseactive)
		return;

	if (dinput)
	{
		mx = 0;
		my = 0;

		for (;;)
		{
			dwElements = 1;

			hr = IDirectInputDevice_GetDeviceData(g_pMouse,
					sizeof(DIDEVICEOBJECTDATA), &od, &dwElements, 0);

			if ((hr == DIERR_INPUTLOST) || (hr == DIERR_NOTACQUIRED))
			{
				dinput_acquired = true;
				IDirectInputDevice_Acquire(g_pMouse);
				break;
			}

			/* Unable to read data or no data available */
			if (FAILED(hr) || dwElements == 0)
			{
				break;
			}

			/* Look at the element to see what happened */

			switch (od.dwOfs)
			{
				case DIMOFS_X:
					mx += od.dwData;
					break;

				case DIMOFS_Y:
					my += od.dwData;
					break;

				case DIMOFS_BUTTON0:
					if (od.dwData & 0x80)
						mstate_di |= 1;
					else
						mstate_di &= ~1;
					break;

				case DIMOFS_BUTTON1:
					if (od.dwData & 0x80)
						mstate_di |= (1<<1);
					else
						mstate_di &= ~(1<<1);
					break;
					
				case DIMOFS_BUTTON2:
					if (od.dwData & 0x80)
						mstate_di |= (1<<2);
					else
						mstate_di &= ~(1<<2);
					break;
			}
		}

	// perform button actions
		for (i=0 ; i<mouse_buttons ; i++)
		{
			if ( (mstate_di & (1<<i)) &&
				!(mouse_oldbuttonstate & (1<<i)) )
			{
				Key_Event (K_MOUSE1 + i, true);
			}

			if ( !(mstate_di & (1<<i)) &&
				(mouse_oldbuttonstate & (1<<i)) )
			{
				Key_Event (K_MOUSE1 + i, false);
			}
		}	
			
		mouse_oldbuttonstate = mstate_di;
	}
	else
	{
		GetCursorPos (&current_pos);
		mx = current_pos.x - window_center_x + mx_accum;
		my = current_pos.y - window_center_y + my_accum;
//.........这里部分代码省略.........
开发者ID:CHMyFork,项目名称:Quake-VS2015,代码行数:101,代码来源:in_win.c

示例5: SetCursorPos

void CGUIDialogKeyboardGeneric::MoveCursor(int iAmount)
{
  if (!m_strEditing.IsEmpty())
    return;
  SetCursorPos(GetCursorPos() + iAmount);
}
开发者ID:nremenda,项目名称:xbmc,代码行数:6,代码来源:GUIDialogKeyboardGeneric.cpp

示例6: GetCursorPos

void CToolTipCtrlEx::OnPaint()
{
	POINT Pos;
	GetCursorPos(&Pos);
	CRect PRect;
	WindowFromPoint(Pos)->GetWindowRect(PRect);

	CPaintDC dc(this); // device context for painting
	CRect	Rect,R1;
	CRect	WRect;

	Orientations Orient=NW;
	BOOL	Over=0,Left=0;
	Over=Pos.y	>(PRect.top+(PRect.bottom-PRect.top)/2);
	Left=Pos.x	<(PRect.left+(PRect.right-PRect.left)/2);
	if(Over & Left)Orient=NW;
	else
	if(Over & !Left)Orient=NE;
	else
	if(!Over & Left)Orient=SW;
	else
	if(!Over & !Left)Orient=SE;

	dc.SelectObject(GetFont());

	CString	Tip=_T(""),TStr=_T("");
	GetWindowText(Tip);
	UINT Width=0;
	UINT Rows=1;
	UINT iPos=0;
	Tip.Replace(_T("\r"),_T(""));
	while(iPos<Tip.GetLength())
	{
		if(Tip.GetAt(iPos)=='\n')
		{
			CSize Sz1=dc.GetTextExtent(TStr);
			Width=(Width > Sz1.cx) ? Width : Sz1.cx;
			Rows+=1;
			TStr=_T("");
		}
		else
		{
			TStr+=Tip.GetAt(iPos);
		}
		iPos++;
	}
	if(TStr.GetLength())
	{
		CSize Sz1=dc.GetTextExtent(TStr);
		Width=(Width > Sz1.cx) ? Width : Sz1.cx;
	}
	if(Rows==1)
	{
		CSize Sz1=dc.GetTextExtent(Tip);
		Width=(Width > Sz1.cx) ? Width : Sz1.cx;
	}
	Width+=2;

	GetWindowRect(WRect);
	TEXTMETRIC TM;
	dc.GetTextMetrics(&TM);
	if(Over)
	{
		WRect.bottom=PRect.top;
		WRect.top=WRect.bottom-(Rows*(TM.tmHeight)+4);
	}
	else
	{
		WRect.top=PRect.bottom;
		WRect.bottom=WRect.top+(Rows*(TM.tmHeight)+4);
	}
	UINT T=WRect.Width()-(20+Width);
	WRect.left=Pos.x;
	WRect.right=WRect.left+20+Width;
	if(WRect.right>GetSystemMetrics(SM_CXSCREEN)-25)
	{
		WRect.OffsetRect(-(WRect.right-(GetSystemMetrics(SM_CXSCREEN)-25)),0);
	}
	MoveWindow(&WRect,1);
	ShowWindow(1);

	GetClientRect(Rect);
	dc.FillSolidRect(Rect,m_bkColor);
	R1=Rect;
	R1.right=R1.left+15;
	dc.FillSolidRect(R1,m_leftColor);
	Rect.left=R1.right+1;

	dc.SetBkMode(TRANSPARENT);
	Rect.top+=1;
	UINT iT=(Rect.Width()-Width)/2;
	Rect.left+=iT;
	dc.SetTextColor(m_textColor);
	if(Rows==1)
	{
		dc.DrawText(Tip,Rect,DT_LEFT|DT_VCENTER|DT_SINGLELINE);
	}
	else
	{
		dc.DrawText(Tip,Rect,DT_TOP|DT_LEFT|DT_WORDBREAK);
//.........这里部分代码省略.........
开发者ID:segafan,项目名称:Construct-classic,代码行数:101,代码来源:FlatToolTipCtrl.cpp

示例7: GiveFocusToScreen

void GiveFocusToScreen(unsigned int ScreenIndex, tree_node *FocusNode, bool Mouse, bool UpdateFocus)
{
    screen_info *Screen = GetDisplayFromScreenID(ScreenIndex);
    if(Screen && Screen != KWMScreen.Current)
    {
        KWMScreen.PrevSpace = KWMScreen.Current->ActiveSpace;
        KWMScreen.Current = Screen;

        Screen->ActiveSpace = GetActiveSpaceOfDisplay(Screen);
        ShouldActiveSpaceBeManaged();
        space_info *Space = GetActiveSpaceOfScreen(Screen);

        DEBUG("GiveFocusToScreen() " << ScreenIndex << \
              ": Space transition ended " << KWMScreen.PrevSpace << \
              " -> " << Screen->ActiveSpace);

        if(UpdateFocus)
        {
            if(Space->Initialized && FocusNode)
            {
                DEBUG("Populated Screen 'Window -f Focus'");

                UpdateActiveWindowList(Screen);
                FilterWindowList(Screen);
                SetWindowFocusByNode(FocusNode);
                MoveCursorToCenterOfFocusedWindow();
            }
            else if(Space->Initialized && Space->RootNode)
            {
                DEBUG("Populated Screen Key/Mouse Focus");

                UpdateActiveWindowList(Screen);
                FilterWindowList(Screen);

                bool WindowBelowCursor = IsAnyWindowBelowCursor();
                if(Mouse && !WindowBelowCursor)
                    ClearFocusedWindow();
                else if(Mouse && WindowBelowCursor)
                    FocusWindowBelowCursor();

                if(!Mouse)
                {
                    if(Space->FocusedWindowID == -1)
                    {
                        if(Space->Settings.Mode == SpaceModeBSP)
                        {
                            void *FocusNode = NULL;
                            GetFirstLeafNode(Space->RootNode, (void**)&FocusNode);
                            Space->FocusedWindowID = ((tree_node*)FocusNode)->WindowID;
                        }
                        else if(Space->Settings.Mode == SpaceModeMonocle)
                        {
                            if(Space->RootNode->List)
                                Space->FocusedWindowID = Space->RootNode->List->WindowID;
                        }
                    }

                    FocusWindowByID(Space->FocusedWindowID);
                    MoveCursorToCenterOfFocusedWindow();
                }
            }
            else
            {
                if(!Space->Initialized ||
                   Space->Settings.Mode == SpaceModeFloating ||
                   !Space->RootNode)
                {
                    DEBUG("Uninitialized Screen");
                    ClearFocusedWindow();

                    if(!Mouse)
                        CGWarpMouseCursorPosition(CGPointMake(Screen->X + (Screen->Width / 2), Screen->Y + (Screen->Height / 2)));

                    if(Space->Settings.Mode != SpaceModeFloating && !Space->RootNode)
                    {
                        CGPoint ClickPos = GetCursorPos();
                        CGEventRef ClickEvent = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, ClickPos, kCGMouseButtonLeft);
                        CGEventSetFlags(ClickEvent, 0);
                        CGEventPost(kCGHIDEventTap, ClickEvent);
                        CFRelease(ClickEvent);

                        ClickEvent = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseUp, ClickPos, kCGMouseButtonLeft);
                        CGEventSetFlags(ClickEvent, 0);
                        CGEventPost(kCGHIDEventTap, ClickEvent);
                        CFRelease(ClickEvent);
                    }
                }
            }
        }
    }
}
开发者ID:dylanharrington,项目名称:kwm,代码行数:91,代码来源:display.cpp

示例8: ShowTrayMenu

void ShowTrayMenu() {

	POINT pt;
	GetCursorPos(&pt);

	WCHAR szBuff[MAX_LANGLEN];

	HMENU hmenu = CreatePopupMenu();
	for (int i = 0; i <= (IDM_EXIT - IDM_STTRAYNEXT); i++) {
		LangLoadString(IDS_STTRAYNEXT + i, szBuff, SIZEOF_ARRAY(szBuff));
		AppendMenu(hmenu, MF_STRING, IDM_STTRAYNEXT + i, szBuff);
	}
	InsertMenu(hmenu, IDM_CONFIG, MF_SEPARATOR | MF_BYCOMMAND, 0, NULL);
	InsertMenu(hmenu, IDM_EXIT, MF_SEPARATOR | MF_BYCOMMAND, 0, NULL);

	HMENU hmenuPopup = CreatePopupMenu();
	for (int i = 0; i <= (IDM_ABOUT - IDM_DOCUMENTATION); i++) {
		LangLoadString(IDS_DOCUMENTATION + i, szBuff, SIZEOF_ARRAY(szBuff));
		AppendMenu(hmenuPopup, MF_STRING, IDM_DOCUMENTATION + i, szBuff);
	}
	LangLoadString(IDS_HELP, szBuff, SIZEOF_ARRAY(szBuff));
	InsertMenu(hmenu, IDM_CONFIG, MF_STRING | MF_BYCOMMAND | MF_POPUP, 
		(UINT_PTR)hmenuPopup, szBuff);
	InsertMenu(hmenu, 4, MF_SEPARATOR | MF_BYPOSITION, 0, NULL);

	hmenuPopup = CreatePopupMenu();
	for (int i = 0; i <= (IDM_NEWEXCLUSION - IDM_HIDE); i++) {
		LangLoadString(IDS_HIDE + i, szBuff, SIZEOF_ARRAY(szBuff));
		AppendMenu(hmenuPopup, MF_STRING, IDM_HIDE + i, szBuff);
	}
	InsertMenu(hmenuPopup, IDM_NEWEXCLUSION, MF_SEPARATOR | MF_BYCOMMAND, 0, NULL);
	InsertMenu(hmenuPopup, IDM_REPLACEALTTAB, MF_SEPARATOR | MF_BYCOMMAND, 0, NULL);
	CheckMenuItem(hmenuPopup, IDM_REPLACEALTTAB, !(g_dwFlags & TSF_NOREPLACEALTTAB) 
		? (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED));
	CheckMenuItem(hmenuPopup, IDM_INSTSWITCHER, (g_dwFlags & TSF_INSTSWITCHER) 
		? (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED));
	CheckMenuItem(hmenuPopup, IDM_STICKYALTTAB, (g_dwFlags & TSF_STICKYALTTAB) 
		? (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED));
	CheckMenuItem(hmenuPopup, IDM_HOOKALTTAB, (g_dwFlags & TSF_HOOKALTTAB) 
		? (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED));
//	CheckMenuItem(hmenuPopup, IDM_EXTMOUSE, (g_dwFlags & TSF_EXTMOUSE) 
//		? (MF_BYCOMMAND | MF_CHECKED) : (MF_BYCOMMAND | MF_UNCHECKED));
	LangLoadString(IDS_QUICKCONFIG, szBuff, SIZEOF_ARRAY(szBuff));
	InsertMenu(hmenu, IDM_CONFIG, MF_STRING | MF_BYCOMMAND | MF_POPUP, 
		(UINT_PTR)hmenuPopup, szBuff);

	SetForegroundWindow(g_hwndMain);
	UINT uMenuID = (UINT)TrackPopupMenu(hmenu, 
		TPM_RIGHTBUTTON | TPM_RIGHTALIGN | TPM_NONOTIFY | TPM_RETURNCMD, 
		pt.x, pt.y, 0, g_hwndMain, NULL);
	PostMessage(g_hwndMain, WM_NULL, 0, 0);
	DestroyMenu(hmenu);

	switch (uMenuID) {
		case IDM_STTRAYNEXT:
			ShowTaskSwitchWnd(IDH_STTRAYNEXT);
			break;
		case IDM_STITRAYNEXT:
			ShowTaskSwitchWnd(IDH_STITRAYNEXT);
			break;
		case IDM_CONFIG:
			ConfigTaskSwitchXP();
			break;
		case IDM_HIDE:
			ShowTrayIcon(FALSE);
			break;
		case IDM_REPLACEALTTAB:
			ReplaceAltTab((g_dwFlags & TSF_NOREPLACEALTTAB) 
				? (g_dwFlags & ~TSF_NOREPLACEALTTAB) : (g_dwFlags | TSF_NOREPLACEALTTAB));
			break;
		case IDM_INSTSWITCHER:
			ReplaceAltTab((g_dwFlags & TSF_INSTSWITCHER) 
				? (g_dwFlags & ~TSF_INSTSWITCHER) : (g_dwFlags | TSF_INSTSWITCHER));
			break;
		case IDM_STICKYALTTAB:
			g_dwFlags ^= TSF_STICKYALTTAB;
			break;
		case IDM_HOOKALTTAB:
			ReplaceAltTab((g_dwFlags & TSF_HOOKALTTAB) 
				? (g_dwFlags & ~TSF_HOOKALTTAB) : (g_dwFlags | TSF_HOOKALTTAB));
			break;
//		case IDM_EXTMOUSE:
//			EnableExtMouse(!(g_dwFlags & TSF_EXTMOUSE), g_dwFlags & TSF_WHEELTAB);
//			break;
		case IDM_NEWEXCLUSION:
			ConfigTaskSwitchXP(L"/newexcl");
			break;
		case IDM_DOCUMENTATION:
			HelpTaskSwitchXP();
			break;
		case IDM_HOMEPAGE:
			ShellExecute(NULL, L"open", L"http://www.ntwind.com/taskswitchxp/", NULL, NULL, SW_SHOWNORMAL);
			break;
		case IDM_ABOUT:
			ConfigTaskSwitchXP(L"/about");
			break;
		case IDM_EXIT:
			DestroyWindow(g_hwndMain);
			break;
	}
//.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:winswitch,代码行数:101,代码来源:main.cpp

示例9: main

int main()
{
    srand(time(NULL));

    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Astroides");
    //used for getting the mouse posistion.
    sf::VideoMode desktop = sf::VideoMode::getDesktopMode();
    const int window_height = desktop.height;
    const int window_width = desktop.width;

    window.setFramerateLimit(60);
    sf::Clock clock = sf::Clock();
    sf::Time elapsedTime;

    //BackGround
    sf::Texture backGroundTexture;
    sf::Sprite backGroundSprite;
    backGroundTexture.loadFromFile("Resorces/Img/background.png");
    backGroundSprite.setTexture(backGroundTexture);
    backGroundSprite.setPosition(0, 0);


    //Entities
    Player player = Player();
    EnemyManager eManager;
    ProjectileManager* projectileMgr = ProjectileManager::instance();
    InputManager* inputMgr = InputManager::instance();

    //set up world.
    sf::Vector2f worldBounds = sf::Vector2f(MAP_WIDTH, MAP_HEIGHT);

    int numPacksSwarmers = 10;
    int numSwarmersPerPack = 10;
    int numSwarmerEnemies = numPacksSwarmers * numSwarmersPerPack;
    int numFactories = 20;

    //create some Enemies
    for (int i = 0; i < numPacksSwarmers; i++)
    {
        for (int z = 0; z < numSwarmersPerPack; z++)
        {
            Swarmer * e = new Swarmer((1000 * i), (700 * i)); //Starts all enemy in the center of the screen.
            eManager.addEnemy(e);
        }
    }

    for (int i = 0; i < numFactories; i++)
    {
        Factory * f = new Factory(&eManager);
        eManager.addFactory(f);
    }


    // Start game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event Event;
		
        while (window.pollEvent(Event))
		{
            if (Event.type == Event.KeyPressed && Event.key.code == sf::Keyboard::Escape)
            {
                window.close();
            }
            switch (Event.type)
            {				
                // Close window : exit
                case sf::Event::Closed:
                    window.close();
                    break;
                default:
                    break;
            }//end switch
        }//end while
		InputManager::instance()->UpdatePressedKeys(Event);
	
        player.Update(worldBounds);
        projectileMgr->Update(window);

        //Get the mouse posistion and send it to the swarm method.
        POINT mousePos;
        if (GetCursorPos(&mousePos))
        {
            if (ScreenToClient(window.getSystemHandle(), &mousePos))
            {
                //std::cout << "mouse pos : (" << mousePos.x << ", " << mousePos.y << ")" << std::endl;
                eManager.swarmEAI(player.GetPos());
            }
        }
        //eManager.flocking();
        eManager.CheckCollisions();
        eManager.UpdateFactories(&player);
        eManager.UpdatePredators(player.GetPos());
        eManager.CollisionSwarm(&player);
        eManager.CollisionPred(&player);

        //prepare frame
        window.clear();
//.........这里部分代码省略.........
开发者ID:DaveMold,项目名称:AI,代码行数:101,代码来源:BasicMovement.cpp

示例10: DefWindowProc

// Called from the Windows notification handler thread, in its message loop
LRESULT CALLBACK
DesktopIndicatorHandler::WndProc
(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
    // Check for our special notification message
    if ((uMessage != WM_DESKTOPINDICATOR_CLICK)) {
        return DefWindowProc(hWnd, uMessage, wParam, lParam);
    }
    DesktopIndicatorHandler *pthis = (DesktopIndicatorHandler *)
        GetWindowLong(hWnd, GWL_USERDATA);
    switch (lParam) {
    case WM_LBUTTONDBLCLK:
        // Execute the default action of the right-click popup menu
        pthis->restoreApplication();
        break;
    //case WM_LBUTTONDOWN:
    //case WM_RBUTTONDOWN:
    //case WM_LBUTTONUP:
        //break;
    case WM_RBUTTONUP: // Display popup menu on right click
        {
            SetForegroundWindow(hWnd);
            POINT pos;
            GetCursorPos(&pos);
            int cxMenuCheck = GetSystemMetrics(SM_CXMENUCHECK);
            int cyMenuCheck = GetSystemMetrics(SM_CYMENUCHECK);
            HMENU hMenu = CreatePopupMenu();
            UAppendMenu(hMenu, MF_STRING, MNU_RESTORE,
                pthis->m_lpwszItemRestore);     // L"Restore";
            UAppendMenu(hMenu, MF_STRING, MNU_ABOUT,
                pthis->m_lpwszItemAbout);       // L"About...";
            UAppendMenu(hMenu, MF_SEPARATOR, 0, (LPCWSTR)NULL);
            UAppendMenu(hMenu, MF_STRING, MNU_EXIT_AFTER,
                pthis->m_lpwszItemExitLater);   // L"Exit After Transfers";
            UAppendMenu(hMenu, MF_STRING, MNU_EXIT,
                pthis->m_lpwszItemExit);        // L"Exit";
            //Load 15x15 bitmaps for unchecked state of menu options
            //Remap colors  #000000, #808080, #C0C0C0, #DFDFDF, #FFFFFF
            //to 3D colors: DlgText, 3DDark, 3DFace, 3DLight, WindowBg
            HBITMAP hbmpRestore = (HBITMAP)LoadImageA(
                ::g_hInstance, MAKEINTRESOURCEA(IDB_RESTORE),
                IMAGE_BITMAP, cxMenuCheck, cyMenuCheck,
                LR_LOADMAP3DCOLORS);
            HBITMAP hbmpHelp = (HBITMAP)LoadImageA(
                ::g_hInstance, MAKEINTRESOURCEA(IDB_HELP),
                IMAGE_BITMAP, cxMenuCheck, cyMenuCheck,
                LR_LOADMAP3DCOLORS);
            HBITMAP hbmpWaitClose = (HBITMAP)LoadImageA(
                ::g_hInstance, MAKEINTRESOURCEA(IDB_WAITCLOSE),
                IMAGE_BITMAP, cxMenuCheck, cyMenuCheck,
                LR_LOADMAP3DCOLORS);
            HBITMAP hbmpClose = (HBITMAP)LoadImageA(
                ::g_hInstance, MAKEINTRESOURCEA(IDB_CLOSE),
                IMAGE_BITMAP, cxMenuCheck, cyMenuCheck,
                LR_LOADMAP3DCOLORS);
            SetMenuItemBitmaps(hMenu, MNU_RESTORE, MF_BYCOMMAND,
                hbmpRestore, (HBITMAP)NULL);
            SetMenuItemBitmaps(hMenu, MNU_ABOUT, MF_BYCOMMAND,
                hbmpHelp, (HBITMAP)NULL);
            SetMenuItemBitmaps(hMenu, MNU_EXIT_AFTER, MF_BYCOMMAND,
                hbmpWaitClose, (HBITMAP)NULL);
            SetMenuItemBitmaps(hMenu, MNU_EXIT, MF_BYCOMMAND,
                hbmpClose, (HBITMAP)NULL);
            SetMenuDefaultItem(hMenu, MNU_RESTORE, MF_BYCOMMAND);
            switch (TrackPopupMenu(hMenu,
                TPM_CENTERALIGN | TPM_BOTTOMALIGN |
                TPM_LEFTBUTTON |
                TPM_NONOTIFY | TPM_RETURNCMD, /* return an item.wID instead of BOOL */
                pos.x, pos.y,
                0, hWnd, (LPCRECT)NULL)) {
            case MNU_RESTORE:
                pthis->restoreApplication();
                break;
            case MNU_ABOUT:
                pthis->showAboutWindow();
                break;
            case MNU_EXIT_AFTER:
                pthis->exitAfterTransfers();
                break;
            case MNU_EXIT:
                pthis->exitApplication();
                break;
            }
            DestroyMenu(hMenu);
            DeleteObject((HGDIOBJ)hbmpRestore);
            DeleteObject((HGDIOBJ)hbmpClose);
        }
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    }
    return 0;
}
开发者ID:BackupTheBerlios,项目名称:limewire,代码行数:95,代码来源:DesktopIndicatorHandler.cpp

示例11: ProcessPageShowContextMenu

void ProcessPageShowContextMenu(DWORD dwProcessId)
{
    HMENU        hMenu;
    HMENU        hSubMenu;
    HMENU        hPriorityMenu;
    POINT        pt;
    SYSTEM_INFO  si;
    HANDLE       hProcess;
    DWORD        dwProcessPriorityClass;
    WCHAR        strDebugger[260];
    DWORD        dwDebuggerSize;
    HKEY         hKey;

    memset(&si, 0, sizeof(SYSTEM_INFO));

    GetCursorPos(&pt);
    GetSystemInfo(&si);

    hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(IDR_PROCESS_PAGE_CONTEXT));
    hSubMenu = GetSubMenu(hMenu, 0);
    hPriorityMenu = GetSubMenu(hSubMenu, 4);

    hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwProcessId);
    dwProcessPriorityClass = GetPriorityClass(hProcess);
    CloseHandle(hProcess);

    if (si.dwNumberOfProcessors < 2)
        RemoveMenu(hSubMenu, ID_PROCESS_PAGE_SETAFFINITY, MF_BYCOMMAND);

    if (!DebugChannelsAreSupported())
        RemoveMenu(hSubMenu, ID_PROCESS_PAGE_DEBUGCHANNELS, MF_BYCOMMAND);

    switch (dwProcessPriorityClass)    {
    case REALTIME_PRIORITY_CLASS:
        CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, MF_BYCOMMAND);
        break;
    case HIGH_PRIORITY_CLASS:
        CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_HIGH, MF_BYCOMMAND);
        break;
    case ABOVE_NORMAL_PRIORITY_CLASS:
        CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_ABOVENORMAL, MF_BYCOMMAND);
        break;
    case NORMAL_PRIORITY_CLASS:
        CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_NORMAL, MF_BYCOMMAND);
        break;
    case BELOW_NORMAL_PRIORITY_CLASS:
        CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_BELOWNORMAL, MF_BYCOMMAND);
        break;
    case IDLE_PRIORITY_CLASS:
        CheckMenuRadioItem(hPriorityMenu, ID_PROCESS_PAGE_SETPRIORITY_REALTIME, ID_PROCESS_PAGE_SETPRIORITY_LOW, ID_PROCESS_PAGE_SETPRIORITY_LOW, MF_BYCOMMAND);
        break;
    }

    if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", 0, KEY_READ, &hKey) == ERROR_SUCCESS)
    {
        dwDebuggerSize = sizeof(strDebugger);
        if (RegQueryValueExW(hKey, L"Debugger", NULL, NULL, (LPBYTE)strDebugger, &dwDebuggerSize) == ERROR_SUCCESS)
        {
            CharUpper(strDebugger);
            if (wcsstr(strDebugger, L"DRWTSN32"))
                EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
        }
        else
            EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);

        RegCloseKey(hKey);
    } else {
        EnableMenuItem(hSubMenu, ID_PROCESS_PAGE_DEBUG, MF_BYCOMMAND|MF_DISABLED|MF_GRAYED);
    }
    TrackPopupMenu(hSubMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_LEFTBUTTON, pt.x, pt.y, 0, hMainWnd, NULL);
    DestroyMenu(hMenu);
}
开发者ID:Moteesh,项目名称:reactos,代码行数:72,代码来源:procpage.c

示例12: ShowStatusMenu

static VOID ShowStatusMenu(
    _In_ HWND hwndDlg
    )
{
    PPH_STRING cacheEntryName;
        
    cacheEntryName = PhGetSelectedListViewItemText(ListViewWndHandle);

    if (cacheEntryName)
    {
        POINT cursorPos;
        PPH_EMENU menu;
        PPH_EMENU_ITEM selectedItem;

        GetCursorPos(&cursorPos);

        menu = PhCreateEMenu();
        PhInsertEMenuItem(menu, PhCreateEMenuItem(0, 1, L"Remove", NULL, NULL), -1);

        selectedItem = PhShowEMenu(
            menu,
            ListViewWndHandle,
            PH_EMENU_SHOW_LEFTRIGHT,
            PH_ALIGN_LEFT | PH_ALIGN_TOP,
            cursorPos.x,
            cursorPos.y
            );

        if (selectedItem && selectedItem->Id != -1)
        {
            switch (selectedItem->Id)
            {
            case 1:
                {
                    INT lvItemIndex = PhFindListViewItemByFlags(
                        ListViewWndHandle,
                        -1,
                        LVNI_SELECTED
                        );

                    if (lvItemIndex != -1)
                    {
                        if (!PhGetIntegerSetting(L"EnableWarnings") || PhShowConfirmMessage(
                            hwndDlg,
                            L"remove",
                            cacheEntryName->Buffer,
                            NULL,
                            FALSE
                            ))
                        {
                            PATOM_TABLE_INFORMATION atomTable = NULL;

                            if (!NT_SUCCESS(PhEnumAtomTable(&atomTable)))
                                return;

                            for (ULONG i = 0; i < atomTable->NumberOfAtoms; i++)
                            {
                                PATOM_BASIC_INFORMATION atomInfo = NULL;

                                if (!NT_SUCCESS(PhQueryAtomTableEntry(atomTable->Atoms[i], &atomInfo)))
                                    continue;

                                if (!PhEqualStringZ(atomInfo->Name, cacheEntryName->Buffer, TRUE))
                                    continue;

                                do
                                {
                                    if (!NT_SUCCESS(NtDeleteAtom(atomTable->Atoms[i])))
                                    {
                                        break;
                                    }

                                    PhFree(atomInfo);
                                    atomInfo = NULL;

                                    if (!NT_SUCCESS(PhQueryAtomTableEntry(atomTable->Atoms[i], &atomInfo)))
                                        break;

                                } while (atomInfo->UsageCount >= 1);

                                ListView_DeleteItem(ListViewWndHandle, lvItemIndex);

                                if (atomInfo)
                                {
                                    PhFree(atomInfo);
                                }
                            }

                            PhFree(atomTable);
                        }
                    }
                }
                break;
            }
        }

        PhDestroyEMenu(menu);
        PhDereferenceObject(cacheEntryName);
    }
}
开发者ID:phplugins,项目名称:plugins-extra,代码行数:100,代码来源:main.c

示例13: WndProc

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_COMMAND:

		switch (LOWORD(wParam))
		{
		case ID_PM_REALTIME:
			SetProcessPriority(REALTIME_PRIORITY_CLASS);
			break;
		case ID_PM_HIGH:
			SetProcessPriority(HIGH_PRIORITY_CLASS);
			break;
		case ID_PM_ABOVE_NORMAL:
			SetProcessPriority(ABOVE_NORMAL_PRIORITY_CLASS);
			break;
		case ID_PM_NORMAL:
			SetProcessPriority(NORMAL_PRIORITY_CLASS);
			break;
		case ID_PM_BELOW_NORMAL:
			SetProcessPriority(BELOW_NORMAL_PRIORITY_CLASS);
			break;
		case ID_PM_IDLE:
			SetProcessPriority(IDLE_PRIORITY_CLASS);
			break;
		}

		switch (HIWORD(wParam))
		{
		case 1:
			{
				if (lParam == (LPARAM)ListBoxProcess)
					ShowModule();
			}
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
			break;
		}

		break;

	case WM_CONTEXTMENU:
		if (SendMessage(ListBoxProcess, LB_GETCURSEL, 0, 0) != LB_ERR)
		{
			POINT cursorPosition;
			GetCursorPos(&cursorPosition);
			TrackPopupMenu(PopupMenu, TPM_BOTTOMALIGN | TPM_LEFTALIGN, cursorPosition.x, cursorPosition.y, 0, hWnd, NULL);
		}
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
		break;
	}

	return 0;
}
开发者ID:Raumo0,项目名称:Labs,代码行数:63,代码来源:lab_5.cpp

示例14: if

void EMU::update_input()
{
#ifdef USE_SHIFT_NUMPAD_KEY
	// update numpad key status
	if(key_shift_pressed && !key_shift_released) {
		if(key_status[VK_SHIFT] == 0) {
			// shift key is newly pressed
			key_status[VK_SHIFT] = 0x80;
#ifdef NOTIFY_KEY_DOWN
			vm->key_down(VK_SHIFT, false);
#endif
		}
	}
	else if(!key_shift_pressed && key_shift_released) {
		if(key_status[VK_SHIFT] != 0) {
			// shift key is newly released
			key_status[VK_SHIFT] = 0;
#ifdef NOTIFY_KEY_DOWN
			vm->key_up(VK_SHIFT);
#endif
			// check l/r shift
			if(!(GetAsyncKeyState(VK_LSHIFT) & 0x8000)) key_status[VK_LSHIFT] &= 0x7f;
			if(!(GetAsyncKeyState(VK_RSHIFT) & 0x8000)) key_status[VK_RSHIFT] &= 0x7f;
		}
	}
	key_shift_pressed = key_shift_released = false;
#endif
	
	// release keys
#ifdef USE_AUTO_KEY
	if(lost_focus && autokey_phase == 0) {
#else
	if(lost_focus) {
#endif
		// we lost key focus so release all pressed keys
		for(int i = 0; i < 256; i++) {
			if(key_status[i] & 0x80) {
				key_status[i] &= 0x7f;
#ifdef NOTIFY_KEY_DOWN
				if(!key_status[i]) {
					vm->key_up(i);
				}
#endif
			}
		}
	}
	else {
		for(int i = 0; i < 256; i++) {
			if(key_status[i] & 0x7f) {
				key_status[i] = (key_status[i] & 0x80) | ((key_status[i] & 0x7f) - 1);
#ifdef NOTIFY_KEY_DOWN
				if(!key_status[i]) {
					vm->key_up(i);
				}
#endif
			}
		}
	}
	lost_focus = false;
	
	// update joystick status
	memset(joy_status, 0, sizeof(joy_status));
	for(int i = 0; i < joy_num && i < 2; i++) {
		JOYINFOEX joyinfo;
		joyinfo.dwSize = sizeof(JOYINFOEX);
		joyinfo.dwFlags = JOY_RETURNALL;
		if(joyGetPosEx(i, &joyinfo) == JOYERR_NOERROR) {
			if(joyinfo.dwYpos < 0x3fff) joy_status[i] |= 0x01;	// up
			if(joyinfo.dwYpos > 0xbfff) joy_status[i] |= 0x02;	// down
			if(joyinfo.dwXpos < 0x3fff) joy_status[i] |= 0x04;	// left
			if(joyinfo.dwXpos > 0xbfff) joy_status[i] |= 0x08;	// right
			joy_status[i] |= ((joyinfo.dwButtons & joy_mask[i]) << 4);
		}
	}
#ifdef USE_KEY_TO_JOY
	// emulate joystick #1 with keyboard
	if(key_status[0x26]) joy_status[0] |= 0x01;	// up
	if(key_status[0x28]) joy_status[0] |= 0x02;	// down
	if(key_status[0x25]) joy_status[0] |= 0x04;	// left
	if(key_status[0x27]) joy_status[0] |= 0x08;	// right
#endif
	
	// update mouse status
	memset(mouse_status, 0, sizeof(mouse_status));
	if(mouse_enabled) {
		// get current status
		POINT pt;
		GetCursorPos(&pt);
		ScreenToClient(main_window_handle, &pt);
		mouse_status[0]  = pt.x - display_width / 2;
		mouse_status[1]  = pt.y - display_height / 2;
		mouse_status[2]  = (GetAsyncKeyState(VK_LBUTTON) & 0x8000) ? 1 : 0;
		mouse_status[2] |= (GetAsyncKeyState(VK_RBUTTON) & 0x8000) ? 2 : 0;
		mouse_status[2] |= (GetAsyncKeyState(VK_MBUTTON) & 0x8000) ? 4 : 0;
		// move mouse cursor to the center of window
		if(!(mouse_status[0] == 0 && mouse_status[1] == 0)) {
			pt.x = display_width / 2;
			pt.y = display_height / 2;
			ClientToScreen(main_window_handle, &pt);
			SetCursorPos(pt.x, pt.y);
//.........这里部分代码省略.........
开发者ID:meesokim,项目名称:fc-100,代码行数:101,代码来源:win32_input.cpp

示例15: GetMessageTime

WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(HWND hwnd, UINT message,
                                                         WPARAM wparam, LPARAM lparam)
{
    WebMouseWheelEvent result; //(WebInputEvent::Uninitialized());

    result.type = WebInputEvent::MouseWheel;

    // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that
    // GetMessageTime() refers to is the same one that we're passed in? Perhaps
    // one of the construction parameters should be the time passed by the
    // caller, who would know for sure.
    result.timeStampSeconds = GetMessageTime() / 1000.0;

    result.button = WebMouseEvent::ButtonNone;

    // Get key state, coordinates, and wheel delta from event.
    typedef SHORT (WINAPI *GetKeyStateFunction)(int key);
    GetKeyStateFunction getKeyState;
    UINT keyState;
    float wheelDelta;
    bool horizontalScroll = false;
    if ((message == WM_VSCROLL) || (message == WM_HSCROLL)) {
        // Synthesize mousewheel event from a scroll event.  This is needed to
        // simulate middle mouse scrolling in some laptops.  Use GetAsyncKeyState
        // for key state since we are synthesizing the input event.
        getKeyState = GetAsyncKeyState;
        keyState = 0;
        if (getKeyState(VK_SHIFT))
            keyState |= MK_SHIFT;
        if (getKeyState(VK_CONTROL))
            keyState |= MK_CONTROL;
        // NOTE: There doesn't seem to be a way to query the mouse button state
        // in this case.

        POINT cursorPosition = {0};
        GetCursorPos(&cursorPosition);
        result.globalX = cursorPosition.x;
        result.globalY = cursorPosition.y;

        switch (LOWORD(wparam)) {
        case SB_LINEUP:    // == SB_LINELEFT
            wheelDelta = WHEEL_DELTA;
            break;
        case SB_LINEDOWN:  // == SB_LINERIGHT
            wheelDelta = -WHEEL_DELTA;
            break;
        case SB_PAGEUP:
            wheelDelta = 1;
            result.scrollByPage = true;
            break;
        case SB_PAGEDOWN:
            wheelDelta = -1;
            result.scrollByPage = true;
            break;
        default:  // We don't supoprt SB_THUMBPOSITION or SB_THUMBTRACK here.
            wheelDelta = 0;
            break;
        }

        if (message == WM_HSCROLL)
            horizontalScroll = true;
    } else {
        // Non-synthesized event; we can just read data off the event.
        getKeyState = GetKeyState;
        keyState = GET_KEYSTATE_WPARAM(wparam);

        result.globalX = static_cast<short>(LOWORD(lparam));
        result.globalY = static_cast<short>(HIWORD(lparam));

        wheelDelta = static_cast<float>(GET_WHEEL_DELTA_WPARAM(wparam));
        if (message == WM_MOUSEHWHEEL) {
            horizontalScroll = true;
            wheelDelta = -wheelDelta;  // Windows is <- -/+ ->, WebKit <- +/- ->.
        }
    }
    if (keyState & MK_SHIFT)
        horizontalScroll = true;

    // Set modifiers based on key state.
    if (keyState & MK_SHIFT)
        result.modifiers |= WebInputEvent::ShiftKey;
    if (keyState & MK_CONTROL)
        result.modifiers |= WebInputEvent::ControlKey;
    if (getKeyState(VK_MENU) & 0x8000)
        result.modifiers |= WebInputEvent::AltKey;
    if (keyState & MK_LBUTTON)
        result.modifiers |= WebInputEvent::LeftButtonDown;
    if (keyState & MK_MBUTTON)
        result.modifiers |= WebInputEvent::MiddleButtonDown;
    if (keyState & MK_RBUTTON)
        result.modifiers |= WebInputEvent::RightButtonDown;

    // Set coordinates by translating event coordinates from screen to client.
    POINT clientPoint = { result.globalX, result.globalY };
    MapWindowPoints(0, hwnd, &clientPoint, 1);
    result.x = clientPoint.x;
    result.y = clientPoint.y;
    result.windowX = result.x;
    result.windowY = result.y;

//.........这里部分代码省略.........
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:101,代码来源:WebInputEventFactory.cpp


注:本文中的GetCursorPos函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。