protected override LResult WindowProcedure(WindowHandle window, MessageType message, WParam wParam, LParam lParam) { switch (message) { case MessageType.Create: dcScreen = Gdi.CreateDeviceContext("DISPLAY", null); window.SetTimer(ID_TIMER, 100); return(0); case MessageType.Timer: Point pt = Windows.GetCursorPosition(); cr = dcScreen.GetPixel(pt); // Not sure why the sample did this // dcScreen.SetPixel(pt, 0); if (cr != crLast) { crLast = cr; window.GetDeviceContext().SetBackgroundColor(cr); window.Invalidate(erase: false); } return(0); case MessageType.Paint: using (DeviceContext dc = window.BeginPaint()) { dc.SelectObject(StockFont.SystemFixed); Rectangle rc = window.GetClientRectangle(); dc.FillRectangle(rc, dc.GetCurrentBrush()); dc.DrawText($"0x{cr.R:X2} 0x{cr.G:X2} 0x{cr.B:X2}".AsSpan(), rc, TextFormat.SingleLine | TextFormat.Center | TextFormat.VerticallyCenter); } return(0); case MessageType.Destroy: dcScreen.Dispose(); window.KillTimer(ID_TIMER); break; } return(base.WindowProcedure(window, message, wParam, lParam)); }