Page 2 of 3
Re: Screenshot of window isn't themed
Posted: Thu Mar 29, 2018 1:48 pm
by nco2k
no, both windows have to be top-level windows.
but you can specify the position and size:
Code: Select all
dwm_thumbnail_properties\rcDestination\left = x
dwm_thumbnail_properties\rcDestination\top = y
dwm_thumbnail_properties\rcDestination\right = Width + dwm_thumbnail_properties\rcDestination\left
dwm_thumbnail_properties\rcDestination\bottom = Height + dwm_thumbnail_properties\rcDestination\top
and you can quickly turn it on or off:
Code: Select all
dwm_thumbnail_properties\fVisible = #True/#False
c ya,
nco2k
Re: Screenshot of window isn't themed
Posted: Thu Mar 29, 2018 3:14 pm
by skywalk
@chi - Your fixes now capture the modern Calculator again, but my drawn windows are stripped of their theme. And I cannot get a clean, zero margin clip of my captured window. I have to go into the code and enter negative numbers but they are not symmetrical.
Is this correct summary?
PrintWindow() - captures PB drawn windows with theme. Fails on modern calculator and equivalents.
bitblt() + pixel looping/alphachannel - captures all windows minus theme.
DwmUpdateThumbnailProperties() - captures all windows + theme but writes to another Window. Still need to save image and back to original problem?
Re: Screenshot of window isn't themed
Posted: Thu Mar 29, 2018 10:31 pm
by chi
@skywalk: the clipboard seems to have issues with some 32bit images... updated source code
Re: Screenshot of window isn't themed
Posted: Fri Mar 30, 2018 2:41 pm
by skywalk
Hi chi - Your AeroShot code now captures the modern Calculator and PB drawn windows when saved to file. But, PB drawn windows saved to Clipboard still have extra padding. I remember having similar problems with PrintWindow_() and trying 32-bit data. It worked fine with 24-bit image data.
Re: Screenshot of window isn't themed
Posted: Fri Mar 30, 2018 2:58 pm
by RASHAD
Capture almost any running application to clipboard
Exact size
After all it is workaround
Code: Select all
Global Dim h(100),n
Procedure tbWindows(hwnd,lParam)
Protected.s title = Space(#MAX_PATH)
If GetWindowLongPtr_(hwnd,#GWL_EXSTYLE) ! #WS_EX_TOOLWINDOW And GetWindowLongPtr_(hwnd,#GWL_STYLE) & #WS_VISIBLE
GetWindowText_(hwnd,title,#MAX_PATH)
If title <> ""
AddGadgetItem(0,-1,title)
h(n) = hwnd
n +1
EndIf
EndIf
ProcedureReturn #True
EndProcedure
OpenWindow(0, 0, 0, 400,400, "Snapshot", #PB_Window_SystemMenu| #PB_Window_ScreenCentered)
ListViewGadget(0,10,10,380,340)
ButtonGadget(1,10,365,60,24,"RUN")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 0
hwnd = h(GetGadgetState(0))
SetWindowPos_(hwnd,#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
wi.WINDOWINFO
wi\cbSize = SizeOf(wi)
GetWindowInfo_(hwnd,wi)
;cap = wi\rcClient\top - wi\rcWindow\top
bord = wi\rcClient\left - wi\rcWindow\left
hBitmap = CreateImage(0,wi\rcWindow\right-wi\rcWindow\left-2*bord+2,wi\rcWindow\bottom-wi\rcWindow\top-bord+1)
hdc = StartDrawing(ImageOutput(0))
SelectObject_(hdc, hBitmap)
BitBlt_(hdc,0,0,wi\rcWindow\right-wi\rcWindow\left-2*bord+2,wi\rcWindow\bottom-wi\rcWindow\top-bord+1, GetDC_(0),wi\rcWindow\left+bord-1,wi\rcWindow\top , #SRCCOPY)
StopDrawing()
ClearClipboard()
SetClipboardImage(0)
SetWindowPos_(hwnd,#HWND_BOTTOM ,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE )
FreeImage(0)
Case 1
ClearGadgetItems(0)
n = 0
ReDim h(100)
EnumChildWindows_(FindWindow_("ToolbarWindow32",0),@tbWindows(),0)
Delay(200)
SetWindowPos_(WindowID(0), #HWND_TOPMOST, 0, 0, 0, 0,#SWP_NOSIZE|#SWP_NOMOVE| #SWP_SHOWWINDOW|#SWP_NOACTIVATE)
EndSelect
EndSelect
Until Quit = 1
Re: Screenshot of window isn't themed
Posted: Fri Mar 30, 2018 3:25 pm
by skywalk
TaDa!
RASHAD, so simple and it respects the current theme of modern and PB drawn windows.
Also works with 24 or 32-bit image creations.
hBitmap = CreateImage(0,wi\rcWindow\right-wi\rcWindow\left-2*bord+2,wi\rcWindow\bottom-wi\rcWindow\top-bord+1,32)
Re: Screenshot of window isn't themed
Posted: Sat Mar 31, 2018 7:16 am
by Dude
RASHAD wrote:Capture almost any running application to clipboard
Exact size
Sorry Rashad, but not quite.

Here's how it captures Calculator on my PC:

Re: Screenshot of window isn't themed
Posted: Sun Apr 01, 2018 8:40 am
by Dude
@nco2k: How can I remove (delete) all thumbnails from a window? When I try to use DwmUnregisterThumbnail_(hThumbnailId), I get this error:
Code: Select all
DwmUnregisterThumbnail_() is not a function, array, list, map or macro.
I just want to remove all thumbnails that I set, without closing the window that I put them on.
Re: Screenshot of window isn't themed
Posted: Sun Apr 01, 2018 8:46 am
by firace
Dude wrote:@nco2k: How can I remove (delete) all thumbnails from a window? When I try to use DwmUnregisterThumbnail_(hThumbnailId), I get this error:
Code: Select all
DwmUnregisterThumbnail_() is not a function, array, list, map or macro.
I just want to remove all thumbnails that I set, without closing the window that I put them on.
Seems to work fine here. Make sure you did not remove the import:
Code: Select all
DwmUnregisterThumbnail_ = GetFunction(LibraryPB, "DwmUnregisterThumbnail")
Re: Screenshot of window isn't themed
Posted: Sun Apr 01, 2018 8:56 am
by Dude
Thanks firace, that was the problem. Got it sorted now.
The only thing is, I have to keep an array of all registered thumb IDs, then unregister them all manually. This works, but I wonder if there's some sort of bulk way to just unregister them all automatically?
Re: Screenshot of window isn't themed
Posted: Mon Apr 02, 2018 10:47 am
by Dude
Anyone know how to capture fullscreen games to an image? Things like "Quake 2" just show a gray screen, even if I press PrintScreen to capture them to the clipboard.

Re: Screenshot of window isn't themed
Posted: Mon Apr 02, 2018 1:10 pm
by chi
skywalk wrote:Hi chi - Your AeroShot code now captures the modern Calculator and PB drawn windows when saved to file. But, PB drawn windows saved to Clipboard still have extra padding. I remember having similar problems with PrintWindow_() and trying 32-bit data. It worked fine with 24-bit image data.
Just don't use the clipboard with 32bit images right now...

I already filed a bug report
here
Dude wrote:Anyone know how to capture fullscreen games to an image? Things like "Quake 2" just show a gray screen, even if I press PrintScreen to capture them to the clipboard.

Maybe hook EndScene (DirectX) or glSwapBuffers (OpenGL)?!
Re: Screenshot of window isn't themed
Posted: Fri May 18, 2018 5:11 am
by Dude
Another question about the DWM thumbnail code: is there a way to get the thumbnail size AFTER the thumbnail is drawn? I want to set my window height to be the thumbnail height, but I don't know what the thumbnail height will be until after it's drawn.
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!
