void SDLWrapper::HandleMouseButtonUpEvents( SDL_Event* event ) { switch( event->button.button ) { case SDL_BUTTON_LEFT: OnLButtonUp( event->button.x, event->button.y ); break; case SDL_BUTTON_RIGHT: OnRButtonUp(event->button.x, event->button.y); break; case SDL_BUTTON_MIDDLE: OnMButtonUp(event->button.x, event->button.y); break; } }
//--------------------------------------------------------------------------- void CFabAtHomeView::OnMButtonDown(UINT nFlags, CPoint point) //--------------------------------------------------------------------------- {// Start 3D rolling // ASSERT(!bRolling); if (bRolling) OnMButtonUp(nFlags, point); CFabAtHomeApp *pApp = (CFabAtHomeApp *) AfxGetApp(); bRolling = TRUE; startPoint = point; memcpy(rotmat0, rotmat, 16*sizeof(GLdouble)); // initialize rolling matrix SetCursor(pApp->hHandCursor); SetCapture(); CView::OnMButtonDown(nFlags, point); }
LRESULT cOpenGLControl::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SETFOCUS: case WM_KILLFOCUS: case WM_ENABLE: Update(); break; case WM_SIZING: case WM_SIZE: UpdateSize(); OnSize(); Update(); break; case WM_PAINT: Paint(); return FALSE; case WM_ERASEBKGND: return TRUE; case WM_MOUSEMOVE: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); if (!bMouseIn) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE | TME_HOVER; tme.hwndTrack = hwnd; tme.dwHoverTime = HOVER_DEFAULT; ::TrackMouseEvent(&tme); OnMouseIn(); bMouseIn = true; } cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnMouseMove(x, y, modifiers); } break; case WM_MOUSELEAVE: if (bMouseIn) { OnMouseOut(); bMouseIn = false; } break; case WM_MOUSEHOVER: if (bMouseIn) { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnMouseHover(x, y, modifiers); // Reset the track mouse event TRACKMOUSEEVENT tme; tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_LEAVE | TME_HOVER; tme.hwndTrack = hwnd; tme.dwHoverTime = HOVER_DEFAULT; ::TrackMouseEvent(&tme); } break; case WM_LBUTTONDOWN: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnLButtonDown(x, y, modifiers); break; } case WM_LBUTTONUP: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnLButtonUp(x, y, modifiers); break; } case WM_RBUTTONDOWN: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnRButtonDown(x, y, modifiers); break; } case WM_RBUTTONUP: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnRButtonUp(x, y, modifiers); break; } case WM_MBUTTONDOWN: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnMButtonDown(x, y, modifiers); break; } case WM_MBUTTONUP: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnMButtonUp(x, y, modifiers); break; } case WM_LBUTTONDBLCLK: { const int x = int((short)LOWORD(lParam)); const int y = int((short)HIWORD(lParam)); cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnDoubleClick(x, y, modifiers); break; } case WM_MOUSEWHEEL: { POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); if (::ScreenToClient(hwnd, &pt) == TRUE) { cKeyModifiers modifiers; GetModifiersForMouseEvent(modifiers, wParam); OnMouseWheel(pt.x, pt.y, short(HIWORD(wParam)), modifiers); } break; } case WM_KEYDOWN: case WM_SYSKEYDOWN: if ((lParam & 0x40000000) == 0) { cKeyEvent event; event.key = wParam; event.modifiers.bControl = ((::GetKeyState(VK_CONTROL) & 0x8000) != 0); event.modifiers.bAlt = ((::GetKeyState(VK_MENU) & 0x8000) != 0); event.modifiers.bShift = ((::GetKeyState(VK_SHIFT) & 0x8000) != 0); OnKeyDown(event); } break; case WM_KEYUP: case WM_SYSKEYUP: if ((lParam & 0x40000000) == 0) { cKeyEvent event; event.key = wParam; event.modifiers.bControl = ((::GetKeyState(VK_CONTROL) & 0x8000) != 0); event.modifiers.bAlt = ((::GetKeyState(VK_MENU) & 0x8000) != 0); event.modifiers.bShift = ((::GetKeyState(VK_SHIFT) & 0x8000) != 0); OnKeyUp(event); } break; } return DefWindowProc(hwnd, uMsg, wParam, lParam); }
void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_ACTIVEEVENT: { switch(Event->active.state) { case SDL_APPMOUSEFOCUS: { if ( Event->active.gain ) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( Event->active.gain ) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( Event->active.gain ) OnRestore(); else OnMinimize(); break; } } break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } case SDL_VIDEORESIZE: { OnResize(Event->resize.w,Event->resize.h); break; } case SDL_VIDEOEXPOSE: { OnExpose(); break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
INT_PTR CMessageForwarder::ForwardMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { m_hwnd = hwnd; m_uMsg = uMsg; m_wParam = wParam; m_lParam = lParam; /* Private message? */ if(uMsg > WM_APP && uMsg < 0xBFFF) { return OnPrivateMessage(uMsg,wParam,lParam); } switch(uMsg) { case WM_INITDIALOG: return OnInitDialog(); break; case WM_CTLCOLORSTATIC: return OnCtlColorStatic(reinterpret_cast<HWND>(lParam), reinterpret_cast<HDC>(wParam)); break; case WM_CTLCOLOREDIT: return OnCtlColorEdit(reinterpret_cast<HWND>(lParam), reinterpret_cast<HDC>(wParam)); break; case WM_HSCROLL: return OnHScroll(reinterpret_cast<HWND>(lParam)); break; case WM_APPCOMMAND: return OnAppCommand(reinterpret_cast<HWND>(wParam), GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); break; case WM_TIMER: return OnTimer(static_cast<int>(wParam)); break; case WM_MBUTTONUP: return OnMButtonUp(&MAKEPOINTS(lParam)); break; case WM_COMMAND: return OnCommand(wParam,lParam); break; case WM_NOTIFY: return OnNotify(reinterpret_cast<LPNMHDR>(lParam)); break; case WM_GETMINMAXINFO: return OnGetMinMaxInfo(reinterpret_cast<LPMINMAXINFO>(lParam)); break; case WM_SIZE: return OnSize(static_cast<int>(wParam), LOWORD(lParam),HIWORD(lParam)); break; case WM_CLOSE: return OnClose(); break; case WM_DESTROY: return OnDestroy(); break; case WM_NCDESTROY: return OnNcDestroy(); break; case EM_SETSEL: OnEMSetSel(wParam,lParam); break; } return GetDefaultReturnValue(hwnd,uMsg,wParam,lParam); }
void Gevents::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); OnLButtonDown(Event->button.x, Event->button.y, Event->key.keysym.mod); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
void Event::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_TEXTINPUT: { OnTextEdit(Event->text.text); break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEWHEEL: { if(Event->wheel.y > 0) { OnMouseWheel(true, false); } else { OnMouseWheel(false, true); } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
LRESULT KItemEventMgr::EventItemProc(UINT uMsg, WPARAM wParam, LPARAM lParam) { float fX = (float)(GET_X_LPARAM(lParam)); float fY = (float)(GET_Y_LPARAM(lParam)); switch(uMsg) { case WM_LBUTTONDOWN: OnMouseEnterOrLeave(fX, fY, false); return OnLButtonDown(fX, fY); case WM_LBUTTONUP: OnMouseEnterOrLeave(fX, fY, false); return OnLButtonUp(fX, fY); case WM_LBUTTONDBLCLK: OnMouseEnterOrLeave(fX, fY, false); return OnLButtonDBClick(fX, fY); case WM_RBUTTONDOWN: OnMouseEnterOrLeave(fX, fY, false); return OnRButtonDown(fX, fY); case WM_RBUTTONUP: OnMouseEnterOrLeave(fX, fY, false); return OnRButtonUp(fX, fY); case WM_RBUTTONDBLCLK: OnMouseEnterOrLeave(fX, fY, false); return OnRButtonDBClick(fX, fY); case WM_MBUTTONDOWN: OnMouseEnterOrLeave(fX, fY, false); return OnMButtonDown(fX, fY); case WM_MBUTTONUP: OnMouseEnterOrLeave(fX, fY, false); return OnMButtonUp(fX, fY); case WM_MBUTTONDBLCLK: OnMouseEnterOrLeave(fX, fY, false); return OnMButtonDBClick(fX, fY); case WM_MOUSEHOVER: OnMouseEnterOrLeave(fX, fY, false); return OnMouseHover(fX, fY); case WM_MOUSEMOVE: OnMouseEnterOrLeave(fX, fY, false); return OnMouseMove(fX, fY); case WND_M_MOUSE_ENTER: { int nX = 0; int nY = 0; g_pUI->m_Pointer.GetCursorPos(nX, nY); fX = (float)nX; fY = (float)nY; OnMouseEnterOrLeave(fX, fY, false); } break; case WND_M_REFRESH_TIP: if (m_pLastMouseOverItem) { g_pUI->m_Script.FireItemEvent(m_pLastMouseOverItem, "OnItemRefreshTip"); } break; case WND_M_MOUSE_LEAVE: OnMouseEnterOrLeave(0.0f, 0.0f, true); break; case WM_MOUSEWHEEL: { OnMouseEnterOrLeave(fX, fY, false); int nRet = OnFireMouseWheelEvent(-(GET_Y_LPARAM(wParam)) / WHEEL_DELTA, fX, fY); OnMouseEnterOrLeave(fX, fY, false); return nRet; } break; case WM_KEYDOWN: case WM_SYSKEYDOWN: return OnFireKeyDownEvent(wParam); break; case WM_KEYUP: case WM_SYSKEYUP: return OnFireKeyUpEvent(wParam); break; } return FALSE; }
void wxFrameworkGLCanvas::OnRButtonUp(wxMouseEvent &event) { //same code as middle up OnMButtonUp(event); }
void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { /* case SDL_ACTIVEEVENT: { switch(Event->active.state) { case SDL_APPMOUSEFOCUS: { if ( Event->active.gain) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( Event->active.gain) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( Event->active.gain) OnRestore(); else OnMinimize(); break; } } break; } */ case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.scancode); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.scancode); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } //case SDL_VIDEORESIZE: { // OnResize(Event->resize.w,Event->resize.h); // break; //} //case SDL_VIDEOEXPOSE: { // OnExpose(); // break; //} default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
//-------------------------------------------------------------------------------- bool CPointerController::ProcessMessage( COSWindow& Window, Cmp_long_ptr& lResult, unsigned int uMsg, Cmp_uint_ptr wParam, Cmp_long_ptr lParam ) { _WINQ_FCONTEXT( "CPointerController::ProcessMessage" ); bool bProcessed = ProcessHook( Window, lResult, uMsg, wParam, lParam ); switch ( uMsg ) { case COSWindow::wmMouseMove: { OnMouseMove( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmLButtonDown: { OnLButtonDown( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmLButtonUp: { OnLButtonUp( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmLButtonDblClk: { OnLButtonDblClk( Window, wParam, lParam ); lResult = 0; bProcessed= true; } break; case COSWindow::wmRButtonDown: { OnRButtonDown( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmRButtonUp: { OnRButtonUp( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmRButtonDblClk: { OnRButtonDblClk( Window, wParam, lParam ); lResult = 0; bProcessed= true; } break; case COSWindow::wmMButtonDown: { OnMButtonDown( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmMButtonUp: { OnMButtonUp( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmMButtonDblClk: { OnMButtonDblClk( Window, wParam, lParam ); lResult = 0; bProcessed= true; } break; #if (_WIN32_WINNT >= 0x0400) || (_WIN32_WINDOWS > 0x0400) case COSWindow::wmMouseWheel: { OnMouseWheel( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; #endif case COSWindow::wmCaptureChanged: { COSWindow::refType refWindow = COSWindow::FromHandle( CWindowHandle( 0, (void*)(lParam) ).Ref() ); OnCaptureChanged( Window, refWindow ); lResult = 0; bProcessed = true; } break; #if((_WIN32_WINNT >= 0x0400) || (WINVER >= 0x0500)) case COSWindow::wmMouseHover: { OnMouseHover( Window, wParam, lParam ); lResult = 0; bProcessed = true; } break; case COSWindow::wmMouseLeave: { OnMouseLeave( Window ); lResult = 0; bProcessed = true; } break; #endif } return bProcessed; }
bool CUIMainDialog::MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { // Mouse messages switch(uMsg) { case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: SetCapture(hWnd); break; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: ReleaseCapture(); break; } switch(uMsg) { case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_LBUTTONUP: case WM_MBUTTONDOWN: case WM_MBUTTONUP: case WM_RBUTTONDOWN: case WM_RBUTTONUP: case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_MOUSEWHEEL: { POINT mousePoint = { short(LOWORD(lParam)), short(HIWORD(lParam)) }; switch(uMsg) { case WM_LBUTTONDBLCLK: OnLButtonDblClk(mousePoint); break; case WM_LBUTTONDOWN: OnLButtonDown(mousePoint); break; case WM_LBUTTONUP: OnLButtonUp(mousePoint); break; case WM_RBUTTONDBLCLK: OnRButtonDblClk(mousePoint); break; case WM_RBUTTONDOWN: OnRButtonDown(mousePoint); break; case WM_RBUTTONUP: OnRButtonUp(mousePoint); break; case WM_MBUTTONDBLCLK: OnMButtonDblClk(mousePoint); break; case WM_MBUTTONDOWN: OnMButtonDown(mousePoint); break; case WM_MBUTTONUP: OnMButtonUp(mousePoint); break; case WM_MOUSEMOVE: OnMouseMove(mousePoint); break; case WM_MOUSEWHEEL: //GetCursorPos(&mousePoint); ::ScreenToClient(hWnd,&mousePoint); OnMouseWheel(mousePoint,(short) HIWORD(wParam)); break; } } break; } UISetHWND(hWnd); // Let the CUIIMEEditBox's static message proc handle the msg. // This is because some IME messages must be handled to ensure // proper functionalities and the static msg proc ensures that // this happens even if no control has the input focus. if(CIME::StaticMsgProc(uMsg, wParam, lParam)) { //return true; } switch(uMsg) { case WM_SIZE: { RECT rc= {0,0,LOWORD(lParam), HIWORD(lParam)}; OnSize(rc); } break; case WM_ACTIVATEAPP: // Call OnFocusIn()/OnFocusOut() of the control that currently has the focus // as the application is activated/deactivated. This matches the Windows // behavior. if(s_pControlFocus && s_pControlFocus->GetEnabled()) { if(wParam) s_pControlFocus->OnFocusIn(); else s_pControlFocus->OnFocusOut(); } break; // Keyboard messages case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_KEYUP: case WM_SYSKEYUP: { // If a control is in focus, it belongs to this dialog, and it's enabled, then give // it the first chance at handling the message. if(s_pControlFocus && s_pControlFocus->GetEnabled()) { if(s_pControlFocus->HandleKeyboard(uMsg, wParam, lParam)) return true; } } break; case WM_CAPTURECHANGED: { // The application has lost mouse capture. // The dialog object may not have received // a WM_MOUSEUP when capture changed. Reset // m_bDrag so that the dialog does not mistakenly // think the mouse button is still held down. // if((HWND)lParam != hWnd) // { // SetPressed(false); // } // break; } } // 含焦点的控件 要优先处理消息 跨dialog处理 if(s_pControlFocus && s_pControlFocus->GetEnabled()) { // If the control MsgProc handles it, then we don't. if(s_pControlFocus->MsgProc(uMsg, wParam, lParam)) return true; } if(CUIDialog::MsgProc(hWnd, uMsg, wParam, lParam)) { return true; } //ClearState(); return false; }
void CEvent::OnEvent(SDL_Event* Event) { switch (Event->type) { case SDL_WINDOWEVENT: { switch (Event->window.event) { case SDL_WINDOWEVENT_ENTER: { OnMouseFocus(); break; } case SDL_WINDOWEVENT_LEAVE: { OnMouseBlur(); break; } case SDL_WINDOWEVENT_FOCUS_GAINED: { OnInputFocus(); break; } //keyboard focus. What is keyboard focus? case SDL_WINDOWEVENT_FOCUS_LOST: { OnInputBlur(); break; } case SDL_WINDOWEVENT_RESTORED: { OnRestore(); break; } case SDL_WINDOWEVENT_MINIMIZED: { OnMinimize(); break; } case SDL_WINDOWEVENT_RESIZED: { OnResize(Event->window.data1, Event->window.data2); break; } case SDL_WINDOWEVENT_EXPOSED: { OnExpose(); break; } case SDL_WINDOWEVENT_CLOSE: { OnExit(); break; } } break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym, Event->key.keysym.mod); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym, Event->key.keysym.mod); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x, Event->motion.y, Event->motion.xrel, Event->motion.yrel, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0); break; } case SDL_MOUSEBUTTONDOWN: { switch (Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x, Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x, Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x, Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch (Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x, Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x, Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x, Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which, Event->jball.ball, Event->jball.xrel, Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which, Event->jhat.hat, Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which, Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which, Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } default: { OnUser(Event->user.type, Event->user.code, Event->user.data1, Event->user.data2); break; } } }
//============================================================================== void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_ACTIVEEVENT: { switch(Event->active.state) {//check to see what event has occured case SDL_APPMOUSEFOCUS: { if ( Event->active.gain ) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( Event->active.gain ) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( Event->active.gain ) OnRestore(); else OnMinimize(); break; } } break; } case SDL_KEYDOWN: {//on key down pass in what was pressed OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_KEYUP: {//on key up pass in what was depressed OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_MOUSEMOTION: {// OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: {//if the button on the mouse is pressed pass in its x and y switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: {//stuff we dont use OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: {//if SDL is quit then run the exit function OnExit(); break; } //more stufff we dont use case SDL_SYSWMEVENT: { //Ignore break; } case SDL_VIDEORESIZE: { OnResize(Event->resize.w,Event->resize.h); break; } case SDL_VIDEOEXPOSE: { OnExpose(); break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
//--------------------------------------------------------------------- LRESULT Window::WindowProcedure(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { #ifdef _DEBUG /* char buf[20]; sprintf(buf, "0x%x : ", hWnd); OutputDebugString(buf); */ PutWindowMessage(message, wParam, lParam); #endif if ( message==WM_CREATE ) { LPCREATESTRUCT pc = (LPCREATESTRUCT)lParam; Window* pw = (Window*)(pc->lpCreateParams); pw->mWnd = hWnd; ::SetWindowLong(hWnd, 0, (long)pw); bool b = pw->OnCreate(pc); gTaskbarCreatedMessage = ::RegisterWindowMessage(TEXT("TaskbarCreated")); return b ? 0 : -1; } // マウスホイール対応 if ( message == msgMOUSEWHEEL ) { message = WM_MOUSEWHEEL; DbgStr("MouseWheel fwKeys:%04x, zDelta:%d, xPos:%d, yPos:%d", LOWORD(wParam), (short)HIWORD(wParam), (short)LOWORD(lParam), (short)HIWORD(lParam) ); } Window* p=(Window*)(::GetWindowLong(hWnd, 0)); if ( p == NULL ) return ::DefWindowProc(hWnd, message, wParam, lParam); if ( message >= WM_USER && message <= 0x7FFF ) return p->OnUser(message, wParam, lParam); if ( message == gTaskbarCreatedMessage ) return p->OnTaskbarRestart(); switch ( message ) { case WM_PAINT: { PAINTSTRUCT thePS; HDC theDC = ::BeginPaint(hWnd, &thePS); if (theDC != NULL) { p->OnPaint(theDC); ::EndPaint(hWnd, &thePS); } } return 0; case WM_NCHITTEST: return p->OnNCHitTest(MAKEPOINT(lParam)); Handle(WM_ACTIVATE, OnActivate(LOWORD(wParam), HIWORD(wParam), (HWND)lParam)); Handle(WM_ACTIVATEAPP, OnActivateApp(BOOL(wParam), (DWORD)lParam)); Handle(WM_DISPLAYCHANGE, OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam)); /*case WM_DISPLAYCHANGE: p->OnDisplayChange(LOWORD(lParam), HIWORD(lParam), wParam); break;*/ Handle(WM_COMMAND, OnCommand(HIWORD(wParam), LOWORD(wParam), (HWND)lParam)); Handle(WM_INITMENU, OnInitMenu(HMENU(wParam))); Handle(WM_CLOSE, OnClose()); Handle(WM_DESTROY, OnDestroy()); Handle(MM_MCINOTIFY, OnMCINotify(WORD(wParam), LONG(lParam))); Handle(WM_LBUTTONDOWN, OnLButtonDown(MAKEPOINT(lParam), wParam)); Handle(WM_MBUTTONDOWN, OnMButtonDown(MAKEPOINT(lParam), wParam)); Handle(WM_RBUTTONDOWN, OnRButtonDown(MAKEPOINT(lParam), wParam)); Handle(WM_LBUTTONUP, OnLButtonUp(MAKEPOINT(lParam), wParam)); Handle(WM_MBUTTONUP, OnMButtonUp(MAKEPOINT(lParam), wParam)); Handle(WM_RBUTTONUP, OnRButtonUp(MAKEPOINT(lParam), wParam)); Handle(WM_LBUTTONDBLCLK, OnLButtonDoubleClick(MAKEPOINT(lParam), wParam)); Handle(WM_MBUTTONDBLCLK, OnMButtonDoubleClick(MAKEPOINT(lParam), wParam)); Handle(WM_RBUTTONDBLCLK, OnRButtonDoubleClick(MAKEPOINT(lParam), wParam)); Handle(WM_MOUSEMOVE, OnMouseMove(MAKEPOINT(lParam), wParam)); Handle(WM_MOUSEWHEEL, OnMouseWheel(LOWORD(wParam), (short)HIWORD(wParam), (short)LOWORD(lParam), (short)HIWORD(lParam))); Handle(WM_NCLBUTTONDBLCLK, OnNCLButtonDoubleClick(wParam, MAKEPOINT(lParam))); Handle(WM_KEYDOWN, OnKeyDown((int)wParam, (long)lParam)); Handle(WM_KEYUP, OnKeyUp((int)wParam, (long)lParam)); Handle(WM_DROPFILES, OnDropFiles(HDROP(wParam))); Handle(WM_TIMER, OnTimer(wParam, (TIMERPROC*)lParam)); Handle(WM_DRAWCLIPBOARD, OnDrawClipboard()); Handle(WM_CHANGECBCHAIN, OnChangeCBChain((HWND)wParam, (HWND)lParam)); default: break; } return ::DefWindowProc(hWnd, message, wParam, lParam); }