Painting on Win32 desktop my mistake lazarus / 31-LCL ---------------------------------------------------------------------- AlexTP · 2020-04-29 18:23 user of CudaText wrote me that CudaText painted some gray rectangle on Win desktop on exiting if user opened hex viewer in app. found that it's caused by TATBinHex.Paint event called in Destroy of main form. Paint called with handle=0 and painted on Win desktop because canvas handle=0 means Win desktop. https://github.com/Alexey-T/ATBinHex- Lazarus/commit/6b05ec74ef4458b87b3f8d4ca4f6e5de200b9da9 here is fix. and another fix was to avoid bad Paint call. suggestion - add IFDEF to LCL to disable painting on canvas DC=0. if author needs to paint on Win desktop he will use ifdef. ---------------------------------------------------------------------- Thaddy · 2020-04-29 18:37 The correct way is not DC(0) as handle directly but call GetDC(0) to obtain the handle to the desktop,. Otherwise you run into problems like described. Some of the time direct assignment works, but that is by accident. You need to call GetDC