>     COLORREF color = GetPixel(GetDC(NULL), x, y); <- resource leak

Each call to `GetDC` should be cleaned up by `ReleaseDC`, otherwise we get GDI resource leak. You can monitor this GDI resource leak in Windows Task Manager (under "Details" tab, right-click on the list column header, and select to show "GDI objects") See also documentation for [GetDC](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc)

A call to `BeginPaint` should be cleaned up with `EndPaint` (we don't want to call `GetDC/ReleaseDC` in between)

    HDC hdc = BeginPaint(hwnd, &ps);
    //use hdc...
    EndPaint(hwnd, &ps);

Font created by `CreateFont` also needs cleanup with `DeleteObject`. You must also save the old font and restore it (see suggested code).

The lag in resizing is caused by `PostMessage(hwnd, WM_PAINT, color, color);` in mouse proc. Each time the window is resized, the mouse proc is sending additional paint request.

Use `GetKeyState(VK_CONTROL)` to see if control key is pushed.

Error handling for functions such as `GetCursorPos` is not necessary. This function fails only if the parameter is incorrect, or there is something seriously wrong, in which case the program will crash anyway. 

`LowLevelMouseProc` should return `CallNextHookEx` if it does not process the message.

Other suggestions:

Add a separate function, for example `update`, to get the pixel color and draw it. 

Suggested changes:

    #ifndef UNICODE
    #define UNICODE
    #endif
    
    #include <windows.h>
    #include <stdio.h>
    #include "w32.h"
    
    const int WIDTH = 300;
    const int HEIGHT = 200;
    const int TEXT_LINE_HEIGHT = 30;
    
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam);
    VOID WINAPI CopyToClipboard(HWND hwnd);
    
    HWND hwnd;
    BOOL ctrlKeyDown = FALSE;
    POINT prevPoint;
    HHOOK mouseHook;
    
    #define WM_USER1 (WM_USER + 1)
    
    COLORREF save_color = 0;
    
    int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow) 
    {
        prevPoint.x = -1;
        prevPoint.y = -1;
        const wchar_t CLASS_NAME[] = L"GrabPixlMainWndw";
    
        WNDCLASSEX wc = {0};
        wc.cbSize = sizeof(wc);
        wc.hCursor = LoadCursor(NULL, IDC_ARROW);
        wc.lpfnWndProc = WindowProc;
        wc.hInstance = hInstance;
        wc.lpszClassName = CLASS_NAME;
    
        RegisterClassEx(&wc);
    
        int screenWidth = GetSystemMetrics(SM_CXFULLSCREEN);
        int screenHeight = GetSystemMetrics(SM_CYFULLSCREEN);
    
        hwnd = CreateWindowEx(0, CLASS_NAME, L"GrabPixel 1.6",
            WS_OVERLAPPEDWINDOW, (screenWidth - WIDTH) / 2, (screenHeight - HEIGHT) / 2,
            WIDTH, HEIGHT, NULL, NULL, hInstance, NULL);
    
        if (hwnd == NULL) 
            return 0;
    
        mouseHook = SetWindowsHookEx(WH_MOUSE_LL, LowLevelMouseProc, hInstance, 0);
    
        ShowWindow(hwnd, nCmdShow);
        UpdateWindow(hwnd);
    
        MSG msg = {0};
    
        while (GetMessage(&msg, NULL, 0, 0)) {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
    
        return 0;
    }
    
    void update(HDC hdc)
    {
        POINT pt;
        GetCursorPos(&pt);
        HDC hdc_desktop = GetDC(0);
        save_color = GetPixel(hdc_desktop, pt.x, pt.y);
        ReleaseDC(0, hdc_desktop);
    
        RECT rect;
        GetClientRect(hwnd, &rect);
        rect.bottom -= TEXT_LINE_HEIGHT;
    
        HBRUSH brush = CreateSolidBrush(save_color);
        FillRect(hdc, &rect, brush);
        DeleteObject(brush);
    
        // Draw the RGB rectangle:
        brush = CreateSolidBrush(RGB(255, 255, 255));
        rect.top = rect.bottom;
        rect.bottom += TEXT_LINE_HEIGHT;
        FillRect(hdc, &rect, brush);
        DeleteObject(brush);
    
        // Print the RGB value of the current pixel:
        wchar_t buffer[20];
        wsprintf(buffer, L"#%02x%02x%02x", 
            GetRValue(save_color), GetGValue(save_color), GetBValue(save_color));
    
        HFONT hFont = CreateFont(30, 16, 0, 0, FW_BOLD, FALSE, FALSE, FALSE, ANSI_CHARSET,
            OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, FF_MODERN, L"Monospaced");
    
        SetTextColor(hdc, RGB(0, 0, 0));
        HFONT oldfont = (HFONT)SelectObject(hdc, hFont);
        TextOut(hdc, 5, rect.bottom - TEXT_LINE_HEIGHT, buffer, 7);
        SelectObject(hdc, oldfont);
        DeleteObject(hFont);
    }
    
    LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 
    {
        switch (uMsg) 
        {
        case WM_USER1:
        {
            HDC hdc = GetDC(hwnd);
            update(hdc);
            ReleaseDC(hwnd, hdc);
            return 0;
        }
    
        case WM_DESTROY:
            PostQuitMessage(0);
            return 0;
    
        case WM_KEYDOWN:
            if ((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000) 
                if (wParam == 'C') 
                    CopyToClipboard(hwnd);
            break;
    
        case WM_SIZE:
            InvalidateRect(hwnd, NULL, TRUE);
            return 0;
    
        case WM_KEYUP:
            if (wParam == VK_CONTROL) 
                ctrlKeyDown = FALSE;
            break;
    
        case WM_PAINT: 
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hwnd, &ps);
            update(hdc);
            EndPaint(hwnd, &ps);
    
            return 0;
        }
        }
    
        return DefWindowProc(hwnd, uMsg, wParam, lParam);
    }
    
    LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam) 
    {
        if ((GetKeyState(VK_LBUTTON) & 0x8000) == 0 && wParam == WM_MOUSEMOVE && lParam)
            PostMessage(hwnd, WM_USER1, 0, 0);
        return CallNextHookEx(mouseHook, nCode, wParam, lParam);
    }
    
    VOID WINAPI CopyToClipboard(HWND hwnd) 
    {
        if (!OpenClipboard(GetDesktopWindow())) 
            return;
        EmptyClipboard();
    
        int r = GetRValue(save_color);
        int g = GetGValue(save_color);
        int b = GetBValue(save_color);
    
        int len = 10;
        HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, len);
        if (!hMem) return;
        char* buffer = (char*)GlobalLock(hMem);
        if (!buffer) return;
        sprintf_s(buffer, len, "#%02x%02x%02x", r, g, b);
        GlobalUnlock(hMem);
    
        SetClipboardData(CF_TEXT, hMem);
        CloseClipboard();
    }