/* * @implemented */ BOOL WINAPI DragDetect( HWND hWnd, POINT pt) { return NtUserDragDetect(hWnd, pt); #if 0 MSG msg; RECT rect; POINT tmp; ULONG dx = GetSystemMetrics(SM_CXDRAG); ULONG dy = GetSystemMetrics(SM_CYDRAG); rect.left = pt.x - dx; rect.right = pt.x + dx; rect.top = pt.y - dy; rect.bottom = pt.y + dy; SetCapture(hWnd); for (;;) { while ( PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || PeekMessageW(&msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) ) { if (msg.message == WM_LBUTTONUP) { ReleaseCapture(); return FALSE; } if (msg.message == WM_MOUSEMOVE) { tmp.x = LOWORD(msg.lParam); tmp.y = HIWORD(msg.lParam); if (!PtInRect(&rect, tmp)) { ReleaseCapture(); return TRUE; } } if (msg.message == WM_KEYDOWN) { if (msg.wParam == VK_ESCAPE) { ReleaseCapture(); return TRUE; } } } WaitMessage(); } return 0; #endif }
static void waitonbutton() { int key = GetSystemMetrics(SM_SWAPBUTTON) ? VK_RBUTTON : VK_LBUTTON; if (GetAsyncKeyState(key) & 0x8000) { // double clicked MSG msg; while (GetAsyncKeyState(key) & 0x8000) PeekMessageW(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE); // pull extra mouseUp out of queue while (PeekMessageW(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE)) ; } // SMR 1880 clear shift/control state MCmodifierstate = MCscreen->querymods(); }
void AppMain() { AppInit(1280, 720, "silver-winner"); for (;;) { MSG msg; while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } if (g_App.bShouldClose) { break; } ImGui_ImplDX11_NewFrame(); RendererPaint(); } AppExit(); }
/** * \brief Dispatch incoming window events and handle them. * * This function should be placed inside libvo's function "check_events". * * \return int with these flags possibly set, take care to handle in the right order * if it matters in your driver: * * VO_EVENT_RESIZE = The window was resized. If necessary reinit your * driver render context accordingly. * VO_EVENT_EXPOSE = The window was exposed. Call e.g. flip_frame() to redraw * the window if the movie is paused. */ int vo_w32_check_events(struct vo *vo) { struct vo_w32_state *w32 = vo->w32; MSG msg; w32->event_flags = 0; while (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } if (vo->opts->WinID >= 0) { BOOL res; RECT r; POINT p; res = GetClientRect(w32->window, &r); if (res && (r.right != vo->dwidth || r.bottom != vo->dheight)) { vo->dwidth = r.right; vo->dheight = r.bottom; w32->event_flags |= VO_EVENT_RESIZE; } p.x = 0; p.y = 0; ClientToScreen(w32->window, &p); if (p.x != w32->window_x || p.y != w32->window_y) { w32->window_x = p.x; w32->window_y = p.y; } res = GetClientRect(WIN_ID_TO_HWND(vo->opts->WinID), &r); if (res && (r.right != vo->dwidth || r.bottom != vo->dheight)) MoveWindow(w32->window, 0, 0, r.right, r.bottom, FALSE); if (!IsWindow(WIN_ID_TO_HWND(vo->opts->WinID))) // Window has probably been closed, e.g. due to program crash mplayer_put_key(vo->key_fifo, MP_KEY_CLOSE_WIN); } return w32->event_flags; }
static gboolean check_msg_pending () { MSG msg; return PeekMessageW (&msg, NULL, 0, 0, PM_NOREMOVE) ? TRUE : FALSE; }
static void MZ_Launch( LPCSTR cmdtail, int length ) { TDB *pTask = GlobalLock16( GetCurrentTask() ); BYTE *psp_start = PTR_REAL_TO_LIN( DOSVM_psp, 0 ); DWORD rv; SYSLEVEL *lock; MSG msg; MZ_FillPSP(psp_start, cmdtail, length); pTask->flags |= TDBF_WINOLDAP; /* DTA is set to PSP:0080h when a program is started. */ pTask->dta = MAKESEGPTR( DOSVM_psp, 0x80 ); GetpWin16Lock( &lock ); _LeaveSysLevel( lock ); /* force the message queue to be created */ PeekMessageW(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); ResumeThread(dosvm_thread); rv = DOSVM_Loop(dosvm_thread); CloseHandle(dosvm_thread); dosvm_thread = 0; dosvm_tid = 0; CloseHandle(loop_thread); loop_thread = 0; loop_tid = 0; VGA_Clean(); ExitProcess(rv); }
static gboolean clutter_event_dispatch (GSource *source, GSourceFunc callback, gpointer user_data) { ClutterEvent *event; MSG msg; clutter_threads_enter (); /* Process Windows messages until we've got one that translates into the clutter event queue */ while (!clutter_events_pending () && PeekMessageW (&msg, NULL, 0, 0, PM_REMOVE)) DispatchMessageW (&msg); /* Pop an event off the queue if any */ if ((event = clutter_event_get ())) { /* forward the event into clutter for emission etc. */ clutter_do_event (event); clutter_event_free (event); } clutter_threads_leave (); return TRUE; }
static void pump_message_loop(void) { // We have a hidden window on this thread (for the OpenGL context,) so pump // its message loop at regular intervals to be safe MSG message; while (PeekMessageW(&message, NULL, 0, 0, PM_REMOVE)) DispatchMessageW(&message); }
//Handle all messages in the queue VOID WindowMessageDispatcher12::RunMessagePump() { MSG Message; while (PeekMessageW(&Message, m_Handle, 0, 0, PM_REMOVE) > 0) { TranslateMessage(&Message); DispatchMessageW(&Message); } }
void _glfwPlatformPollEvents(void) { MSG msg; _GLFWwindow* window; while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { if (msg.message == WM_QUIT) { // Treat WM_QUIT as a close on all windows // While GLFW does not itself post WM_QUIT, other processes may post // it to this one, for example Task Manager window = _glfw.windowListHead; while (window) { _glfwInputWindowCloseRequest(window); window = window->next; } } else { TranslateMessage(&msg); DispatchMessageW(&msg); } } window = _glfw.focusedWindow; if (window) { // LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix) // This is the only async event handling in GLFW, but it solves some // nasty problems { const int mods = getAsyncKeyMods(); // Get current state of left and right shift keys const int lshiftDown = (GetAsyncKeyState(VK_LSHIFT) >> 15) & 1; const int rshiftDown = (GetAsyncKeyState(VK_RSHIFT) >> 15) & 1; // See if this differs from our belief of what has happened // (we only have to check for lost key up events) if (!lshiftDown && window->keys[GLFW_KEY_LEFT_SHIFT] == 1) _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, 0, GLFW_RELEASE, mods); if (!rshiftDown && window->keys[GLFW_KEY_RIGHT_SHIFT] == 1) _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, 0, GLFW_RELEASE, mods); } // Did the cursor move in an focused window that has disabled the cursor if (window->cursorMode == GLFW_CURSOR_DISABLED) { int width, height; _glfwPlatformGetWindowSize(window, &width, &height); _glfwPlatformSetCursorPos(window, width / 2, height / 2); } } }
void OpenGLWindow::Impl::processEvents() { MSG message; while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&message); DispatchMessageW(&message); } }
// Static void SystemGUI::processEvents() { MSG message; // hwnd=NULL means all windows in the current thread while (PeekMessageW(&message, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&message); DispatchMessageW(&message); } }
void CEditToolApp::OnSysMsg(void) { MSG msg; while( PeekMessageW( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { if( !GetMessageW( &msg, NULL, 0, 0 ) ) GenErr( "GetMessage shouldn't return 0." ); TranslateMessage( &msg ); DispatchMessageW( &msg ); } }
int32_t WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int32_t nCmdShow) { Timer globalTimer; auto& window = Win_Window::GetInstance(); window.Createwindow(); window.SetUpOpenGL(); auto& game = Game::GetInstance(); game.Init("../Assets/GameInit.txt"); auto oldTime = globalTimer.GetGlobalTime(); MSG msg; int32_t frames = 0; float frameTimer = 0.0f; int32_t framesLastSecond = 0; while (window.IsRunning()) { if (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } globalTimer.ToggleTimer(); auto timeStamp = globalTimer.GetGlobalTime(); if ((timeStamp - oldTime) > TARGET_TIME) { float dt = (timeStamp - oldTime) * Timer::AreTimersRunning(); game.ProcessInput(dt); oldTime = timeStamp; game.Render(); if (frameTimer > 1.0f) { framesLastSecond = frames; frameTimer = 0.0f; frames = 0; } game.RenderText(std::to_string(framesLastSecond) + " FPS", glm::vec2(-WIDTH / 2.0f, -HEIGHT / 2.0f), 0.4f, glm::vec3(1.0f, 0.0f, 1.0f)); window.Swapwindow(); ++frames; } frameTimer += globalTimer.GetDeltaTime(); } return EXIT_SUCCESS; }
static void runMessagePump(DWORD timeoutMilliseconds) { DWORD startTickCount = GetTickCount(); MSG msg; BOOL result; while ((result = PeekMessageW(&msg, 0, 0, 0, PM_REMOVE)) && GetTickCount() - startTickCount <= timeoutMilliseconds) { if (result == -1) break; TranslateMessage(&msg); DispatchMessage(&msg); } }
bool GlProcessEvent(bool *quit) { MSG msg; if(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { if(msg.message == WM_QUIT && quit) *quit = true; TranslateMessage(&msg); DispatchMessageW(&msg); return true; } return false; }
static HRESULT start_binding(IMoniker *mon, Binding *binding_ctx, IUri *uri, IBindCtx *pbc, BOOL to_obj, REFIID riid, Binding **ret) { Binding *binding = NULL; HRESULT hres; MSG msg; hres = Binding_Create(mon, binding_ctx, uri, pbc, to_obj, riid, &binding); if(FAILED(hres)) return hres; hres = IBindStatusCallback_OnStartBinding(binding->callback, 0, &binding->IBinding_iface); if(FAILED(hres)) { WARN("OnStartBinding failed: %08x\n", hres); stop_binding(binding, INET_E_DOWNLOAD_FAILURE, NULL); IBinding_Release(&binding->IBinding_iface); return hres; } if(binding_ctx) { set_binding_sink(binding->protocol, &binding->IInternetProtocolSink_iface, &binding->IInternetBindInfo_iface); if(binding_ctx->redirect_url) IBindStatusCallback_OnProgress(binding->callback, 0, 0, BINDSTATUS_REDIRECTING, binding_ctx->redirect_url); report_data(binding, BSCF_FIRSTDATANOTIFICATION | (binding_ctx->download_state == END_DOWNLOAD ? BSCF_LASTDATANOTIFICATION : 0), 0, 0); }else { hres = IInternetProtocolEx_StartEx(&binding->protocol->IInternetProtocolEx_iface, uri, &binding->IInternetProtocolSink_iface, &binding->IInternetBindInfo_iface, PI_APARTMENTTHREADED|PI_MIMEVERIFICATION, 0); TRACE("start ret %08x\n", hres); if(FAILED(hres) && hres != E_PENDING) { stop_binding(binding, hres, NULL); IBinding_Release(&binding->IBinding_iface); return hres; } } while(!(binding->bindf & BINDF_ASYNCHRONOUS) && !(binding->state & BINDING_STOPPED)) { MsgWaitForMultipleObjects(0, NULL, FALSE, 5000, QS_POSTMESSAGE); while (PeekMessageW(&msg, binding->notif_hwnd, WM_USER, WM_USER+117, PM_REMOVE|PM_NOYIELD)) { TranslateMessage(&msg); DispatchMessageW(&msg); } } *ret = binding; return S_OK; }
/// <summary> /// Creates the main window and begins processing /// </summary> /// <param name="hInstance">handle to the application instance</param> /// <param name="nCmdShow">whether to display minimized, maximized, or normally</param> int CFaceBasics::Run(HINSTANCE hInstance, int nCmdShow) { MSG msg = {0}; WNDCLASS wc; // Dialog custom window class ZeroMemory(&wc, sizeof(wc)); wc.style = CS_HREDRAW | CS_VREDRAW; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hIcon = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APP)); wc.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1); wc.lpfnWndProc = DefDlgProcW; wc.lpszClassName = L"Face-And-HDFace-Basics-D2DAppDlgWndClass"; if (!RegisterClassW(&wc)) { return 0; } //hMenu = LoadMenuW(hInstance, MAKEINTRESOURCE(IDR_MENU1)); // Create main application window HWND hWndApp = CreateDialogParamW( NULL, MAKEINTRESOURCE(IDD_APP), NULL, (DLGPROC)CFaceBasics::MessageRouter, reinterpret_cast<LPARAM>(this)); //HWND hWndApp = CreateDialogParamW( NULL, MAKEINTRESOURCE(IDD_APP), NULL, (DLGPROC)CFaceBasics::MessageRouter, WS_CAPTION); // Show window ShowWindow(hWndApp, nCmdShow); //ShowWindow(hWndApp, 3); // Main message loop while (WM_QUIT != msg.message) { Update(); while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { // If a dialog message will be taken care of by the dialog proc if (hWndApp && IsDialogMessageW(hWndApp, &msg)) { continue; } TranslateMessage(&msg); DispatchMessageW(&msg); } } return static_cast<int>(msg.wParam); }
/*------------------------------------------------------------------*\ submitEvents() \*------------------------------------------------------------------*/ void CWinEventEmitter::submitEvents(CEventServer & server, bool allWindows) { MSG msg; while ( PeekMessageW(&msg,allWindows?NULL:_HWnd,0,0,PM_REMOVE) ) { TranslateMessage(&msg); DispatchMessageW(&msg); } // Dispatch sent messages _InternalServer.setServer (&server); _InternalServer.pump (allWindows); }
bool Engine::UpdateSystemMessage() { MSG msg; while (PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE)) { if (GetMessageW(&msg, NULL, 0, 0) == 0) return false; TranslateMessage( &msg ); DispatchMessageW( &msg ); } return true; }
/*-------------------------------------- * Function: updateDisplay() *------------------------------------*/ void updateDisplay(void) { if (!window) error("graphics not initialized"); MSG msg; while (window && PeekMessageW(&msg, window->hwnd, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } // @To-do: This is retarded. Sleep(500); }
static Ret ftk_source_wince_dispatch(FtkSource* thiz) { MSG msg; while(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } Sleep(20); return RET_OK; }
BOOL StartProcess(LPWSTR lpPath, BOOL Wait) { PROCESS_INFORMATION pi; STARTUPINFOW si; DWORD dwRet; MSG msg; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_SHOW; if (!CreateProcessW(NULL, lpPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) { return FALSE; } CloseHandle(pi.hThread); if (Wait) EnableWindow(hMainWnd, FALSE); while (Wait) { dwRet = MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLEVENTS); if (dwRet == WAIT_OBJECT_0 + 1) { while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } } else { if (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED) break; } } CloseHandle(pi.hProcess); if (Wait) { EnableWindow(hMainWnd, TRUE); SetForegroundWindow(hMainWnd); SetFocus(hMainWnd); } return TRUE; }
void NzWindowImpl::ProcessEvents(bool block) { if (m_ownsWindow) { if (block) WaitMessage(); MSG message; while (PeekMessageW(&message, nullptr, 0, 0, PM_REMOVE)) { TranslateMessage(&message); DispatchMessageW(&message); } } }
MOZCE_SHUNT_API BOOL mozce_PeekMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg) { SetLastError(0); #ifdef API_LOGGING mozce_printf("mozce_PeekMessageA called\n"); #endif BOOL b = PeekMessageW(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); if (b && wRemoveMsg == PM_REMOVE) gGetMessageTime = lpMsg->time; return b; }
//-------------------------------------------------------------------------------------- // This function is used only briefly in CHT IME handling, // so accelerator isn't processed. DXUTAPI void CDXUTIMEEditBox::PumpMessage() { MSG msg; while (PeekMessageW(&msg, nullptr, 0, 0, PM_NOREMOVE)) { if (!GetMessageW(&msg, nullptr, 0, 0)) { PostQuitMessage((int)msg.wParam); return; } TranslateMessage(&msg); DispatchMessageA(&msg); } }
/* execute rundll32 on the wine.inf file if necessary */ static void update_wineprefix( int force ) { const char *config_dir = wine_get_config_dir(); char *inf_path = get_wine_inf_path(); int fd; struct stat st; if (!inf_path) { WINE_MESSAGE( "wine: failed to update %s, wine.inf not found\n", config_dir ); return; } if ((fd = open( inf_path, O_RDONLY )) == -1) { WINE_MESSAGE( "wine: failed to update %s with %s: %s\n", config_dir, inf_path, strerror(errno) ); goto done; } fstat( fd, &st ); close( fd ); if (update_timestamp( config_dir, st.st_mtime ) || force) { HANDLE process; DWORD count = 0; if ((process = start_rundll32( inf_path, FALSE ))) { HWND hwnd = show_wait_window(); for (;;) { MSG msg; DWORD res = MsgWaitForMultipleObjects( 1, &process, FALSE, INFINITE, QS_ALLINPUT ); if (res == WAIT_OBJECT_0) { CloseHandle( process ); if (count++ || !(process = start_rundll32( inf_path, TRUE ))) break; } else while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) DispatchMessageW( &msg ); } DestroyWindow( hwnd ); } WINE_MESSAGE( "wine: configuration in '%s' has been updated.\n", config_dir ); } done: HeapFree( GetProcessHeap(), 0, inf_path ); }
// Translates a Windows key to the corresponding GLFW key // static int translateKey(WPARAM wParam, LPARAM lParam) { if (wParam == VK_CONTROL) { // The CTRL keys require special handling MSG next; DWORD time; // Is this an extended key (i.e. right key)? if (lParam & 0x01000000) return GLFW_KEY_RIGHT_CONTROL; // Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only // want the RALT message, so we try to see if the next message // is a RALT message. In that case, this is a false LCTRL! time = GetMessageTime(); if (PeekMessageW(&next, NULL, 0, 0, PM_NOREMOVE)) { if (next.message == WM_KEYDOWN || next.message == WM_SYSKEYDOWN || next.message == WM_KEYUP || next.message == WM_SYSKEYUP) { if (next.wParam == VK_MENU && (next.lParam & 0x01000000) && next.time == time) { // Next message is a RALT down message, which // means that this is not a proper LCTRL message return _GLFW_KEY_INVALID; } } } return GLFW_KEY_LEFT_CONTROL; } if (wParam == VK_PROCESSKEY) { // IME notifies that keys have been filtered by setting the virtual // key-code to VK_PROCESSKEY return _GLFW_KEY_INVALID; } return _glfw.win32.keycodes[HIWORD(lParam) & 0x1FF]; }
/* * Sys_SendKeyEvents * * Send Key_Event calls */ void Sys_SendKeyEvents( void ) { MSG msg; while( PeekMessageW( &msg, NULL, 0, 0, PM_NOREMOVE ) ) { if( !GetMessageW( &msg, NULL, 0, 0 ) ) Sys_Quit(); sys_msg_time = msg.time; myTranslateMessage( &msg ); DispatchMessageW( &msg ); } // grab frame time sys_frame_time = timeGetTime(); // FIXME: should this be at start? }
static void pump_msgs(BOOL *b) { MSG msg; if(b) { while(!*b && GetMessageW(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessageW(&msg); } }else { while(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessageW(&msg); } } }