MCPcopy Create free account
hub / github.com/GPUOpen-LibrariesAndSDKs/Cauldron / WindowProc

Function WindowProc

src/VK/base/FrameworkWindows.cpp:197–286  ·  view source on GitHub ↗

this is the main message handler for the program

Source from the content-addressed store, hash-verified

195
196// this is the main message handler for the program
197LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
198{
199 // sort through and find what code to run for the message given
200 switch (message)
201 {
202 case WM_DESTROY:
203 {
204 PostQuitMessage(0);
205 return 0;
206 }
207
208 // When close button is clicked on window
209 case WM_CLOSE:
210 {
211 PostQuitMessage(0);
212 return 0;
213 }
214
215 case WM_KEYDOWN:
216 {
217 if (wParam == VK_ESCAPE)
218 {
219 PostQuitMessage(0);
220 }
221
222 break;
223 }
224
225 case WM_SYSKEYDOWN:
226 {
227 const bool bAltKeyDown = (lParam & (1 << 29));
228 if ((wParam == VK_RETURN) && bAltKeyDown) // For simplicity, alt+enter only toggles in/out windowed and borderless fullscreen
229 pFrameworkInstance->ToggleFullScreen();
230 break;
231 }
232
233 case WM_SIZE:
234 {
235 if (pFrameworkInstance)
236 {
237 RECT clientRect = {};
238 GetClientRect(hWnd, &clientRect);
239 pFrameworkInstance->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
240 bIsMinimized = (IsIconic(hWnd) == TRUE);
241 return 0;
242 }
243 break;
244 }
245
246 // When window goes outof focus, use this event to fall back on SDR.
247 // If we don't gracefully fallback to SDR, the renderer will output HDR colours which will look extremely bright and washed out.
248 // However if you want to use breakpoints in HDR mode to inspect/debug values, you will have to comment this function call.
249 case WM_ACTIVATE:
250 {
251 if (pFrameworkInstance)
252 {
253 pFrameworkInstance->OnActivate(wParam != WA_INACTIVE);
254 }

Callers

nothing calls this directly

Calls 4

ToggleFullScreenMethod · 0.45
OnResizeMethod · 0.45
OnActivateMethod · 0.45
OnWindowMoveMethod · 0.45

Tested by

no test coverage detected