Jump to content
Tuts 4 You

PureBasic Adventures...

Sign in to follow this  
  • entries
    7
  • comments
    10
  • views
    31,065

PW_RENDERFULLCONTENT

Teddy Rogers

3,470 views

Apparently... Windows 8.1 came with a new flag for PrintWindow called, PW_RENDERFULLCONTENT. This allows PrintWindow to properly capture window content that is displaying DirectX through DWM.

 

Below are some screenshots taken of Unreal Tournament. The first is how PrintWindow normally captures a window with DirectX content being rendered inside it, notice the window border is missing and there is corrupted graphics on the right. The second screenshot is taken with PW_RENDERFULLCONTENT...

 

blogentry-620-0-36093100-1426344802_thum

 

blogentry-620-0-70443000-1426344759_thum

 

Below is an example using PureBasic code, there isn't much information about PW_RENDERFULLCONTENT and it is currently undocumented on MSDN. I am sure if I had a bit more spare time I could find a more worthy example to show you than the above images. You get the idea though...

 
UsePNGImageEncoder()

Declare PrintScreen(hWnd)

Prototype.i PrintWindow(hWnd, hdcBlt, nFlags)Global PrintWindow.PrintWindow

If OpenWindow(1, #Null, #Null, #Null, #Null, "Capture Window", #PB_Window_Invisible)
  Repeat
    MyEvent = WaitWindowEvent()
    
    If GetAsyncKeyState_(#VK_SNAPSHOT) & $8000
      PrintScreen(FindWindow_(#Null, "Unreal Tournament"))
    EndIf
    
    If GetAsyncKeyState_(#VK_ESCAPE) & $8000
      MyEvent = #PB_Event_CloseWindow
    EndIf
    
  Until MyEvent = #PB_Event_CloseWindow
EndIf

Procedure PrintScreen(hWnd)
  Protected r.RECT
  
  #PW_RENDERFULLCONTENT = $00000002
  
  If OpenLibrary(User32, "User32.dll")
    PrintWindow = GetFunction(User32, "PrintWindow")
    
    If GetWindowRect_(hWnd, r.RECT)
      If CreateImage(CapImage, r\right-r\left, r\bottom-r\top, 32)
        hdc = StartDrawing(ImageOutput(CapImage))
        
        ; PW_RENDERFULLCONTENT -> new in Windows 8.1, can capture DirectX screens through DWM
        
        Okay = PrintWindow(hWnd, hdc, #PW_RENDERFULLCONTENT)
        StopDrawing()
        
        If Okay
          SaveImage(CapImage, "C:\Users\Teddy\Downloads\" + FormatDate("%yyyy.%mm.%DD-%hh.%ii.%ss", Date()) + ".png", #PB_ImagePlugin_PNG)
          CloseLibrary(User32)
          ProcedureReturn
        EndIf
        
      EndIf
    EndIf
    CloseLibrary(User32)
  EndIf
  
EndProcedure

 

If you have more information or details on PW_RENDERFULLCONTENT please tell me about it...

 

Ted.



0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×