MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Samples / RunMessagePump

Function RunMessagePump

SampleApps/WebView2APISample/App.cpp:138–173  ·  view source on GitHub ↗

Run the message pump for one thread.

Source from the content-addressed store, hash-verified

136
137// Run the message pump for one thread.
138static int RunMessagePump()
139{
140 HACCEL hAccelTable = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDC_WEBVIEW2APISAMPLE));
141
142 MSG msg;
143
144 // Main message loop:
145 //! [MoveFocus0]
146 while (GetMessage(&msg, nullptr, 0, 0))
147 {
148 if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
149 {
150 // Calling IsDialogMessage handles Tab traversal automatically. If the
151 // app wants the platform to auto handle tab, then call IsDialogMessage
152 // before calling TranslateMessage/DispatchMessage. If the app wants to
153 // handle tabbing itself, then skip calling IsDialogMessage and call
154 // TranslateMessage/DispatchMessage directly.
155 if (!g_autoTabHandle || !IsDialogMessage(GetAncestor(msg.hwnd, GA_ROOT), &msg))
156 {
157 TranslateMessage(&msg);
158 DispatchMessage(&msg);
159 }
160 }
161 }
162 //! [MoveFocus0]
163
164 DWORD threadId = GetCurrentThreadId();
165 auto it = s_threads.find(threadId);
166 if (it != s_threads.end())
167 {
168 CloseHandle(it->second);
169 s_threads.erase(threadId);
170 }
171
172 return (int)msg.wParam;
173}
174
175// Make a new thread.
176void CreateNewThread(AppWindow* app)

Callers 2

wWinMainFunction · 0.70
ThreadProcFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected