Page 2 of 3

Re: Screenshot of window isn't themed

Posted: Fri May 18, 2018 6:47 am
by idle
Dude

This should capture your themed window

Code: Select all

#CAPTUREBLT = $40000000 

Procedure CapWindow(Hwnd) 
  
  Protected Rect.rect 
  Protected SrcDc,DestDc,Image,Result,W,H  
  If hwnd 
    SrcDc = GetDC_(0)
    If SrcDc 
      GetWindowRect_(Hwnd,@Rect)
      W = Rect\Right-Rect\Left 
      H = Rect\Bottom - Rect\Top 
      If W 
        Image = CreateImage(#PB_Any,W,H,32) 
        If Image 
          DestDc = StartDrawing(ImageOutput(Image))
          If DestDc 
            Result = BitBlt_(DestDc,0,0,W,H,Srcdc,Rect\Left,Rect\Top,#SRCCOPY | #CAPTUREBLT);
            If Result 
              ProcedureReturn Image 
            EndIf 
          EndIf 
        EndIf   
      EndIf   
    EndIf
  EndIf  
  
EndProcedure


Delay(2000)

winshot=CapWindow(GetForegroundWindow_()) 
SetClipboardImage(winshot)
If winshot
  FreeImage(winshot)
EndIf 

Re: Screenshot of window isn't themed

Posted: Fri May 18, 2018 7:43 am
by Dude
Thanks idle, it sure does! :)

Re: Screenshot of window isn't themed

Posted: Fri May 18, 2018 7:55 am
by idle
Dude wrote:Thanks idle, it sure does! :)
It should also capture a windowscreen and for Vista / Win7 compatibility, it might also need enable DwmEnableComposition

Code: Select all

Procedure DWMEnableDisable(OnOff.i)
  Protected *pAfunc,Lib
  Lib = LoadLibrary_("dwmapi.dll")
  If Lib
    *pAfunc = GetProcAddress_(Lib, "DwmEnableComposition") 
    If *pAfunc
      CallFunctionFast(*pAfunc, OnOff) 
    EndIf 
    FreeLibrary_(Lib) 
  EndIf
EndProcedure 

Re: Screenshot of window isn't themed

Posted: Wed Apr 08, 2020 11:18 am
by Dude
Back for another question, nco2k. :)

On the first page of this thread, you showed how to do a thumbnail of a window. Are you able to explain how to show just a portion of the source window as the thumbnail in the target window? Everything I've tried always shows the entire source window as a thumbnail.

Aiming to do like this app:

https://github.com/LionelJouin/PiP-Tool

So I know it's possible. The relevant part of my source is this:

Code: Select all

dwm_thumbnail_properties\rcSource\left=x
dwm_thumbnail_properties\rcSource\top=y
dwm_thumbnail_properties\rcSource\right=w
dwm_thumbnail_properties\rcSource\bottom=h
dwm_thumbnail_properties\rcDestination\left=0
dwm_thumbnail_properties\rcDestination\top=0
dwm_thumbnail_properties\rcDestination\right=w
dwm_thumbnail_properties\rcDestination\bottom=h
Where X/Y are the top left desired area of the source (not of its window corner), and W/H is partial of the source window. Just can't seem to make any progress. :(

Re: Screenshot of window isn't themed

Posted: Thu Apr 30, 2020 7:24 am
by nco2k
a wild guess:
#DWM_TNP_RECTSOURCE = $00000002

dwm_thumbnail_properties\dwFlags = #DWM_TNP_RECTSOURCE | ...
dwm_thumbnail_properties\rcSource\left = x
dwm_thumbnail_properties\rcSource\top = y
dwm_thumbnail_properties\rcSource\right = Width
dwm_thumbnail_properties\rcSource\bottom = Height
c ya,
nco2k

Re: Screenshot of window isn't themed

Posted: Wed May 18, 2022 11:27 am
by BarryG
nco2k wrote: Wed Mar 28, 2018 9:10 pmDwmThumbnail(WindowID(0), WindowID(1))
Just testing this and was wondering if drawing the thumbnail be put on a gadget, like a ButtonGadget for clicking it? Instead of drawing it direct to a window? I tried using the GadgetID() of various gadgets but no luck.