0

I want to write a programm which uses OpenGL to create a animated desktop background. Therefore i need to know the HWND that contains the picture from the desktop. Perfect would be a code-example how i find that specific window.

Borgleader
  • 15,826
  • 5
  • 46
  • 62

1 Answers1

1

If you carefully read the documentation you will find that you must not set the pixel format on the root / desktop window. Also the DC of the desktop window is not owned exclusively. Either constraint make it impossible to create a OpenGL context on the desktop window directly. Also note, that for your typical Windows shell (explorer.exe), the desktop is actually a Win32 Icon View, owned by a explorer.exe process and being a child of the desktop window.

What you can do is create a FBO the same size of the desktop window, with a pixelformat that's compatible with the DC of the desktop window. Then render to the FBO read its contents into a DIBSection use CreateDIBPatternBrushPt to create a HBRUSH and set the background brush of the desktop window with SetClassLongPtr.

datenwolf
  • 159,371
  • 13
  • 185
  • 298