//--------------------------------------------------------------------- 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); }
LRESULT WindowImplBase::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT lRes = 0; BOOL bHandled = TRUE; CPoint pt; switch (uMsg) { case WM_CREATE: lRes = OnCreate(uMsg, wParam, lParam, bHandled); break; case WM_CLOSE: lRes = OnClose(uMsg, wParam, lParam, bHandled); break; case WM_DESTROY: lRes = OnDestroy(uMsg, wParam, lParam, bHandled); break; #if defined(WIN32) && !defined(UNDER_CE) case WM_NCACTIVATE: lRes = OnNcActivate(uMsg, wParam, lParam, bHandled); break; case WM_NCCALCSIZE: lRes = OnNcCalcSize(uMsg, wParam, lParam, bHandled); break; case WM_NCPAINT: lRes = OnNcPaint(uMsg, wParam, lParam, bHandled); break; case WM_NCHITTEST: lRes = OnNcHitTest(uMsg, wParam, lParam, bHandled); break; case WM_GETMINMAXINFO: lRes = OnGetMinMaxInfo(uMsg, wParam, lParam, bHandled); break; case WM_MOUSEWHEEL: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnMouseWheel(uMsg,GET_KEYSTATE_WPARAM(wParam),GET_WHEEL_DELTA_WPARAM(wParam),pt,bHandled); break; } #endif case WM_SIZE: lRes = OnSize(uMsg, wParam, lParam, bHandled); break; case WM_CHAR: lRes = OnChar(uMsg, wParam, lParam, bHandled); break; case WM_SYSCOMMAND: lRes = OnSysCommand(uMsg, wParam, lParam, bHandled); break; case WM_KEYDOWN: { lRes = OnKeyDown( uMsg,wParam, lParam&0xff, lParam>>16 ,bHandled); break; } case WM_KEYUP: { lRes = OnKeyUp(uMsg, wParam, lParam&0xff, lParam>>16,bHandled ); break; } case WM_SYSKEYDOWN: { lRes=OnSysKeyDown(uMsg,wParam,lParam&0xff,lParam>>16,bHandled); break; } case WM_SYSKEYUP: { lRes=OnSysKeyUp(uMsg,wParam,lParam&0xff,lParam>>16,bHandled); break; } case WM_KILLFOCUS: lRes = OnKillFocus(uMsg, wParam, lParam, bHandled); break; case WM_SETFOCUS: lRes = OnSetFocus(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONUP: lRes = OnLButtonUp(uMsg, wParam, lParam, bHandled); break; case WM_LBUTTONDOWN: lRes = OnLButtonDown(uMsg, wParam, lParam, bHandled); break; case WM_RBUTTONDOWN: { lRes = OnRButtonDown(uMsg,wParam,lParam,bHandled); break; } case WM_RBUTTONUP: { lRes = OnRButtonUp(uMsg,wParam,lParam,bHandled); break; } case WM_MOUSEMOVE: { pt.x = GET_X_LPARAM( lParam ); pt.y = GET_Y_LPARAM( lParam ); lRes = OnMouseMove(uMsg, wParam, pt, bHandled); break; } case WM_MOUSEHOVER: { lRes = OnMouseHover(uMsg, wParam, lParam, bHandled); break; } #if(WINVER >= 0x0601) case WM_TOUCH: { UINT cInputs = LOWORD(wParam); HTOUCHINPUT hTouchInput=(HTOUCHINPUT)lParam; lRes = OnTouch(uMsg, cInputs, hTouchInput, bHandled); //If the application does not process the message, it must call DefWindowProc if (lRes==FALSE) { ::DefWindowProc(*this,uMsg,wParam,lParam); } break; } #endif #if(WINVER >= 0x0602) case WM_POINTERUP: { lRes = OnPointerUp(uMsg,wParam,lParam,bHandled); break; } case WM_POINTERDOWN: { lRes = OnPointerDown(uMsg,wParam,lParam,bHandled); break; } #endif default: { bHandled = FALSE; break; } } if (bHandled) { return lRes; } lRes = HandleCustomMessage(uMsg, wParam, lParam, bHandled); if(bHandled) { return lRes; } if (m_PaintManager.MessageHandler(uMsg, wParam, lParam, lRes)) { return lRes; } return CWindowWnd::HandleMessage(uMsg, wParam, lParam); }
void MouseReportParser::Parse(USBHID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf) { MOUSEINFO *pmi = (MOUSEINFO*)buf; // Future: // bool event; #if 0 if (prevState.mouseInfo.bmLeftButton == 0 && pmi->bmLeftButton == 1) OnLeftButtonDown(pmi); if (prevState.mouseInfo.bmLeftButton == 1 && pmi->bmLeftButton == 0) OnLeftButtonUp(pmi); if (prevState.mouseInfo.bmRightButton == 0 && pmi->bmRightButton == 1) OnRightButtonDown(pmi); if (prevState.mouseInfo.bmRightButton == 1 && pmi->bmRightButton == 0) OnRightButtonUp(pmi); if (prevState.mouseInfo.bmMiddleButton == 0 && pmi->bmMiddleButton == 1) OnMiddleButtonDown(pmi); if (prevState.mouseInfo.bmMiddleButton == 1 && pmi->bmMiddleButton == 0) OnMiddleButtonUp(pmi); if (prevState.mouseInfo.dX != pmi->dX || prevState.mouseInfo.dY != pmi->dY) OnMouseMove(pmi); if (len > sizeof (MOUSEINFO)) for (uint8_t i = 0; i<sizeof (MOUSEINFO); i++) prevState.bInfo[i] = buf[i]; #else // // Optimization idea: // // 1: Don't pass the structure on every event. Buttons would not need it. // 2: Only pass x/y values in the movement routine. // // These two changes (with the ones I have made) will save extra flash. // The only "bad" thing is that it could break old code. // // Future thoughts: // // The extra space gained can be used for a generic mouse event that can be called // when there are _ANY_ changes. This one you _MAY_ want to pass everything, however the // sketch could already have noted these facts to support drag/drop scroll wheel stuff, etc. // // Why do we need to pass the structure for buttons? // The function call not enough of a hint for what is happening? if(prevState.mouseInfo.bmLeftButton != pmi->bmLeftButton ) { if(pmi->bmLeftButton) { OnLeftButtonDown(pmi); } else { OnLeftButtonUp(pmi); } // Future: // event = true; } if(prevState.mouseInfo.bmRightButton != pmi->bmRightButton) { if(pmi->bmRightButton) { OnRightButtonDown(pmi); } else { OnRightButtonUp(pmi); } // Future: // event = true; } if(prevState.mouseInfo.bmMiddleButton != pmi->bmMiddleButton) { if(pmi->bmMiddleButton) { OnMiddleButtonDown(pmi); } else { OnMiddleButtonUp(pmi); } // Future: // event = true; } // // Scroll wheel(s), are not part of the spec, but we could support it. // Logitech wireless keyboard and mouse combo reports scroll wheel in byte 4 // We wouldn't even need to save this information. //if(len > 3) { //} // // Mice only report motion when they actually move! // Why not just pass the x/y values to simplify things?? if(pmi->dX || pmi->dY) { OnMouseMove(pmi); // Future: // event = true; } // // Future: // Provide a callback that operates on the gathered events from above. // // if(event) OnMouse(); // // Only the first byte matters (buttons). We do NOT need to save position info. prevState.bInfo[0] = buf[0]; #endif };
LRESULT Window::OnMessage(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: OnCreate(); return 0; case WM_DESTROY: OnDestroy(); return 0; case WM_CLOSE: if (OnClose()) /* true returned: message was handled */ return 0; break; case WM_SIZE: OnResize(LOWORD(lParam), HIWORD(lParam)); return 0; case WM_MOUSEMOVE: if (OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam)) return 0; break; case WM_LBUTTONDOWN: if (OnMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_LBUTTONUP: if (OnMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_LBUTTONDBLCLK: if (!double_clicks) /* instead of disabling CS_DBLCLKS (which would affect all instances of a window class), we just translate WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for built-in window class such as BUTTON */ return OnMessage(_hWnd, WM_LBUTTONDOWN, wParam, lParam); if (OnMouseDouble(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; #ifdef WM_MOUSEWHEEL case WM_MOUSEWHEEL: if (OnMouseWheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), GET_WHEEL_DELTA_WPARAM(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; #endif case WM_KEYDOWN: if (OnKeyDown(wParam)) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_KEYUP: if (OnKeyUp(wParam)) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_COMMAND: if (OnCommand(LOWORD(wParam), HIWORD(wParam))) { /* true returned: message was handled */ ResetDisplayTimeOut(); return 0; } break; case WM_CANCELMODE: if (OnCancelMode()) return 0; break; case WM_SETFOCUS: OnSetFocus(); /* pass on to DefWindowProc() so the underlying window class knows it's focused */ break; case WM_KILLFOCUS: OnKillFocus(); /* pass on to DefWindowProc() so the underlying window class knows it's not focused anymore */ break; case WM_TIMER: if (OnTimer(*(WindowTimer *)wParam)) return 0; break; case WM_PAINT: if (custom_painting) { PaintCanvas canvas(*this); OnPaint(canvas, canvas.get_dirty()); return 0; } break; case WM_GETDLGCODE: if (OnKeyCheck(wParam)) return DLGC_WANTMESSAGE; break; } if (message >= WM_USER && message <= 0x7FFF && OnUser(message - WM_USER)) return 0; return OnUnhandledMessage(_hWnd, message, wParam, lParam); }
LRESULT GenericWindow::HandleMessage (UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_MOUSEMOVE: if (!m_flagMouseTracking) { // register for mouse out message (TME_LEAVE) TRACKMOUSEEVENT trackMouseEvent; trackMouseEvent.cbSize = sizeof (trackMouseEvent); trackMouseEvent.dwFlags = TME_LEAVE; trackMouseEvent.dwHoverTime = 0; trackMouseEvent.hwndTrack = GetHandle (); m_flagMouseTracking = ::TrackMouseEvent (&trackMouseEvent); } OnMouseMove (0, -1, LOWORD(lParam), HIWORD(lParam)); break; case WM_MOUSELEAVE: OnMouseLeave (); m_flagMouseTracking = FALSE; break; case WM_LBUTTONDOWN: OnMouseDown (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONUP: OnMouseUp (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONDOWN: OnMouseDown (0, 1, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONUP: OnMouseUp (0, 1, LOWORD(lParam), HIWORD(lParam)); OnContextMenu ( ); break; case WM_ERASEBKGND: // we'll erase the background during the WM_PAINT message as necessary // to support dynamic background color for views // return FALSE to indicate we didn't erase the background here. return FALSE; case WM_PAINT: { PAINTSTRUCT ps; HDC hdc = ::BeginPaint (m_hWnd, &ps); // erase the background if required if (ps.fErase) { OnEraseBackground (hdc, ps); ps.fErase = FALSE; } OnPaint (hdc, ps); ::EndPaint (m_hWnd, &ps); } break; case WM_CHAR: OnKeyPress ( (int)wParam, LOWORD(lParam) ); break; case WM_KEYDOWN: OnKeyDown ( (int)wParam ); break; case WM_KEYUP: OnKeyUp ( (int)wParam ); break; case WM_NCDESTROY: OnPreDestroy (); m_hWnd = NULL; break; case WM_DESTROY: OnDestroy (); if (m_isMainWnd) { // ::MessageBox (0, _T("callling PostQuitMessage(0)"), _T(""), 0); ::PostQuitMessage (0); } break; case WM_SIZE: { int cx, cy; cx = LOWORD(lParam); cy = HIWORD(lParam); OnResize (cx, cy); } break; case WM_SETFOCUS: OnGotFocus (); break; case WM_KILLFOCUS: OnLostFocus (); break; case WM_COMMAND: OnCommand ( LOWORD(wParam) ); break; case WM_CONTEXTMENU: OnContextMenu ( ); break; case WM_CLOSE: { BOOL cancel = FALSE; OnClose (cancel); if (cancel == FALSE) DestroyWindow (m_hWnd); } break; case WM_DROPFILES: OnDropFiles ((HDROP)wParam); break; default: return ::DefWindowProc (m_hWnd, msg, wParam, lParam); } return 0; }
void CXTPSkinObjectTrackBar::OnMouseLeave() { OnMouseMove(0, CPoint(-1, -1)); }
LRESULT CD3DApplication::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch( msg ) { // WM_ACTIVATE is sent when the window is activated or deactivated. // We pause the game when the window is deactivated and unpause it // when it becomes active. case WM_ACTIVATE: if( LOWORD(wParam) == WA_INACTIVE ) { mAppPaused = true; mTimer.Stop(); } else { mAppPaused = false; mTimer.Start(); } return 0; // WM_SIZE is sent when the user resizes the window. case WM_SIZE: // Save the new client area dimensions. mClientWidth = LOWORD(lParam); mClientHeight = HIWORD(lParam); if( md3dDevice ) { if( wParam == SIZE_MINIMIZED ) { mAppPaused = true; mMinimized = true; mMaximized = false; } else if( wParam == SIZE_MAXIMIZED ) { mAppPaused = false; mMinimized = false; mMaximized = true; OnResize(); } else if( wParam == SIZE_RESTORED ) { // Restoring from minimized state? if( mMinimized ) { mAppPaused = false; mMinimized = false; OnResize(); } // Restoring from maximized state? else if( mMaximized ) { mAppPaused = false; mMaximized = false; OnResize(); } else if( mResizing ) { // If user is dragging the resize bars, we do not resize // the buffers here because as the user continuously // drags the resize bars, a stream of WM_SIZE messages are // sent to the window, and it would be pointless (and slow) // to resize for each WM_SIZE message received from dragging // the resize bars. So instead, we reset after the user is // done resizing the window and releases the resize bars, which // sends a WM_EXITSIZEMOVE message. } else // API call such as SetWindowPos or mSwapChain->SetFullscreenState. { OnResize(); } } } return 0; // WM_EXITSIZEMOVE is sent when the user grabs the resize bars. case WM_ENTERSIZEMOVE: mAppPaused = true; mResizing = true; mTimer.Stop(); return 0; // WM_EXITSIZEMOVE is sent when the user releases the resize bars. // Here we reset everything based on the new window dimensions. case WM_EXITSIZEMOVE: mAppPaused = false; mResizing = false; mTimer.Start(); OnResize(); return 0; // WM_DESTROY is sent when the window is being destroyed. case WM_DESTROY: PostQuitMessage(0); return 0; // The WM_MENUCHAR message is sent when a menu is active and the user presses // a key that does not correspond to any mnemonic or accelerator key. case WM_MENUCHAR: // Don't beep when we alt-enter. return MAKELRESULT(0, MNC_CLOSE); // Catch this message so to prevent the window from becoming too small. case WM_GETMINMAXINFO: ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200; ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; return 0; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_MOUSEMOVE: OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; } return DefWindowProc(hwnd, msg, wParam, lParam); }
bool TopWindow::OnEvent(const SDL_Event &event) { switch (event.type) { Window *w; #if SDL_MAJOR_VERSION < 2 case SDL_VIDEOEXPOSE: invalidated = false; Expose(); return true; #endif case SDL_KEYDOWN: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; #if SDL_MAJOR_VERSION >= 2 return w->OnKeyDown(event.key.keysym.sym); #else return w->OnKeyDown(event.key.keysym.sym) || (event.key.keysym.unicode != 0 && w->OnCharacter(event.key.keysym.unicode)); #endif #if SDL_MAJOR_VERSION >= 2 case SDL_TEXTINPUT: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; if (*event.text.text) { std::pair<unsigned, const char *> next = NextUTF8(event.text.text); bool handled = w->OnCharacter(next.first); while (next.second) { next = NextUTF8(next.second); handled = w->OnCharacter(next.first) || handled; } return handled; } else return false; #endif case SDL_KEYUP: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; return w->OnKeyUp(event.key.keysym.sym); #ifdef HAVE_MULTI_TOUCH case SDL_FINGERDOWN: if (SDL_GetNumTouchFingers(event.tfinger.touchId) == 2) return OnMultiTouchDown(); else return false; case SDL_FINGERUP: if (SDL_GetNumTouchFingers(event.tfinger.touchId) == 1) return OnMultiTouchUp(); else return false; #endif case SDL_MOUSEMOTION: // XXX keys return OnMouseMove(event.motion.x, event.motion.y, 0); case SDL_MOUSEBUTTONDOWN: #if SDL_MAJOR_VERSION < 2 if (event.button.button == SDL_BUTTON_WHEELUP) return OnMouseWheel(event.button.x, event.button.y, 1); else if (event.button.button == SDL_BUTTON_WHEELDOWN) return OnMouseWheel(event.button.x, event.button.y, -1); #endif return double_click.Check(RasterPoint(event.button.x, event.button.y)) ? OnMouseDouble(event.button.x, event.button.y) : OnMouseDown(event.button.x, event.button.y); case SDL_MOUSEBUTTONUP: #if SDL_MAJOR_VERSION < 2 if (event.button.button == SDL_BUTTON_WHEELUP || event.button.button == SDL_BUTTON_WHEELDOWN) /* the wheel has already been handled in SDL_MOUSEBUTTONDOWN */ return false; #endif double_click.Moved(RasterPoint(event.button.x, event.button.y)); return OnMouseUp(event.button.x, event.button.y); case SDL_QUIT: return OnClose(); #if SDL_MAJOR_VERSION < 2 case SDL_VIDEORESIZE: Resize(event.resize.w, event.resize.h); return true; #endif #if SDL_MAJOR_VERSION >= 2 case SDL_MOUSEWHEEL: int x, y; SDL_GetMouseState(&x, &y); return OnMouseWheel(x, y, event.wheel.y); case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_RESIZED: Resize(event.window.data1, event.window.data2); return true; case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_MAXIMIZED: { SDL_Window* event_window = SDL_GetWindowFromID(event.window.windowID); if (event_window) { int w, h; SDL_GetWindowSize(event_window, &w, &h); if ((w >= 0) && (h >= 0)) { Resize(w, h); } } } return true; case SDL_WINDOWEVENT_EXPOSED: invalidated = false; Expose(); return true; } #endif } return false; }
LRESULT CALLBACK Window::WinMsgHandler(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CLOSE: if (OnClose()) return 0; break; case WM_DESTROY: OnDestroy(); break; case WM_SIZE: if(OnSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) return 0; break; case WM_SYSKEYDOWN: /* * http://msdn.microsoft.com/en-us/library/windows/desktop/ms646286(v=vs.85).aspx * Bit 29 of lParam : * The context code. The value is 1 if the ALT key is down while the key is pressed; it is 0 if the * WM_SYSKEYDOWN message is posted to the active window because no window has the keyboard focus. */ if(!((lParam>>29)&0x01)) { if(OnKeyDown(wParam)) return 0; } break; case WM_KEYDOWN: if(OnKeyDown(wParam)) return 0; break; case WM_KEYUP: if(OnKeyUp(wParam)) return 0; break; case WM_LBUTTONDBLCLK: if(OnLButtonDblClick((POINT){GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)})) return 0; break; case WM_MOUSEMOVE: if(OnMouseMove((POINT){GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)})) return 0; break; case WM_LBUTTONDOWN: if(OnLButtonDown((POINT){GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)})) return 0; break; case WM_LBUTTONUP: if(OnLButtonUp((POINT){GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)})) return 0; break; case WM_SETFOCUS: OnSetFocus(); break; case WM_KILLFOCUS: OnKillFocus(); break; case WM_CTLCOLORSTATIC: case WM_CTLCOLOREDIT: if(lParam) { Window * pChildWnd = Window::GetObjectFromWindow((HWND)lParam); if(pChildWnd) { HBRUSH hBrush = pChildWnd->OnCtlColor((HDC)wParam); if(hBrush) { return (LRESULT)hBrush; } } } break; case WM_TIMER: OnTimer(); break; default: break; } Window * pOwner = GetParent(); if(pOwner && pOwner->Notify(this, uMsg, wParam, lParam)) { return 0; } if(_OriginalWndProc) { return CallWindowProc(_OriginalWndProc, hWnd, uMsg, wParam, lParam); } return ::DefWindowProc(hWnd, uMsg, wParam, lParam); }
LRESULT GraphicsWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_CREATE: // Should be created before the first WM_PAINT message if (FAILED(D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory))) { return -1; // Fail CreateWindowEx. } DPIScale::Initialize(pFactory); SetTimer(m_hwnd, m_nTimerID, 1000, NULL); return 0; case WM_DESTROY: KillTimer(m_hwnd, m_nTimerID); DiscardGraphicsResources(); SafeRelease(&pFactory); break; case WM_TIMER: InvalidateRect(m_hwnd, NULL, FALSE); // allow the clock faces to cycle the second hand break; case WM_PAINT: OnPaint(); return 0; case WM_LBUTTONDOWN: OnLButtonDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (DWORD)wParam); return 0; case WM_LBUTTONUP: OnLButtonUp(); return 0; case WM_MOUSEMOVE: OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), (DWORD)wParam); return 0; case WM_SIZE: Resize(); return 0; case WM_COMMAND: // We've received an accelerator command switch (LOWORD(wParam)) { case ID_DRAW_MODE: SetMode(DrawMode); break; case ID_SELECT_MODE: SetMode(SelectMode); break; case ID_TOGGLE_MODE: if (mode == DrawMode) { SetMode(SelectMode); } else { SetMode(DrawMode); } break; case ID_MOVE_UP: MoveSelectionUp(); break; case ID_MOVE_DOWN: MoveSelectionDown(); break; case ID_DELETE: DeleteSelection(); break; } return 0; case WM_SETCURSOR: // The mouse is back on our window, maintain the cursor display we had before if (LOWORD(lParam) == HTCLIENT) { SetCursor(hCursor); return TRUE; } break; } return DefWindowProc(m_hwnd, uMsg, wParam, lParam); }
//----------------------------------------------- // MainDlgProc // Notice: dialog procedure // BOOL CALLBACK MainDlgProc (HWND hDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter LPARAM lParam ) // second message parameter { POINT pt; RECT rc; static bCapture = false; static HBITMAP hBmpCross; static HBITMAP hBmpBlank; switch (uMsg) { case WM_INITDIALOG: hStatic = ::GetDlgItem(hDlg,IDC_CAPTURE); hBmpCross = LoadBitmap (hInst, MAKEINTRESOURCE(IDB_CROSS)); hBmpBlank = LoadBitmap (hInst, MAKEINTRESOURCE(IDB_BLANK)); hCurCross = LoadCursor (hInst, MAKEINTRESOURCE(IDC_CROSS0)); hCurHot = LoadCursor (hInst, MAKEINTRESOURCE(IDC_CROSS1)); hCurNormal = LoadCursor (NULL, IDC_ARROW); return true; case WM_LBUTTONDOWN: pt.x = MAKEPOINTS(lParam).x; pt.y = MAKEPOINTS(lParam).y; ::ClientToScreen (hDlg, &pt); ::GetWindowRect(hStatic, &rc); if( ::PtInRect(&rc, pt) ) { ::SetCursor( hCurCross ); ::SendMessage (hStatic,STM_SETIMAGE,IMAGE_BITMAP,(long)hBmpBlank); ::SetCapture( hDlg ); bCapture = true; } break; case WM_LBUTTONUP: case WM_KILLFOCUS: if( bCapture ) { if( hWndOld ) HighlightWindow(hWndOld,FALSE); hWndOld = NULL; ::SetCursor( hCurNormal ); ::SendMessage (hStatic,STM_SETIMAGE,IMAGE_BITMAP,(long)hBmpCross); ::ReleaseCapture(); bCapture = false; } break; case WM_MOUSEMOVE: if (bCapture) { pt.x = MAKEPOINTS(lParam).x; pt.y = MAKEPOINTS(lParam).y; ::ClientToScreen (hDlg, &pt); OnMouseMove (hDlg, pt); } break; case WM_CTLCOLOREDIT: if (bOverPasswdEdit) { HDC hdc = (HDC) wParam; if (GetDlgItem (hDlg,IDC_EDIT3) == (HWND) lParam) { SetBkColor (hdc, RGB(255,255,160)); return (BOOL) brush; } } break; case WM_CLOSE: ::KillTimer (hDlg,100); ::EndDialog (hDlg, 0); return true; } return false; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: { HMENU hMenu = ::GetMenu(hWnd); HMENU hMenuShapes = ::GetSubMenu(hMenu, 1); ::CheckMenuRadioItem(hMenuShapes, ID_SHAPE_RECTANGLE, ID_SHAPE_CIRCLE, ID_SHAPE_RECTANGLE, MF_BYCOMMAND); } case WM_COMMAND: { int wmId = LOWORD(wParam); int wmEvent = HIWORD(wParam); bool isHandled = true; LRESULT lResult = OnCommand(hWnd, wmId, wmEvent, (HWND)lParam, isHandled); if (!isHandled) { lResult = DefWindowProc(hWnd, message, wParam, lParam); } return lResult; } break; case WM_CHAR: { if (VK_ESCAPE == wParam && isRubberBand) { isRubberBand = false; DrawRubberBand(hWnd); } } break; case WM_LBUTTONDOWN: { return OnLButtonDown(hWnd, (UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } break; case WM_MOUSEMOVE: { return OnMouseMove(hWnd, (UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } break; case WM_LBUTTONUP: { return OnLButtonUp(hWnd, (UINT)wParam, LOWORD(lParam), HIWORD(lParam)); } break; case WM_PAINT: { return OnPaint(hWnd); } break; case WM_DESTROY: { PostQuitMessage(0); return 0; } break; } //C: Exit. return DefWindowProc(hWnd, message, wParam, lParam); }
void CXTPSkinObjectHeader::OnMouseLeave() { OnMouseMove(0, CPoint(-1, -1)); }
UINT NervWindowHandler::OnMouseMoveMessage(WPARAM wParam, LPARAM lParam){ NervMouseEvent event{int(wParam), int(lParam)}; OnMouseMove(&event); return 0; }
//e.key.keysym.sym 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; } case SDL_WINDOWEVENT_FOCUS_LOST: { OnInputBlur(); break; } case SDL_WINDOWEVENT_SHOWN: { OnRestore(); break; } case SDL_WINDOWEVENT_HIDDEN: { OnMinimize(); break; } case SDL_WINDOWEVENT_RESIZED: { OnResize(Event->window.data1,Event->window.data2); break; } case SDL_WINDOWEVENT_EXPOSED: { OnExpose(); break; } } break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym, Event->key.keysym.mod, Event->key.keysym.mod); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym, Event->key.keysym.mod, 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; } } }
HRESULT GLWindow::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { if (bDummy) return DefWindowProc(m_hwnd, uMsg, wParam, lParam); int ll = (int)(short)LOWORD(lParam); int hl = (int)(short)HIWORD(lParam); OnMessage(uMsg, wParam, lParam); switch(uMsg) { case WM_CREATE: initRC(); OnCreate(); return 0; case WM_PAINT: this->Redraw(); ValidateRect(m_hwnd, NULL); return 0; case WM_SIZE: OnSize(ll, hl); return 0; case WM_LBUTTONDOWN: OnMouseDown(MouseButton::LBUTTON, ll, hl); SetCapture(m_hwnd); return 0; case WM_MBUTTONDOWN: OnMouseDown(MouseButton::MBUTTON, ll, hl); SetCapture(m_hwnd); return 0; case WM_RBUTTONDOWN: OnMouseDown(MouseButton::RBUTTON, ll, hl); SetCapture(m_hwnd); return 0; case WM_LBUTTONUP: OnMouseUp(MouseButton::LBUTTON, ll, hl); ReleaseCapture(); return 0; case WM_MBUTTONUP: OnMouseUp(MouseButton::MBUTTON, ll, hl); ReleaseCapture(); return 0; case WM_RBUTTONUP: OnMouseUp(MouseButton::RBUTTON, ll, hl); ReleaseCapture(); return 0; case WM_LBUTTONDBLCLK: OnMouseDblClick(MouseButton::LBUTTON, ll, hl); return 0; case WM_MBUTTONDBLCLK: OnMouseDblClick(MouseButton::MBUTTON, ll, hl); return 0; case WM_RBUTTONDBLCLK: OnMouseDblClick(MouseButton::RBUTTON, ll, hl); return 0; case WM_MOUSEMOVE: OnMouseMove(wParam, ll, hl); return 0; case WM_MOUSEWHEEL: OnMouseWheel(HIWORD(wParam), LOWORD(wParam), ll, hl); return 0; case WM_KEYDOWN: OnKeyDown(wParam); return 0; case WM_KEYUP: OnKeyUp(wParam); return 0; case WM_CHAR: OnChar(wParam); return 0; case WM_TIMER: OnTimer(); return 0; case WM_ACTIVATE: { WORD active = LOWORD(wParam); if (active == WA_INACTIVE) { if (bFullScreen) { ShowWindow(m_hwnd, SW_SHOWMINIMIZED); ChangeDisplaySettings(NULL, 0); } } else { SetFocus(m_hwnd); if (bFullScreen) changeDisplaySettings(); } return 0; } case WM_DESTROY: OnDestroy(); delete m_rc; ReleaseDC(m_hwnd, m_hdc); return 0; } return DefWindowProc(m_hwnd, uMsg, wParam, lParam); }
void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { 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_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: { OnMouseWheel(Event->wheel.x, Event->wheel.y); 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_WINDOWEVENT: // window events switch (Event->window.event) { case SDL_WINDOWEVENT_RESIZED: OnResize(Event->window.windowID, Event->window.data1, Event->window.data2); break; case SDL_WINDOWEVENT_EXPOSED: // required redraw OnExpose(); break; case SDL_WINDOWEVENT_ENTER: // mouse gained focus OnMouseFocus(); break; case SDL_WINDOWEVENT_LEAVE: // mouse lost focus OnMouseBlur(); break; case SDL_WINDOWEVENT_FOCUS_GAINED: // gained kyobord focus OnInputFocus(); break; case SDL_WINDOWEVENT_FOCUS_LOST: // lost keyboard focus OnInputBlur(); break; case SDL_WINDOWEVENT_MINIMIZED: OnMinimize(); break; case SDL_WINDOWEVENT_RESTORED: OnRestore(); break; default: break; } break; default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
bool CUIWindow::OnMouse(float x, float y, EUIMessages mouse_action) { Frect wndRect = GetWndRect(); cursor_pos.x = x; cursor_pos.y = y; if( WINDOW_LBUTTON_DOWN == mouse_action ) { static u32 _last_db_click_frame = 0; u32 dwCurTime = Device.dwTimeContinual; if( (_last_db_click_frame!=Device.dwFrame) && (dwCurTime-m_dwLastClickTime < DOUBLE_CLICK_TIME) ) { mouse_action = WINDOW_LBUTTON_DB_CLICK; _last_db_click_frame = Device.dwFrame; } m_dwLastClickTime = dwCurTime; } if(GetParent()== NULL) { if(!wndRect.in(cursor_pos)) return false; //получить координаты относительно окна cursor_pos.x -= wndRect.left; cursor_pos.y -= wndRect.top; } //если есть дочернее окно,захватившее мышь, то //сообщение направляем ему сразу if(m_pMouseCapturer) { m_pMouseCapturer->OnMouse(cursor_pos.x - m_pMouseCapturer->GetWndRect().left, cursor_pos.y - m_pMouseCapturer->GetWndRect().top, mouse_action); return true; } // handle any action switch (mouse_action){ case WINDOW_MOUSE_MOVE: OnMouseMove(); break; case WINDOW_MOUSE_WHEEL_DOWN: OnMouseScroll(WINDOW_MOUSE_WHEEL_DOWN); break; case WINDOW_MOUSE_WHEEL_UP: OnMouseScroll(WINDOW_MOUSE_WHEEL_UP); break; case WINDOW_LBUTTON_DOWN: if(OnMouseDown(MOUSE_1)) return true; break; case WINDOW_RBUTTON_DOWN: if(OnMouseDown(MOUSE_2)) return true; break; case WINDOW_CBUTTON_DOWN: if(OnMouseDown(MOUSE_3)) return true; break; case WINDOW_LBUTTON_DB_CLICK: if (OnDbClick()) return true; break; default: break; } //Проверка на попадание мыши в окно, //происходит в обратном порядке, чем рисование окон //(последние в списке имеют высший приоритет) WINDOW_LIST::reverse_iterator it = m_ChildWndList.rbegin(); for(; it!=m_ChildWndList.rend(); ++it) { CUIWindow* w = (*it); Frect wndRect = w->GetWndRect(); if (wndRect.in(cursor_pos) ) { if(w->IsEnabled()) { if( w->OnMouse(cursor_pos.x -w->GetWndRect().left, cursor_pos.y -w->GetWndRect().top, mouse_action))return true; } } else if (w->IsEnabled() && w->CursorOverWindow()) { if( w->OnMouse(cursor_pos.x -w->GetWndRect().left, cursor_pos.y -w->GetWndRect().top, mouse_action))return true; } } return false; }
//============================================================================== 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; } } }
//*********************************************************************************************************** BOOL CBCGPBaseVisualCtrl::PreTranslateMessage(MSG* pMsg) { switch (pMsg->message) { case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_NCLBUTTONDOWN: case WM_NCRBUTTONDOWN: case WM_NCMBUTTONDOWN: case WM_NCLBUTTONUP: case WM_NCRBUTTONUP: case WM_NCMBUTTONUP: case WM_MOUSEMOVE: if (m_pToolTip->GetSafeHwnd () != NULL) { m_pToolTip->RelayEvent(pMsg); } } switch (pMsg->message) { case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: if (pMsg->hwnd == GetSafeHwnd()) { if (!m_bIsPopup) { SetFocus(); } CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); if (OnMouseDown(pMsg->message == WM_LBUTTONDOWN ? 0 : pMsg->message == WM_RBUTTONDOWN ? 1 : 2, pt)) { #if !defined _BCGPCHART_STANDALONE if (CBCGPPopupMenu::GetActiveMenu() != NULL && ::IsWindow (CBCGPPopupMenu::GetActiveMenu()->m_hWnd)) { CBCGPPopupMenu::GetActiveMenu()->SendMessage (WM_CLOSE); } #endif SetCapture(); m_bIsCaptured = TRUE; StartClickAndHold(); return TRUE; } } break; case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: if (pMsg->hwnd == GetSafeHwnd()) { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); OnMouseUp(pMsg->message == WM_LBUTTONUP ? 0 : pMsg->message == WM_RBUTTONUP ? 1 : 2, pt); if (m_bIsCaptured) { ReleaseCapture(); m_bIsCaptured = FALSE; } StopClickAndHold(); } break; case WM_LBUTTONDBLCLK: case WM_RBUTTONDBLCLK: case WM_MBUTTONDBLCLK: if (pMsg->hwnd == GetSafeHwnd()) { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); OnMouseDblClick(pMsg->message == WM_LBUTTONDBLCLK ? 0 : pMsg->message == WM_RBUTTONDBLCLK ? 1 : 2, pt); } break; case WM_MOUSEWHEEL: { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); CWnd* pWnd = CWnd::FromHandle (pMsg->hwnd); if (pWnd != NULL) { pWnd->ScreenToClient(&pt); } if (OnMouseWheel(pt, HIWORD(pMsg->wParam))) { if (m_pToolTip->GetSafeHwnd () != NULL) { m_pToolTip->Pop(); } return TRUE; } } break; case WM_MOUSEMOVE: { CPoint pt (BCG_GET_X_LPARAM(pMsg->lParam), BCG_GET_Y_LPARAM(pMsg->lParam)); OnMouseMove(pt); if (!m_bIsTracked) { m_bIsTracked = TRUE; TRACKMOUSEEVENT trackmouseevent; trackmouseevent.cbSize = sizeof(trackmouseevent); trackmouseevent.dwFlags = TME_LEAVE; trackmouseevent.hwndTrack = GetSafeHwnd(); trackmouseevent.dwHoverTime = HOVER_DEFAULT; ::BCGPTrackMouse (&trackmouseevent); } if (m_pToolTip->GetSafeHwnd () != NULL) { CString strToolTip; CString strDescr; OnGetToolTip(pt, strToolTip, strDescr); if (strToolTip != m_strLastDisplayedToolTip || strDescr != m_strLastDisplayedToolTipDescr) { if (m_bTooltipTrackingMode) { m_pToolTip->Update(); } else { m_pToolTip->Pop (); } if (!strToolTip.IsEmpty() && !strDescr.IsEmpty()) { m_bToolTipCleared = TRUE; } } } } break; case WM_CANCELMODE: if (m_bIsCaptured) { ReleaseCapture(); m_bIsCaptured = FALSE; OnCancelMode(); } StopClickAndHold(); break; case WM_KEYDOWN: if (pMsg->wParam == VK_ESCAPE) { if (OnKeyboardDown((UINT)pMsg->wParam, (pMsg->lParam & 0xFFFF), 0)) { return TRUE; } } break; case WM_TIMER: if (pMsg->hwnd == GetSafeHwnd() && pMsg->wParam == GetClickAndHoldID()) { CPoint point; ::GetCursorPos (&point); ScreenToClient (&point); if (GetClickAndHoldRect().PtInRect(point)) { OnClickAndHoldEvent(GetClickAndHoldID(), point); return TRUE; } } break; } return CStatic::PreTranslateMessage(pMsg); }
void AEEngine::i_OnMouseMove(int *param) { if(this->OnMouseMove!=NULL) OnMouseMove(param); }
bool TopWindow::OnEvent(const Event &event) { switch (event.type) { Window *w; case Event::NOP: case Event::USER: case Event::CALLBACK: break; case Event::CLOSE: OnClose(); break; case Event::KEY_DOWN: w = GetFocusedWindow(); if (w == nullptr) w = this; return w->OnKeyDown(event.param); case Event::KEY_UP: w = GetFocusedWindow(); if (w == nullptr) w = this; return w->OnKeyUp(event.param); case Event::MOUSE_MOTION: #ifdef DRAW_MOUSE_CURSOR /* redraw to update the mouse cursor position */ Invalidate(); #endif // XXX keys return OnMouseMove(event.point, 0); case Event::MOUSE_DOWN: return double_click.Check(event.point) ? OnMouseDouble(event.point) : OnMouseDown(event.point); case Event::MOUSE_UP: double_click.Moved(event.point); return OnMouseUp(event.point); case Event::MOUSE_WHEEL: return OnMouseWheel(event.point, (int)event.param); #ifdef USE_X11 case Event::RESIZE: if (screen->CheckResize(PixelSize(event.point.x, event.point.y))) Resize(screen->GetSize()); return true; case Event::EXPOSE: Invalidate(); return true; #endif } return false; }
void CTTToeView::OnTimer(UINT nFlags) { if(nFlags == TMR_FIELD_ID){ field->updateCells(); } else if (nFlags == TMR_MENU_ID){ menu->timerTicked(); menu->displayUpdated(); } else if(nFlags == TMR_MAIN_ID){ if(gameStatus != -2){ if(moveQueued){ moveMade = false; aiThinking = true; aiThread = AfxBeginThread(makeAIMove, &vicCombStartEnd); moveQueued = false; } if(moveMade){ getMainFrame()->setStPlayersMove(); getMainFrame()->resetAIPerc(); getMainFrame()->setMoveNum(field->getMovesMade()); moveMade = false; aiThinking = false; if(gameStatus != -1){ if(aiMove.getIsValid()){ field->aIPlayed(aiMove); } vicAnimFirstTime = true; OnMouseMove(0,CPoint(0,0)); bool prevValue = settings.showtrack; settings.showtrack = true; if(gameStatus == RateField::ST_AI_WON){ gameStatus = -2; getMainFrame()->setAIScr(++aiVictoryNumber); MessageBox(L"Sorry, you have lost..."); } else if(gameStatus == RateField::ST_PLAYER_WON){ gameStatus = -2; getMainFrame()->setPlayerScr(++playerVicNumber); MessageBox(L"Congratulations, you have won!"); } else{ gameStatus = -1; getMainFrame()->setDrawScr(++drawNumber); MessageBox(L"Draw!"); } settings.showtrack = prevValue; gameStatus = -1; field->resetCellModes(); getMainFrame()->setMoveNum(field->getMovesMade()); field->display(false,false,false,false); } else{ lastMove = aiMove; field->aIPlayed(lastMove); } } } } else if(nFlags == TMR_MENU_ACT_SEQ_ID){ processMenuActions(); KillTimer(TMR_MENU_ACT_SEQ_ID); } else if(nFlags == TMR_WINNING_COMB_ID){ if(gameStatus == -2){ animateWinningCombination(); } } else if(nFlags == TMR_STATUS_BAR_ID){ if(aiThinking){ getMainFrame()->updateStAIThinking(); getMainFrame()->setAIPerc(field->getAIPercent()); } } else if(nFlags == TMR_TEST_ID){ if(cnt == 0){ } else{ testProperty = false; char* a = new char[20]; _itoa(cnt, a, 10); cnt = 0; CString str(a); MessageBox(str); } } CView::OnTimer(nFlags); }
bool TopWindow::OnEvent(const SDL_Event &event) { switch (event.type) { Window *w; #if SDL_MAJOR_VERSION < 2 case SDL_VIDEOEXPOSE: invalidated = false; Expose(); return true; #endif case SDL_KEYDOWN: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; #if SDL_MAJOR_VERSION >= 2 return w->OnKeyDown(event.key.keysym.sym); #else return w->OnKeyDown(event.key.keysym.sym) || (event.key.keysym.unicode != 0 && w->OnCharacter(event.key.keysym.unicode)); #endif #if SDL_MAJOR_VERSION >= 2 case SDL_TEXTINPUT: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; if (*event.text.text) { std::pair<unsigned, const char *> next = NextUTF8(event.text.text); bool handled = w->OnCharacter(next.first); while (next.second) { next = NextUTF8(next.second); handled = w->OnCharacter(next.first) || handled; } return handled; } else return false; #endif case SDL_KEYUP: w = GetFocusedWindow(); if (w == nullptr) w = this; if (!w->IsEnabled()) return false; return w->OnKeyUp(event.key.keysym.sym); #ifdef HAVE_MULTI_TOUCH case SDL_FINGERDOWN: if (SDL_GetNumTouchFingers(event.tfinger.touchId) == 2) return OnMultiTouchDown(); else return false; case SDL_FINGERUP: if (SDL_GetNumTouchFingers(event.tfinger.touchId) == 1) return OnMultiTouchUp(); else return false; #endif case SDL_MOUSEMOTION: // XXX keys #ifdef HAVE_HIGHDPI_SUPPORT { auto x = event.motion.x; auto y = event.motion.y; PointToReal(x, y); return OnMouseMove(x, y, 0); } #else return OnMouseMove(event.motion.x, event.motion.y, 0); #endif case SDL_MOUSEBUTTONDOWN: { #if SDL_MAJOR_VERSION < 2 if (event.button.button == SDL_BUTTON_WHEELUP) return OnMouseWheel(event.button.x, event.button.y, 1); else if (event.button.button == SDL_BUTTON_WHEELDOWN) return OnMouseWheel(event.button.x, event.button.y, -1); #endif #ifdef HAVE_HIGHDPI_SUPPORT auto x = event.button.x; auto y = event.button.y; PointToReal(x, y); return double_click.Check(RasterPoint(x, y)) ? OnMouseDouble(x, y) : OnMouseDown(x, y); #else return double_click.Check(RasterPoint(event.button.x, event.button.y)) ? OnMouseDouble(event.button.x, event.button.y) : OnMouseDown(event.button.x, event.button.y); #endif } case SDL_MOUSEBUTTONUP: { #if SDL_MAJOR_VERSION < 2 if (event.button.button == SDL_BUTTON_WHEELUP || event.button.button == SDL_BUTTON_WHEELDOWN) /* the wheel has already been handled in SDL_MOUSEBUTTONDOWN */ return false; #endif #ifdef HAVE_HIGHDPI_SUPPORT auto x = event.button.x; auto y = event.button.y; PointToReal(x, y); double_click.Moved(RasterPoint(x, y)); return OnMouseUp(x, y); #else double_click.Moved(RasterPoint(event.button.x, event.button.y)); return OnMouseUp(event.button.x, event.button.y); #endif } case SDL_QUIT: return OnClose(); #if SDL_MAJOR_VERSION < 2 case SDL_VIDEORESIZE: Resize(event.resize.w, event.resize.h); return true; #endif #if SDL_MAJOR_VERSION >= 2 case SDL_MOUSEWHEEL: { int x, y; SDL_GetMouseState(&x, &y); #ifdef HAVE_HIGHDPI_SUPPORT PointToReal(x, y); #endif return OnMouseWheel(x, y, event.wheel.y); } case SDL_WINDOWEVENT: switch (event.window.event) { case SDL_WINDOWEVENT_RESIZED: #ifndef HAVE_HIGHDPI_SUPPORT Resize(event.window.data1, event.window.data2); return true; #endif case SDL_WINDOWEVENT_RESTORED: case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_SHOWN: case SDL_WINDOWEVENT_MAXIMIZED: { SDL_Window* event_window = SDL_GetWindowFromID(event.window.windowID); if (event_window) { int w, h; SDL_GetWindowSize(event_window, &w, &h); if ((w >= 0) && (h >= 0)) { #ifdef HAVE_HIGHDPI_SUPPORT int real_w, real_h; SDL_GL_GetDrawableSize(event_window, &real_w, &real_h); point_to_real_x = static_cast<float>(real_w) / static_cast<float>(w); point_to_real_y = static_cast<float>(real_h) / static_cast<float>(h); Resize(real_w, real_h); #else Resize(w, h); #endif } #if defined(__MACOSX__) && __MACOSX__ SDL_SysWMinfo *wm_info = reinterpret_cast<SDL_SysWMinfo *>(alloca(sizeof(SDL_SysWMinfo))); SDL_VERSION(&wm_info->version); if ((SDL_GetWindowWMInfo(event_window, wm_info)) && (wm_info->subsystem == SDL_SYSWM_COCOA)) { [wm_info->info.cocoa.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary]; } Invalidate(); #endif } } return true; case SDL_WINDOWEVENT_EXPOSED: invalidated = false; Expose(); return true; } #endif }
INT_PTR GenericWindow::HandleDialogMessage (UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_MOUSEMOVE: if (!m_flagMouseTracking) { // register for mouse out message (TME_LEAVE) TRACKMOUSEEVENT trackMouseEvent; trackMouseEvent.cbSize = sizeof (trackMouseEvent); trackMouseEvent.dwFlags = TME_LEAVE; trackMouseEvent.dwHoverTime = 0; trackMouseEvent.hwndTrack = GetHandle (); m_flagMouseTracking = ::TrackMouseEvent (&trackMouseEvent); } OnMouseMove (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_MOUSELEAVE: OnMouseLeave (); m_flagMouseTracking = FALSE; break; case WM_LBUTTONDOWN: OnMouseDown (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_LBUTTONUP: OnMouseUp (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONDOWN: OnMouseDown (0, 0, LOWORD(lParam), HIWORD(lParam)); break; case WM_RBUTTONUP: OnMouseUp (0, 0, LOWORD(lParam), HIWORD(lParam)); OnContextMenu ( ); break; case WM_CHAR: OnKeyPress ( (int)wParam, LOWORD(lParam) ); break; case WM_KEYDOWN: OnKeyDown ( (int)wParam ); break; case WM_NCDESTROY: OnPreDestroy (); m_hWnd = NULL; break; case WM_DESTROY: OnDestroy (); break; case WM_SIZE: { int cx, cy; cx = LOWORD(lParam); cy = HIWORD(lParam); OnResize (cx, cy); } break; case WM_SETFOCUS: OnGotFocus (); break; case WM_KILLFOCUS: OnLostFocus (); break; case WM_COMMAND: OnCommand ( LOWORD(wParam) ); break; case WM_CONTEXTMENU: OnContextMenu ( ); break; default: return FALSE; } return TRUE; }
//============================================================================== 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; } } }
bool TextViewBase::HandleWndProc(UINT msg, WPARAM wParam, LPARAM lParam, LONG *pResult) { HIMC hIMC = NULL; switch (msg) { // Draw contents of TextView whenever window needs updating case WM_ERASEBKGND: *pResult = 1; return true; // Need to custom-draw the border for XP/Vista themes case WM_NCPAINT: *pResult = OnNcPaint((HRGN)wParam); return true; case WM_PAINT: *pResult = OnPaint(); return true; // Set a new font case WM_SETFONT: *pResult = OnSetFont((HFONT)wParam); return true; case WM_SIZE: *pResult = OnSize(wParam, LOWORD(lParam), HIWORD(lParam)); return true; case WM_VSCROLL: *pResult = OnVScroll(LOWORD(wParam), HIWORD(wParam)); return true; case WM_HSCROLL: *pResult = OnHScroll(LOWORD(wParam), HIWORD(wParam)); return true; case WM_MOUSEACTIVATE: *pResult = OnMouseActivate((HWND)wParam, LOWORD(lParam), HIWORD(lParam)); return true; //case WM_CONTEXTMENU: // return OnContextMenu((HWND)wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); case WM_MOUSEWHEEL: if (IsKeyPressed(VK_CONTROL)) return false; else *pResult = OnMouseWheel((short)HIWORD(wParam)); return true; case WM_SETFOCUS: *pResult = OnSetFocus((HWND)wParam); return true; case WM_KILLFOCUS: *pResult = OnKillFocus((HWND)wParam); return true; // make sure we get arrow-keys, enter, tab, etc when hosted inside a dialog case WM_GETDLGCODE: *pResult = DLGC_WANTALLKEYS;//DLGC_WANTMESSAGE;//DLGC_WANTARROWS; return true; case WM_LBUTTONDOWN: *pResult = OnLButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_LBUTTONUP: *pResult = OnLButtonUp(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_LBUTTONDBLCLK: *pResult = OnLButtonDblClick(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_RBUTTONDOWN: *pResult = OnRButtonDown(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_MOUSEMOVE: *pResult = OnMouseMove(wParam, (short)LOWORD(lParam), (short)HIWORD(lParam)); return true; case WM_KEYDOWN: *pResult = OnKeyDown(wParam, lParam); return true; case WM_UNDO: case TXM_UNDO: case EM_UNDO: *pResult = Undo(); return true; case TXM_REDO : case EM_REDO: *pResult = Redo(); return true; case TXM_CANUNDO: case EM_CANUNDO: *pResult = CanUndo(); return true; case TXM_CANREDO: case EM_CANREDO: *pResult = CanRedo(); return true; case WM_CHAR: OutputDebugString(L"WM_CHAR\n"); *pResult = OnChar(wParam, lParam); return true; case WM_SETCURSOR: if (LOWORD(lParam) == HTCLIENT) { *pResult = TRUE; return true; } else return false; case WM_COPY: *pResult = OnCopy(); return true; case WM_CUT: *pResult = OnCut(); return true; case WM_PASTE: *pResult = OnPaste(); return true; case WM_CLEAR: *pResult = OnClear(); return true; case WM_GETTEXT: *pResult = GetText((WCHAR*)lParam, 0, (ULONG)wParam); return true; case WM_SETTEXT: *pResult = OnSetText((WCHAR*)lParam, lstrlen((WCHAR*)lParam)); return true; //case TXM_SETTEXT: // { // ClearFile(); // EnterText((WCHAR*)lParam, (LONG)wParam); // return 0; // } case WM_TIMER: *pResult = OnTimer(wParam); return true; case WM_IME_STARTCOMPOSITION: OutputDebugString(L"WM_IME_STARTCOMPOSITION\n"); *pResult = OnStartComposition(wParam, lParam); return true; //return DefWindowProc(m_hWnd, WM_IME_STARTCOMPOSITION, wParam, lParam); case WM_IME_COMPOSITION: OutputDebugString(L"WM_IME_COMPOSITION\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_COMPOSITION, wParam, lParam); return true; //return OnComposition(wParam, lParam); case WM_IME_ENDCOMPOSITION: OutputDebugString(L"WM_IME_ENDCOMPOSITION\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_ENDCOMPOSITION, wParam, lParam); return true; //return OnEndComposition(wParam, lParam); case WM_IME_CHAR: OutputDebugString(L"WM_IME_CHAR\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_CHAR, wParam, lParam); return true; case WM_IME_CONTROL: OutputDebugString(L"WM_IME_CONTROL\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_CONTROL, wParam, lParam); return true; case WM_IME_NOTIFY: OutputDebugString(L"WM_IME_NOTIFY\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_NOTIFY, wParam, lParam); return true; //return HandleImeNotify(wParam, lParam); case WM_IME_REQUEST: OutputDebugString(L"WM_IME_REQUEST\n"); *pResult = DefWindowProc(m_hWnd, WM_IME_REQUEST, wParam, lParam); return true; case WM_INPUTLANGCHANGE: *pResult = OnInputLanChange(wParam, lParam); return true; case TXM_PRINT: *pResult = OnPrint((HDC)wParam, (int)lParam); return true; // case TXM_OPENFILE: *pResult = OpenFile((TCHAR *)lParam); return true; case TXM_SAVEFILE: *pResult = SaveFile((TCHAR *)lParam); return true; case TXM_IMPORTFILE: *pResult = ImportFile((TCHAR *)lParam, (int)wParam); return true; case TXM_EXPORTFILE: { int convertype = LOWORD(wParam); int utf_type = HIWORD(wParam); *pResult = ExportFile((TCHAR *)lParam, convertype, utf_type); return true; } case TXM_CLEAR: *pResult = ClearFile(); return true; case TXM_GETFORMAT: *pResult = m_pTextDoc->getformat(); return true; case TXM_SETFORMAT: *pResult = m_pTextDoc->setformat((int)wParam); return true; case TXM_GETSELSIZE: *pResult = SelectionSize(); return true; case TXM_SETSELALL: *pResult = SelectAll(); return true; case TXM_GETCURPOS: *pResult = m_CurrentCharPos.get(); return true; case TXM_GETCURLINE_D: *pResult = m_nCurrentLine_D; return true; case TXM_GETCURLINE_V: *pResult = OnGetCurLineV(); return true; case TXM_GETCURCOL: *pResult = OnGetCurCol(); return true; case TXM_GETEDITMODE: *pResult = m_nEditMode; return true; case TXM_SETEDITMODE: lParam = m_nEditMode; m_nEditMode = wParam; *pResult = lParam; return true; case TXM_FIND_INIT: FindInitial((WCHAR*)lParam); *pResult = 0; return true; case TXM_FIND: { BOOL m = (BOOL)LOWORD(wParam); BOOL b = (BOOL)HIWORD(wParam); //FindText() if (b) *pResult = FindBackward(m, NULL); else *pResult = FindForward(m, NULL); return true; } case TXM_FIND_TEXT: { FIND_OPTION* fp = (FIND_OPTION*)(lParam); *pResult = Find_Text(fp->text, lstrlen(fp->text), fp->fBackward, fp->fMachCase, fp->fWarp); return true; } case TXM_REPLACE_TEXT: { *pResult = Replace_Text((REPLACE_OPTION*)(lParam)); return true; } case TXM_SETRESMODULE: { *pResult = OnSetResModule((HMODULE)lParam); return true; } case WM_GETTEXTLENGTH: case TXM_GETTEXTLEN: { *pResult = OnGetTextLen(); return true; } case TXM_REPLACE: { BOOL ra = (BOOL)LOWORD(wParam); WORD mb = (WORD)HIWORD(wParam); BOOL m = (BOOL)LOBYTE(mb); BOOL b = (BOOL)HIBYTE(mb); if (b) *pResult = FindBackward(m, (WCHAR*)lParam, ra); else *pResult = FindForward(m, (WCHAR*)lParam, ra); return true; } case TXM_FIND_GETTEXTLENGTH: *pResult = m_pFndIterator->find_text_length(); return true; case TXM_GETSELSTART: *pResult = m_nSelectionStart; return true; case TXM_GETSELEND: *pResult = m_nSelectionEnd; return true; case TXM_GETSELTEXT: *pResult = OnGetSelText((WCHAR*)wParam, ULONG(lParam)); return true; case TXM_SETTESTERMODE: OnTesterMode((bool)wParam); *pResult = 0; return true; case TXM_SETCONTEXTMENU: m_hUserMenu = (HMENU)wParam; *pResult = 0; return true; case TXM_STATISTIC: *pResult = OnDoStatistic((STATISTIC*)(lParam)); return true; case TXM_GETCONVERTTYPES: *pResult = OnGetConvertTypes((convert_type*)(lParam)); return true; case EM_GETSEL: *pResult = OnMsg_EM_GETSEL((ULONG*)wParam, (ULONG*)lParam); return true; case EM_SETSEL: *pResult = OnMsg_EM_SETSEL((LONG)wParam, (LONG)lParam); return true; default: return false; } }
LRESULT D3D11App::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { // WM_ACTIVATE is sent when the window is activated or deactivated. // We pause the game when the window is deactivated and unpause it // when it becomes active. case WM_ACTIVATE: /* if (LOWORD(wParam) == WA_INACTIVE) { mAppPaused = true; mTimer.Stop(); } else { mAppPaused = false; mTimer.Start(); }*/ return 0; // WM_SIZE is sent when the user resizes the window. case WM_SIZE: // Save the new client area dimensions. mClientWidth = LOWORD(lParam); mClientHeight = HIWORD(lParam); if (SwapChainPtr->GetState()) { if (wParam == SIZE_MINIMIZED) { mAppPaused = true; mMinimized = true; mMaximized = false; } else if (wParam == SIZE_MAXIMIZED) { mAppPaused = false; mMinimized = false; mMaximized = true; OnResize(); } else if (wParam == SIZE_RESTORED) { // Restoring from minimized state? if (mMinimized) { mAppPaused = false; mMinimized = false; OnResize(); } // Restoring from maximized state? else if (mMaximized) { mAppPaused = false; mMaximized = false; OnResize(); } else if (mResizing) { // If user is dragging the resize bars, we do not resize // the buffers here because as the user continuously // drags the resize bars, a stream of WM_SIZE messages are // sent to the window, and it would be pointless (and slow) // to resize for each WM_SIZE message received from dragging // the resize bars. So instead, we reset after the user is // done resizing the window and releases the resize bars, which // sends a WM_EXITSIZEMOVE message. } else // API call such as SetWindowPos or mSwapChain->SetFullscreenState. { OnResize(); } } } return 0; // WM_EXITSIZEMOVE is sent when the user grabs the resize bars. case WM_ENTERSIZEMOVE: mAppPaused = true; mResizing = true; mTimer.Stop(); mClientWidthOld = mClientWidth; mClientHeightOld = mClientHeight; return 0; // WM_EXITSIZEMOVE is sent when the user releases the resize bars. // Here we reset everything based on the new window dimensions. case WM_EXITSIZEMOVE: mAppPaused = false; mResizing = false; mTimer.Start(); if ((mClientWidthOld != mClientWidth) && (mClientHeightOld!= mClientHeight)) { OnResize(); } return 0; /* case WM_PAINT: hDC = BeginPaint(hwnd, &paintStruct); EndPaint(hwnd, &paintStruct); break;*/ // Catch this message so to prevent the window from becoming too small. case WM_GETMINMAXINFO: ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 200; ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 200; return 0; case WM_DESTROY: PostQuitMessage(0); break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: OnMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: OnMouseUp(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_MOUSEMOVE: OnMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; case WM_MOUSEWHEEL: { short zDelta = (short)HIWORD(wParam); OnMouseWheel(zDelta, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; } case WM_LBUTTONDBLCLK: OnLButtonDblClk(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); return 0; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
void Event::OnEvent(SDL_Event * e) { switch(e->type) { case SDL_ACTIVEEVENT: { switch(e->active.state) { case SDL_APPMOUSEFOCUS: { if ( e->active.gain ) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( e->active.gain ) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( e->active.gain ) OnRestore(); else OnMinimize(); break; } } break; } case SDL_KEYDOWN: { OnKeyDown(e->key.keysym.sym,e->key.keysym.mod,e->key.keysym.unicode); break; } case SDL_KEYUP: { OnKeyUp(e->key.keysym.sym,e->key.keysym.mod,e->key.keysym.unicode); break; } case SDL_MOUSEMOTION: { OnMouseMove(e->motion.x,e->motion.y,e->motion.xrel,e->motion.yrel,(e->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(e->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(e->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(e->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(e->button.x,e->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(e->button.x,e->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(e->button.x,e->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(e->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(e->button.x,e->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(e->button.x,e->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(e->button.x,e->button.y); break; } } break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } case SDL_VIDEORESIZE: { OnResize(e->resize.w,e->resize.h); break; } case SDL_VIDEOEXPOSE: { OnExpose(); break; } default: { OnUser(e->user.type,e->user.code,e->user.data1,e->user.data2); break; } } }
////////////////// // Handle mousemove: enter DRAGGING state. // BOOL CDragDropMgr::OnMouseMove(const MSG& msg) { if (!IsCaptured()) return FALSE; BOOL bLButtonDown = (GetKeyState(VK_LBUTTON) & 0x8000); BOOL bRButtonDown = (GetKeyState(VK_RBUTTON) & 0x8000); // check mouse button is still down if (!bLButtonDown && !bRButtonDown) { SetState(NONE); return FALSE; } CWnd* pWnd = CWnd::FromHandle(m_hwndTracking); CPoint pt = GETPOINT(msg.lParam); if (IsDragging()) { // already dragging: move drag image pWnd->ClientToScreen(&pt); // convert to screen coords // get new target window if any m_ddi.pt = pt; m_pMainWnd->ScreenToClient(&m_ddi.pt); // convert to main window coords HWND hwndTarget = ::ChildWindowFromPoint(*m_pMainWnd, m_ddi.pt); if (hwndTarget) { m_pMainWnd->ClientToScreen(&m_ddi.pt); // back to screen ScreenToClient(hwndTarget, &m_ddi.pt); // then to target client coords } else m_ddi.pt.x = m_ddi.pt.y = -10000; m_ddi.hwndTarget = hwndTarget; // m_ddi.pt is current pos in client coords of current target window SendDragMessage(WM_DD_PREDRAGMOVE); // now move drag image m_pDragImage->DragMove(pt); // update ui UINT nDropEffect = SendDragMessage(WM_DD_DRAGOVER); // set the cursor if (!(m_ddi.hwndTarget && IsTargetWnd(m_ddi.hwndTarget))) nDropEffect = DROPEFFECT_NONE; HCURSOR hCur = NULL; if (!m_hInstOle32) m_hInstOle32 = LoadLibrary(_T("Ole32.dll")); switch (nDropEffect) { case DD_DROPEFFECT_COPY: hCur = LoadCursor(m_hInstOle32, MAKEINTRESOURCE(3)); break; case DD_DROPEFFECT_MOVE: hCur = LoadCursor(m_hInstOle32, MAKEINTRESOURCE(2)); break; case DD_DROPEFFECT_LINK: hCur = LoadCursor(m_hInstOle32, MAKEINTRESOURCE(4)); break; case DD_DROPEFFECT_NONE: default: hCur = LoadCursor(m_hInstOle32, MAKEINTRESOURCE(1)); break; } if (hCur) SetCursor(hCur); } else // if (IsCaptured()) { // Not dragging yet: enter drag mode if mouse moves beyond threshhold. CPoint delta = pt - m_ptOrg; static CPoint jog(GetSystemMetrics(SM_CXDRAG), GetSystemMetrics(SM_CYDRAG)); if (abs(delta.x) > jog.x || abs(delta.y) > jog.y) { m_ddi.hwndSource = m_hwndTracking; m_ddi.pt = m_ptOrg; // start from ORIGINAL point, not where now m_ddi.hwndTarget = m_hwndTracking; m_ddi.pData = NULL; m_ddi.bLeftDrag = bLButtonDown; // Send main window a message: enter drag mode. BOOL bDrag = SendDragMessage(WM_DD_DRAGENTER); if (bDrag && m_ddi.pData) { SetState(bLButtonDown ? LDRAGGING : RDRAGGING); // I am now dragging OnMouseMove(msg); CRect rc; m_pDragImage = m_ddi.pData->CreateDragImage(pWnd, rc); m_pDragImage->BeginDrag(0, rc.BottomRight()); pWnd->ClientToScreen(&pt); m_pDragImage->DragEnter(NULL, pt); } else SetState(NONE); } } return TRUE; }