MCPcopy Create free account
hub / github.com/LegacyUpdate/LegacyUpdate / BackgroundWndProc

Function BackgroundWndProc

nsisplugin/DialogInit.c:321–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

319}
320
321static LRESULT CALLBACK BackgroundWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
322 switch (uMsg) {
323 case WM_PAINT: {
324 PAINTSTRUCT ps = {0};
325 HDC hdc = BeginPaint(hwnd, &ps);
326 RECT rect = {0};
327 GetClientRect(hwnd, &rect);
328
329 // Gradient
330 int height = rect.bottom - rect.top;
331 int width = rect.right - rect.left;
332
333 for (int i = 0; i < height; i++) {
334 float ratio = (float)(i - rect.top) / (float)(rect.bottom - rect.top);
335 COLORREF color = RGB(
336 (int)(0x00 * (1 - ratio) + 0x00 * ratio),
337 (int)(0x00 * (1 - ratio) + 0x00 * ratio),
338 (int)(0x80 * (1 - ratio) + 0x00 * ratio)
339 );
340
341 RECT lineRect = {rect.left, rect.top + i, rect.right, rect.top + i + 1};
342 HBRUSH brush = CreateSolidBrush(color);
343 FillRect(hdc, &lineRect, brush);
344 DeleteObject(brush);
345 }
346
347 HFONT font = CreateFont(-40, 0, 0, 0, FW_BOLD, TRUE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_DONTCARE | FIXED_PITCH, L"Times New Roman");
348 HFONT oldFont = (HFONT)SelectObject(hdc, font);
349
350 static LPWSTR text = L"Legacy Update";
351
352 // Shadow
353 SetTextColor(hdc, RGB(0x00, 0x00, 0x00));
354 SetBkMode(hdc, TRANSPARENT);
355 TextOut(hdc, 10 + 4, 4 + 4, text, lstrlen(text));
356
357 // Text
358 SetTextColor(hdc, RGB(0xff, 0xff, 0xff));
359 TextOut(hdc, 10, 4, text, lstrlen(text));
360 SelectObject(hdc, oldFont);
361 DeleteObject(font);
362
363 EndPaint(hwnd, &ps);
364 return 0;
365 }
366
367 case WM_ERASEBKGND:
368 return 1;
369
370 case WM_ACTIVATE:
371 // If we become foreground, bring the main dialog to front
372 if (LOWORD(wParam) != WA_INACTIVE) {
373 SetForegroundWindow(g_hwndParent);
374 }
375 return 0;
376
377 case WM_CLOSE:
378 // Don't allow closing

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected