LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
        switch (msg)
        {
        case WM_SYSKEYDOWN:
        {
            if (wParam == VK_MENU)//ignore left alt stop
            {
            }
            else
                return DefWindowProc(hwnd, msg, wParam, lParam); // this makes ALT+F4 work
            break;
        }
        case WM_CLOSE:
        {
            ShowWindow(hwnd, false);
            PostQuitMessage(0);
            break;
        }
        case WM_COMMAND:
            break;
        case WM_MOUSEWHEEL:
        {
            win32mouse->SetMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
            break;
        }
        case WM_INPUT:
        {
            UINT dwSize = 48; // 48 for 64bit build
            static BYTE lpb[48];

            GetRawInputData((HRAWINPUT)lParam, RID_INPUT,
                lpb, &dwSize, sizeof(RAWINPUTHEADER)); // this gets relative coords

            RAWINPUT* raw = (RAWINPUT*)lpb;

            if (raw->header.dwType == RIM_TYPEMOUSE)
            {
                int xPosRelative = raw->data.mouse.lLastX;
                int yPosRelative = raw->data.mouse.lLastY;
                win32mouse->SetCursorDeltaRaw(xPosRelative, yPosRelative);
            }
            break;
        }
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
        }
        return 0;
	}
Exemple #2
0
//-----------------------------------------------------------------------------
// Name: MsgProc()
// Desc: The window's message handler
//-----------------------------------------------------------------------------
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
        case WM_DESTROY:
            PostQuitMessage( 0 );
            break;
		case WM_SETCURSOR:
			CGameInput::getSingletonPtr()->SetCursorIcon();
			break;
		case WM_CHAR:
			printf( "WM_CHAR\n" );
			CGameInput::getSingletonPtr()->InJectChar( wParam );
			break;
		case WM_KEYDOWN:
			printf( "WM_KEYDOWN\n" );
			CGameInput::getSingletonPtr()->KeyDown( wParam, lParam );
			break;
		case WM_KEYUP:
			printf( "WM_KEYUP\n" );
			CGameInput::getSingletonPtr()->KeyUp( wParam, lParam );
			break;
		case WM_LBUTTONDOWN:
		case WM_LBUTTONDBLCLK:
			CGameInput::getSingletonPtr()->SetMouseLBtn(0);
			break;
		case WM_LBUTTONUP:
			CGameInput::getSingletonPtr()->SetMouseLBtn(1);
			break;
		case WM_RBUTTONDOWN:
			CGameInput::getSingletonPtr()->SetMouseRBtn(0);
			break;
		case WM_RBUTTONUP:
			CGameInput::getSingletonPtr()->SetMouseRBtn(1);
			break;
		case WM_MOUSEMOVE:
			CGameInput::getSingletonPtr()->MouseMove( (int)LOWORD( lParam ), (int)HIWORD( lParam ) );
			break;
		case WM_MOUSEWHEEL:
			CGameInput::getSingletonPtr()->SetMouseWheel( GET_WHEEL_DELTA_WPARAM( wParam ) );
			break;
		case WM_MOVE:
			g_iWinX = (int)(short) LOWORD(lParam);   // horizontal position 
			g_iWinY = (int)(short) HIWORD(lParam);   // vertical position 
			break;
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}
Exemple #3
0
LRESULT HubMessageControl::onMouseWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
  m_wheelAccumulator += GET_WHEEL_DELTA_WPARAM(wParam);
  while (abs(m_wheelAccumulator) >= WHEEL_DELTA) {
    const bool isNeg = m_wheelAccumulator < 0;
    m_wheelAccumulator = abs(m_wheelAccumulator) - WHEEL_DELTA;
    if (isNeg) {
      if (m_wheelAccumulator != 0) m_wheelAccumulator = -m_wheelAccumulator;
      SendMessage(WM_VSCROLL, SB_LINEDOWN);
    }
    else {
      SendMessage(WM_VSCROLL, SB_LINEUP);
    }
  }
  return 0;
}
Exemple #4
0
LRESULT CDangleWindowHex::DangleProc(UINT Msg,WPARAM wParam,LPARAM lParam)
{
	//выбор по сообщению
	switch(Msg)
	{
	case WM_KEYDOWN:
		return OnKey(wParam),0;
	case WM_COMMAND:
		return OnCommand(LOWORD(wParam),HIWORD(wParam),(HWND)lParam),0;
	case WM_MOUSEWHEEL:
		return OnMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam)/WHEEL_DELTA,GET_KEYSTATE_WPARAM(wParam)),0;
	default:
		return DefWindowProc(mhWindow,Msg,wParam,lParam);
	}
}
Exemple #5
0
/***********************************************************************
 * UPDOWN_MouseWheel
 *
 * Handle mouse wheel scrolling
 */
static LRESULT UPDOWN_MouseWheel(UPDOWN_INFO *infoPtr, WPARAM wParam)
{
    int iWheelDelta = GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA;

    if (wParam & (MK_SHIFT | MK_CONTROL))
        return 0;

    if (iWheelDelta != 0)
    {
        UPDOWN_GetBuddyInt(infoPtr);
        UPDOWN_DoAction(infoPtr, abs(iWheelDelta), iWheelDelta > 0 ? FLAG_INCR : FLAG_DECR);
    }

    return 1;
}
Exemple #6
0
void CGameMain::OnMouseWheel(const WPARAM& wParam, const LPARAM& lParam){
	int delta = GET_WHEEL_DELTA_WPARAM(wParam);
	eMouseKeyStateMask keyState = (eMouseKeyStateMask)GET_KEYSTATE_WPARAM(wParam);

	///// 鼠标所在的屏幕坐标
	int x = GET_X_LPARAM(lParam);
	int y = GET_Y_LPARAM(lParam); //WHEEL_DELTA
	
	static POINT pos;
	pos.x = x;
	pos.y = y;
	::ScreenToClient(g_hWnd, &pos); ////--> 转化为客户区坐标
	//printf("OnMouseWheel %d %d  (%d,%d) (%d,%d) \n", delta, keyState, x, y, pos.x, pos.y);
	_gui.OnMouseWheel(x, y, delta, keyState);
}
Exemple #7
0
bool ExScrollBar::isPressed(unsigned int Sender, WPARAM wParam)
{
	if (cState == INVISIBLE) return false;
	switch (Sender) {
	case WM_KEYDOWN:
	{
		switch (wParam)
		{
		case VK_UP:   {if (*sValue > sMin)    { *sValue = *sValue - 1; Update(); } return true; }
		case VK_DOWN: {if (*sValue<sMax)    { *sValue = *sValue + 1; Update(); }  return true; }
		case VK_PRIOR:{if (*sValue >= sMin + 5) { *sValue = *sValue - 5; Update(); } else if (*sValue>sMin) { *sValue = sMin; Update(); }  return true; } /*PGUP*/
		case VK_NEXT: {if (*sValue <= sMax - 5) { *sValue = *sValue + 5; Update(); } else if (*sValue<sMax) { *sValue = sMax; Update(); }  return true; } /*PGDN*/
		case VK_HOME: {if (*sValue>sMin)    { *sValue = sMin; Update(); }  return true; }
		case VK_END:  {if (*sValue<sMax)    { *sValue = sMax; Update(); }  return true; }
		}
	}
	case WM_MOUSEWHEEL:
	{
		if (GET_WHEEL_DELTA_WPARAM(wParam)>0)		{ if (*sValue > sMin)    { *sValue = *sValue - 1; Update(); } return true; }
		else if (GET_WHEEL_DELTA_WPARAM(wParam) < 0)   { if (*sValue < sMax)    { *sValue = *sValue + 1; Update(); }  return true; }
	}
	}
	return false;
}
LRESULT CALLBACK Window::WindowProc(HWND Handle, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
	TwEventWin(Handle,msg,wParam,lParam);

	switch (msg)
	{
		case WM_SYSCOMMAND:
			{
				if (wParam == SC_CLOSE)
				{
					PostMessage(Handle,WM_DESTROY,0,0);
				}
				break;
			}

		case WM_DESTROY:
			{
				PostQuitMessage(0);
				break;
			}

		case WM_MOUSEWHEEL:
			{
				if(lcMouse::Get())
					lcMouse::Get()->m_uiScrollVal = GET_WHEEL_DELTA_WPARAM(wParam);
				break;
			}

		case WM_DROPFILES:
			{
				HDROP hDrop = (HDROP)wParam;
				int iFileCount = DragQueryFile(hDrop,0xFFFFFFFF, nullptr, MAX_PATH);
				for(int i = 0;i < iFileCount;++i)
				{
					char a_szFileDir[256];
					DragQueryFile(hDrop,i,a_szFileDir,MAX_PATH);
					m_pSingleton->OnDropFile(a_szFileDir);
				}
				DragFinish(hDrop);
				break;
			}

		default:
			return DefWindowProc(Handle,msg,wParam,lParam);
	};

	return 0;
}
Exemple #9
0
void customize_Scene::WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
	switch (iMessage)
	{

	case WM_MOUSEWHEEL:

		Z -= (GET_WHEEL_DELTA_WPARAM(wParam) / 100);
		if (Z < 0.5)
			Z = 0.5f;
		if (Z > 10)
			Z = 10;	
		
		break;
	}
}
Exemple #10
0
void CDataScope::OnMouseWheel(WPARAM wParam, LPARAM lParam)
{
  INT nValue = GET_WHEEL_DELTA_WPARAM(wParam);

  // Update scroll info
  if (nValue > 0)
  {
    m_fXScale *= 0.9;
  }
  else
  {
    m_fXScale /= 0.9;
  }

  InvalidateRect(m_hWnd, NULL, TRUE);
}
void WinInputManager::Run(UINT const & msg, WPARAM wParam, LPARAM lParam)
{
    if (m_listenerList.empty())
        return;

    eKeyCodes KeyIndex;
    wchar_t buffer[1];
    BYTE lpKeyState[256];

    CursorEvent();
    switch (msg)
    {
    case WM_KEYDOWN:
        KeyIndex = static_cast<eKeyCodes>(wParam);
        GetKeyboardState(lpKeyState);
        ToUnicode(wParam, HIWORD(lParam) & 0xFF, lpKeyState, buffer, 1, 0);
        KeyEvent(KeyIndex, buffer[0], true);
        break;
    case WM_KEYUP:
        KeyIndex = static_cast<eKeyCodes>(wParam);
        GetKeyboardState(lpKeyState);
        ToUnicode(wParam, HIWORD(lParam) & 0xFF, lpKeyState, buffer, 1, 0);
        KeyEvent(KeyIndex, buffer[0], false);
        break;
    case WM_LBUTTONDOWN:
        MouseEvent(MOUSE_LEFT, true);
        break;
    case WM_LBUTTONUP:
        MouseEvent(MOUSE_LEFT, false);
        break;
    case WM_RBUTTONDOWN:
        MouseEvent(MOUSE_RIGHT, true);
        break;
    case WM_RBUTTONUP:
        MouseEvent(MOUSE_RIGHT, false);
        break;
    case WM_MBUTTONDOWN:
        MouseEvent(MOUSE_MIDDLE, true);
        break;
    case WM_MBUTTONUP:
        MouseEvent(MOUSE_MIDDLE, false);
        break;
    case WM_MOUSEWHEEL:
        MouseWheelEvent((short)GET_WHEEL_DELTA_WPARAM(wParam) / WHEEL_DELTA);
        break;
    }
}
Exemple #12
0
WebWheelEvent WebEventFactory::createWebWheelEvent(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    // Taken from WebCore
    static const float cScrollbarPixelsPerLine = 100.0f / 3.0f;

    POINT globalPosition = point(lParam);
    POINT position = globalPosition;
    ::ScreenToClient(hWnd, &position);

    WebWheelEvent::Granularity granularity  = WebWheelEvent::ScrollByPixelWheelEvent;

    WebEvent::Modifiers modifiers = modifiersForEvent(wParam);
    double timestamp = ::GetTickCount() * 0.001; // ::GetTickCount returns milliseconds (Chrome uses GetMessageTime() / 1000.0)

    int deltaX = 0;
    int deltaY = 0;
    int wheelTicksX = 0;
    int wheelTicksY = 0;

    float delta = GET_WHEEL_DELTA_WPARAM(wParam) / static_cast<float>(WHEEL_DELTA);
    bool isMouseHWheel = (message == WM_VISTA_MOUSEHWHEEL);
    if (isMouseHWheel) {
        wheelTicksX = delta;
        wheelTicksY = 0;
        delta = -delta;
    } else {
        wheelTicksX = 0;
        wheelTicksY = delta;
    }
    if (isMouseHWheel || (modifiers & WebEvent::ShiftKey)) {
        deltaX = delta * static_cast<float>(horizontalScrollChars()) * cScrollbarPixelsPerLine;
        deltaY = 0;
        granularity = WebWheelEvent::ScrollByPixelWheelEvent;
    } else {
        deltaX = 0;
        deltaY = delta;
        int verticalMultiplier = verticalScrollLines();
        if (verticalMultiplier == WHEEL_PAGESCROLL)
            granularity = WebWheelEvent::ScrollByPageWheelEvent;
        else {
            granularity = WebWheelEvent::ScrollByPixelWheelEvent;
            deltaY *= static_cast<float>(verticalMultiplier) * cScrollbarPixelsPerLine;
        }
    }

    return WebWheelEvent(WebEvent::Wheel, position, globalPosition, FloatSize(deltaX, deltaY), FloatSize(wheelTicksX, wheelTicksY), granularity, modifiers, timestamp);
}
Exemple #13
0
VOID CInputManager::MessageProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch(message)
	{
	//滚轮消息
	case WM_MOUSEWHEEL:
		{
			if(GET_WHEEL_DELTA_WPARAM(wParam)>0)
			{
				m_dwMouseFlag |= MOUSE_WHEELUP;
			}
			else
			{
				m_dwMouseFlag |= MOUSE_WHEELDOWN;
			}
		}
		break;
	//键盘按下
	case WM_KEYDOWN:
		{
			//用来处理重复的键盘按下
			m_Buf_WM_KEYDOWN = std::make_pair(wParam, lParam);
			m_bCatchKeyDown = true;
//			AxTrace(0, 2, "Push:%d", wParam);
		}
		break;

	//鼠标
	case WM_LBUTTONDBLCLK:
	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_RBUTTONDOWN:
	case WM_RBUTTONUP:
	case WM_MOUSEMOVE:
		{
			m_ptMouseNow.x = GET_X_LPARAM(lParam); 
			m_ptMouseNow.y = GET_Y_LPARAM(lParam); 
		}
		break;

	//文字输入
	case WM_CHAR:
	case WM_IME_COMPOSITION:
		CGameProcedure::s_pUISystem_->InjectInput_CHAR(hWnd, message, wParam, lParam);
		break;
	}
}
Exemple #14
0
IMGUI_API LRESULT ImGui_ImplDX10_WndProcHandler(HWND, UINT msg, WPARAM wParam, LPARAM lParam)
{
    ImGuiIO& io = ImGui::GetIO();
    switch (msg)
    {
    case WM_LBUTTONDOWN:
        io.MouseDown[0] = true;
        return true;
    case WM_LBUTTONUP:
        io.MouseDown[0] = false;
        return true;
    case WM_RBUTTONDOWN:
        io.MouseDown[1] = true;
        return true;
    case WM_RBUTTONUP:
        io.MouseDown[1] = false;
        return true;
    case WM_MBUTTONDOWN:
        io.MouseDown[2] = true;
        return true;
    case WM_MBUTTONUP:
        io.MouseDown[2] = false;
        return true;
    case WM_MOUSEWHEEL:
        io.MouseWheel += GET_WHEEL_DELTA_WPARAM(wParam) > 0 ? +1.0f : -1.0f;
        return true;
    case WM_MOUSEMOVE:
        io.MousePos.x = (signed short)(lParam);
        io.MousePos.y = (signed short)(lParam >> 16);
        return true;
    case WM_KEYDOWN:
        if (wParam < 256)
            io.KeysDown[wParam] = 1;
        return true;
    case WM_KEYUP:
        if (wParam < 256)
            io.KeysDown[wParam] = 0;
        return true;
    case WM_CHAR:
        // You can also use ToAscii()+GetKeyboardState() to retrieve characters.
        if (wParam > 0 && wParam < 0x10000)
            io.AddInputCharacter((unsigned short)wParam);
        return true;
    }
    return 0;
}
Exemple #15
0
void HandleMouseScrollEvents(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LPSCROLLSTATE state)
{
    SCROLLINFO si;
    int Delta;
    int NewPos;

    si.cbSize = sizeof(si);
    si.fMask = SIF_PAGE;
    GetScrollInfo(hWnd, SB_VERT, &si);

    if (Globals.uLinesToScroll == WHEEL_PAGESCROLL)
    {
        NewPos = si.nPage;
    }
    else
    {
        NewPos = Globals.uLinesToScroll * 5;
    }

    if (GET_WHEEL_DELTA_WPARAM(wParam) > 0)
    {
        NewPos = state->CurrentY - NewPos;
    }
    else
    {
        NewPos = state->CurrentY + NewPos;
    }

    NewPos = min(state->MaxY, max(0, NewPos));

    if (NewPos == state->CurrentY)
    {
        return;
    }

    Delta = NewPos - state->CurrentY;

    state->CurrentY = NewPos;

    ScrollWindowEx(hWnd, 0, -Delta, NULL, NULL, NULL, NULL, SW_INVALIDATE);

    si.cbSize = sizeof(si);
    si.fMask = SIF_POS;
    si.nPos = state->CurrentY;
    SetScrollInfo(hWnd, SB_VERT, &si, TRUE);
}
Exemple #16
0
BOOL CMouseWheelMgr::OnMouseEx(UINT uMouseMsg, const MOUSEHOOKSTRUCTEX& info)
{
	if (uMouseMsg == WM_MOUSEWHEEL)
	{
		HWND hwndPt = ::WindowFromPoint(info.pt);
		int zDelta = GET_WHEEL_DELTA_WPARAM(info.mouseData);

		if (info.hwnd != hwndPt)  // does the window under the mouse have the focus.
		{
			// modifier keys are not reported in MOUSEHOOKSTRUCTEX
			// so we have to figure them out
			WORD wKeys = 0;

			if (GetKeyState(VK_CONTROL) & 0x8000)
				wKeys |= MK_CONTROL;

			if (GetKeyState(VK_SHIFT) & 0x8000)
				wKeys |= MK_SHIFT;

			if (GetKeyState(VK_LBUTTON) & 0x8000)
				wKeys |= MK_LBUTTON;

			if (GetKeyState(VK_RBUTTON) & 0x8000)
				wKeys |= MK_RBUTTON;

			if (GetKeyState(VK_MBUTTON) & 0x8000)
				wKeys |= MK_MBUTTON;
			
			::PostMessage(hwndPt, WM_MOUSEWHEEL, MAKEWPARAM(wKeys, zDelta), MAKELPARAM(info.pt.x, info.pt.y));
			return TRUE; // eat
		}
		else // special cases not natively supporting mouse wheel
		{
			CString sClass = CWinClasses::GetClass(hwndPt);
			
			if (CWinClasses::IsClass(sClass, WC_DATETIMEPICK) ||
				CWinClasses::IsClass(sClass, WC_MONTHCAL))
			{
				::PostMessage(hwndPt, WM_KEYDOWN, zDelta > 0 ? VK_UP : VK_DOWN, 0L);
			}
		}
	}
	
	// all else
	return FALSE;
}
/*************************************************************//**
 *
 *  @brief  送信されたメッセージの処理を行う
 *  @param  ウィンドウハンドル
 *  @param  メッセージ
 *  @param  メッセージの付加情報
 *  @param  メッセージの付加情報
 *  @return メッセージ処理の結果
 *
 ****************************************************************/
LRESULT CALLBACK C_MainWindow::LocalWindowProcedure(HWND pWindowHandle,
                                                    UINT message,
                                                    WPARAM wParameter,
                                                    LPARAM lParameter)
{
    // ウィンドウのクライアント領域を描画するときに使うことのできる情報
    PAINTSTRUCT paintStruct;

    // デバイスコンテキストハンドル
    HDC deviceContextHandle = nullptr;

    // 送られてきたメッセージにより各種処理を行う
    switch (message)
    {
    /* マウスホイールを回転した場合 */
    case WM_MOUSEWHEEL:

        // 回転量を設定
        C_InputManager::s_GetInstance()->SetMouseWheelRotation(GET_WHEEL_DELTA_WPARAM(wParameter) / WHEEL_DELTA);

        break;
    /* 無効領域が発生した場合 */
    case WM_PAINT:

        // 指定されたウィンドウに対して描画の準備
        deviceContextHandle = ::BeginPaint(pWindowHandle, &paintStruct);

        // 指定されたウィンドウ内の描画の終わりを示す
        ::EndPaint(pWindowHandle, &paintStruct);

        break;
    /* ウィンドウが破棄される場合 */
    case WM_DESTROY:

        // アプリケーションの終了コードを指定
        ::PostQuitMessage(0);

        // 終了フラグを立てる
        C_BaseWindow::s_SetFinishFlag(true);

        break;
    }

    // メッセージ処理の結果を返す
    return DefWindowProc(pWindowHandle, message, wParameter, lParameter);
}
LRESULT WebPopupMenuProxyWin::onMouseWheel(HWND hWnd, UINT message, WPARAM wParam, LPARAM, bool& handled)
{
    handled = true;

    if (!scrollbar())
        return 0;

    int i = 0;
    for (incrementWheelDelta(GET_WHEEL_DELTA_WPARAM(wParam)); abs(wheelDelta()) >= WHEEL_DELTA; reduceWheelDelta(WHEEL_DELTA)) {
        if (wheelDelta() > 0)
            ++i;
        else
            --i;
    }

    ScrollableArea::scroll(i > 0 ? ScrollUp : ScrollDown, ScrollByLine, abs(i));
    return 0;
}
Exemple #19
0
PlatformWheelEvent::PlatformWheelEvent(HWND hWnd, WPARAM wParam, LPARAM lParam, bool isMouseHWheel)
    : PlatformEvent(PlatformEvent::Wheel, wParam & MK_SHIFT, wParam & MK_CONTROL, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, GetKeyState(VK_MENU) & HIGH_BIT_MASK_SHORT, ::GetTickCount() * 0.001)
    , m_position(positionForEvent(hWnd, lParam))
    , m_globalPosition(globalPositionForEvent(hWnd, lParam))
    , m_directionInvertedFromDevice(false)
{
    float scaleFactor = deviceScaleFactorForWindow(hWnd);

    // How many pixels should we scroll per line?  Gecko uses the height of the
    // current line, which means scroll distance changes as you go through the
    // page or go to different pages.  IE 7 is ~50 px/line, although the value
    // seems to vary slightly by page and zoom level.  Since IE 7 has a
    // smoothing algorithm on scrolling, it can get away with slightly larger
    // scroll values without feeling jerky.  Here we use 100 px per three lines
    // (the default scroll amount on Windows is three lines per wheel tick).
    static const float cScrollbarPixelsPerLine = scaleFactor * 100.0f / 3.0f;
    float delta = GET_WHEEL_DELTA_WPARAM(wParam) / (scaleFactor * static_cast<float>(WHEEL_DELTA));
    if (isMouseHWheel) {
        // Windows is <-- -/+ -->, WebKit wants <-- +/- -->, so we negate
        // |delta| after saving the original value on the wheel tick member.
        m_wheelTicksX = delta;
        m_wheelTicksY = 0;
        delta = -delta;
    } else {
        // Even though we use shift + vertical wheel to scroll horizontally in
        // WebKit, we still note it as a vertical scroll on the wheel tick
        // member, so that the DOM event we later construct will match the real
        // hardware event better.
        m_wheelTicksX = 0;
        m_wheelTicksY = delta;
    }
    if (isMouseHWheel || shiftKey()) {
        m_deltaX = delta * static_cast<float>(horizontalScrollChars()) * cScrollbarPixelsPerLine;
        m_deltaY = 0;
        m_granularity = ScrollByPixelWheelEvent;
    } else {
        m_deltaX = 0;
        m_deltaY = delta;
        int verticalMultiplier = verticalScrollLines();
        m_granularity = (verticalMultiplier == WHEEL_PAGESCROLL) ? ScrollByPageWheelEvent : ScrollByPixelWheelEvent;
        if (m_granularity == ScrollByPixelWheelEvent)
            m_deltaY *= static_cast<float>(verticalMultiplier) * cScrollbarPixelsPerLine;
    }
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, 
						    LPARAM lParam)
{
    switch(message)
    {
		case WM_MOUSEWHEEL:
			{
				int clicks = GET_WHEEL_DELTA_WPARAM(wParam);
				float end_value = scale->GetEndValue();
				end_value *= pow(0.9, clicks/120);
				scale->Interrupt(end_value, 500);
			} break;
		case WM_KEYDOWN:
			{
				if(wParam == VK_LEFT)
				{
					float x_value = X->GetEndValue() - scale->GetValue() / 10;
					X->Interrupt(x_value, 500);
				}
				if(wParam == VK_RIGHT)
				{
					float x_value = X->GetEndValue() + scale->GetValue() / 10;
					X->Interrupt(x_value, 500);
				}
				if(wParam == VK_UP)
				{
					float y_value = Y->GetEndValue() + scale->GetValue() / 10;
					Y->Interrupt(y_value, 500);
				}
				if(wParam == VK_DOWN)
				{
					float y_value = Y->GetEndValue() - scale->GetValue() / 10;
					Y->Interrupt(y_value, 500);
				}
			} break;
        case WM_DESTROY:
            {
                PostQuitMessage(0);
                return 0;
            } break;
    }

    return DefWindowProc (hWnd, message, wParam, lParam);
}
LRESULT Camera::CameraInputProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch ( message )
	{
		case WM_RBUTTONDOWN:
			isDrag = true;
			prevMousePos.x = GET_X_LPARAM(lParam);
			prevMousePos.y = GET_Y_LPARAM(lParam);
			break;
		case WM_RBUTTONUP:
			isDrag = false;
			break;
		case WM_MOUSEMOVE:
			{
				if ( isDrag )
				{
					POINT currentMousePos;
					currentMousePos.x = GET_X_LPARAM(lParam);
					currentMousePos.y = GET_Y_LPARAM(lParam);
					float fDeltaX = (float)(currentMousePos.x - prevMousePos.x);
					float fDeltaY = (float)(currentMousePos.y - prevMousePos.y);

					camRotX += ( fDeltaY / 100.f );
					camRotY += ( fDeltaX / 100.f );

					if ( camRotX < -D3DX_PI / 0.5f + 0.0001f )
						camRotX = -D3DX_PI / 0.5f + 0.0001f;

					if ( camRotX > D3DX_PI / 0.5f - 0.0001f )
						camRotX = D3DX_PI / 0.5f - 0.0001f;

					prevMousePos = currentMousePos;
				}
			}
			break;
		case WM_MOUSEWHEEL:
			camDistance += -GET_WHEEL_DELTA_WPARAM(wParam) / 100.f;
			if ( camDistance < 1.0f )
				camDistance = 1.0f;
			break;
	}

	return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
		case WM_INPUT:
			OnRawInput(
				GET_RAWINPUT_CODE_WPARAM(wParam) == RIM_INPUT,
				(HRAWINPUT)lParam
			);
			return(DefWindowProc(hWnd, msg, wParam, lParam));
		case WM_MOUSEWHEEL:
			OutputDebugString(_T("WM_MOUSEWHEEL\n"));
			TCHAR buffer[1024];
			memset(buffer, NULL, 1024);
			_stprintf_s(buffer, 1024, _T("  wheel delta=%d\n"), GET_WHEEL_DELTA_WPARAM(wParam));
			OutputDebugString(buffer);
			break;
		// Windows XP までは tilt は専用ドライバによってWM_HSCROLLを発行している場合が多いらしい
		case WM_HSCROLL:
			OutputDebugString(_T("WM_HSCROLL\n"));
			break;
		// Windows Vista からは tilt は WM_MOUSEHWHEEL で検出できるらしい
		case WM_MOUSEHWHEEL:
			OutputDebugString(_T("WM_MOUSEHWHEEL\n"));
			break;
		case WM_CREATE:
			device.usUsagePage = 0x01;
			device.usUsage = 0x02;
			device.dwFlags = 0;
			device.hwndTarget = 0;
			RegisterRawInputDevices(&device, 1, sizeof device);
			break;
		case WM_DESTROY:
			device.usUsagePage = 0x01;
			device.usUsage = 0x02;
			device.dwFlags = RIDEV_REMOVE;
			device.hwndTarget = 0;
			RegisterRawInputDevices(&device, 1, sizeof device);
			PostQuitMessage(0);
			break;
		default:
			return(DefWindowProc(hWnd, msg, wParam, lParam));
	}
	return (0L);
}
Exemple #23
0
void cCamera::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam )
{
	switch (message)
	{
	case WM_LBUTTONDOWN:
		{
			m_ptPrevMouse.x = LOWORD(lParam);
			m_ptPrevMouse.y = HIWORD(lParam);
		}
		break;
	case WM_MOUSEWHEEL:
		{
			m_fDistance -= GET_WHEEL_DELTA_WPARAM(wParam) / 100.f;
			if(m_fDistance < 3.0f) 
				m_fDistance = 3.0f;
		}
		break;
	}
}
Exemple #24
0
static void wheelscroll(struct table *t, WPARAM wParam)
{
	int delta;
	int lines;
	UINT scrollAmount;

	delta = GET_WHEEL_DELTA_WPARAM(wParam);
	if (SystemParametersInfoW(SPI_GETWHEELSCROLLLINES, 0, &scrollAmount, 0) == 0)
		abort();
	if (scrollAmount == WHEEL_PAGESCROLL)
		scrollAmount = t->pagesize;
	if (scrollAmount == 0)		// no mouse wheel scrolling (or t->pagesize == 0)
		return;
	// the rest of this is basically http://blogs.msdn.com/b/oldnewthing/archive/2003/08/07/54615.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/08/11/54624.aspx
	// see those pages for information on subtleties
	delta += t->wheelCarry;
	lines = delta * ((int) scrollAmount) / WHEEL_DELTA;
	t->wheelCarry = delta - lines * WHEEL_DELTA / ((int) scrollAmount);
	vscrollby(t, -lines);
}
Exemple #25
0
LRESULT CFilePreviewCtrl::OnMouseWheel(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
    if(m_PreviewMode!=PREVIEW_TEXT &&
            m_PreviewMode!=PREVIEW_HEX)
        return 0;

    int nDistance =  GET_WHEEL_DELTA_WPARAM(wParam)/WHEEL_DELTA;
    int nLinesPerDelta = m_nMaxLinesPerPage!=0?m_nVScrollMax/m_nMaxLinesPerPage:0;

    SCROLLINFO info;
    memset(&info, 0, sizeof(SCROLLINFO));
    info.cbSize = sizeof(SCROLLINFO);
    info.fMask = SIF_ALL;
    GetScrollInfo(SB_VERT, &info);
    info.nPos -=nDistance*nLinesPerDelta;
    SetScrollInfo(SB_VERT, &info, TRUE);

    SendMessage(WM_VSCROLL, MAKEWPARAM(SB_THUMBPOSITION, info.nPos), 0);
    return 0;
}
Exemple #26
0
void Engine::proccessEvent(UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_CLOSE:
        stop();
		break;
    case WM_MOUSEMOVE:
        onMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam);
	    break;
	case WM_MOUSELEAVE:
        onMouseLeave();
	    break;
	case WM_MOUSEWHEEL:
		onMouseWheel(GET_WHEEL_DELTA_WPARAM(wParam));
		break;
	case WM_KEYDOWN:
		onKeyDown(wParam);
	    break;
	}
}
LRESULT CALLBACK WndProc( HWND, UINT message, WPARAM wParam, LPARAM)
{
	switch (message)
	{
	case WM_MOUSEWHEEL:
		GET_WHEEL_DELTA_WPARAM(wParam);
		if (wParam > 0)
		{
			int i = 5;
		}
		else
		{
			int i = 6;
		}
		break;
	default:
		break;
	}

	return 0;
}
Exemple #28
0
static void wheelscroll(uiArea *a, int which, struct scrollParams *p, WPARAM wParam, LPARAM lParam)
{
	int delta;
	int lines;
	UINT scrollAmount;

	delta = GET_WHEEL_DELTA_WPARAM(wParam);
	if (SystemParametersInfoW(p->wheelSPIAction, 0, &scrollAmount, 0) == 0)
		// TODO use scrollAmount == 3 (for both v and h) instead?
		logLastError(L"error getting area wheel scroll amount");
	if (scrollAmount == WHEEL_PAGESCROLL)
		scrollAmount = p->pagesize;
	if (scrollAmount == 0)		// no mouse wheel scrolling (or t->pagesize == 0)
		return;
	// the rest of this is basically http://blogs.msdn.com/b/oldnewthing/archive/2003/08/07/54615.aspx and http://blogs.msdn.com/b/oldnewthing/archive/2003/08/11/54624.aspx
	// see those pages for information on subtleties
	delta += *(p->wheelCarry);
	lines = delta * ((int) scrollAmount) / WHEEL_DELTA;
	*(p->wheelCarry) = delta - lines * WHEEL_DELTA / ((int) scrollAmount);
	scrollby(a, which, p, -lines);
}
Exemple #29
0
void cCamera::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
	case WM_RBUTTONDOWN:
		SetCapture( hWnd );
		m_isLButtonDown = true;
		m_ptPrevMouse.x = LOWORD(lParam);
		m_ptPrevMouse.y = HIWORD(lParam);
		break;
	case WM_RBUTTONUP:
		ReleaseCapture( );
		m_isLButtonDown = false;
		break;
	case WM_MOUSEMOVE:
	{
		if (m_isLButtonDown)
		{
			POINT ptCurrMouse;
			ptCurrMouse.x = LOWORD(lParam);
			ptCurrMouse.y = HIWORD(lParam);
			m_fRotX += (ptCurrMouse.y - m_ptPrevMouse.y) / 100.0f;
			m_fRotY += (ptCurrMouse.x - m_ptPrevMouse.x) / 100.0f;
			m_ptPrevMouse = ptCurrMouse;
			if (m_fRotX >= D3DX_PI / 2.0f - EPSILON)
			{
				m_fRotX = D3DX_PI / 2.0f - EPSILON;
			}
			if (m_fRotX <= -D3DX_PI / 2.0f + EPSILON)
			{
				m_fRotX = -D3DX_PI / 2.0f + EPSILON;
			}
		}
	}
	break;
	case WM_MOUSEWHEEL:
		m_fDist -= GET_WHEEL_DELTA_WPARAM(wParam) / 10;
		break;
	}
}
/*
обработчик главного окна
*/
LRESULT __stdcall CWinMain::windowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	if( uMsg == WM_NCCREATE ) {
		SetWindowLong( hWnd, GWL_USERDATA, reinterpret_cast<LONG>( ( reinterpret_cast<CREATESTRUCT*>( lParam ) )->lpCreateParams ) );
	}
	CWinMain* wnd = reinterpret_cast<CWinMain*>( GetWindowLong( hWnd, GWL_USERDATA ) );

	switch( uMsg ) {
		case WM_REDACTOR_OK:
			wnd->TakeFormula();
			return 0;
		case WM_NCCREATE:
			wnd->timer = SetTimer( hWnd, 0, 10, 0 );
			break;
		case WM_CREATE:
			wnd->OnCreate( hWnd );
			return 0;
		case WM_SIZE:
			wnd->ResizeChildrens();
			return 0;
		case WM_DESTROY:
			wnd->OnDestroy();
			return 0;
		case WM_TIMER:
			wnd->Move();
			return 0;
		case WM_COMMAND:
			return wnd->OnCommand( wParam, lParam );
		case WM_KEYDOWN:
			return wnd->OnKeyDown( wParam, lParam );
		case WM_KEYUP:
			return wnd->OnKeyUp( wParam, lParam );
		case WM_MOUSEWHEEL:
			wnd->winPlotter.zoom( static_cast<LONG>( GET_WHEEL_DELTA_WPARAM( wParam ) ) );
			return 0;
	}

	return DefWindowProc( hWnd, uMsg, wParam, lParam );
}