Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class OS extends C {
/**
* Values taken from https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions
*/
public static final int WIN32_BUILD_WIN8_1 = 9600; // "Windows 8.1"
public static final int WIN32_BUILD_WIN10_1607 = 14393; // "Windows 10 August 2016 Update"
public static final int WIN32_BUILD_WIN10_1809 = 17763; // "Windows 10 October 2018 Update"
public static final int WIN32_BUILD_WIN10_2004 = 19041; // "Windows 10 May 2020 Update"
Expand Down Expand Up @@ -1069,6 +1070,7 @@ public class OS extends C {
public static final int PLANES = 0xe;
public static final int PM_NOREMOVE = 0x0;
public static final int PM_NOYIELD = 0x2;
public static final int PW_RENDERFULLCONTENT = 0x2; // undocumented ( >= Windows 8.1)
public static final int QS_HOTKEY = 0x0080;
public static final int QS_KEY = 0x0001;
public static final int QS_MOUSEMOVE = 0x0002;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2219,15 +2219,23 @@ public boolean print (GC gc) {
}
int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
OS.RedrawWindow (topHandle, null, 0, flags);
printWidget (topHandle, hdc, gc);
int printWindowFlags = 0;
if (OS.WIN32_BUILD >= OS.WIN32_BUILD_WIN8_1) {
/*
* Undocumented flag in windows, which also allows the capturing
* of GPU-drawn areas, e.g. an embedded Edge WebView2.
*/
printWindowFlags |= OS.PW_RENDERFULLCONTENT;
}
printWidget (topHandle, hdc, gc, printWindowFlags);
if (gdipGraphics != 0) {
OS.RestoreDC(hdc, state);
Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc);
}
return true;
}

void printWidget (long hwnd, long hdc, GC gc) {
void printWidget (long hwnd, long hdc, GC gc, int printWindowFlags) {
/*
* Bug in Windows. For some reason, PrintWindow()
* returns success but does nothing when it is called
Expand Down Expand Up @@ -2311,7 +2319,7 @@ void printWidget (long hwnd, long hdc, GC gc) {
if ((bits1 & OS.WS_VISIBLE) == 0) {
OS.ShowWindow (hwnd, OS.SW_SHOW);
}
success = OS.PrintWindow (hwnd, hdc, 0);
success = OS.PrintWindow (hwnd, hdc, printWindowFlags);
if ((bits1 & OS.WS_VISIBLE) == 0) {
OS.ShowWindow (hwnd, OS.SW_HIDE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ boolean mnemonicMatch (char key) {
}

@Override
void printWidget (long hwnd, long hdc, GC gc) {
void printWidget (long hwnd, long hdc, GC gc, int printWindowFlags) {
/*
* Bug in Windows. For some reason, PrintWindow()
* returns success but does nothing when it is called
Expand All @@ -307,7 +307,7 @@ void printWidget (long hwnd, long hdc, GC gc) {
if ((bits & OS.WS_VISIBLE) == 0) {
OS.ShowWindow (hwnd, OS.SW_SHOW);
}
success = OS.PrintWindow (hwnd, hdc, 0);
success = OS.PrintWindow (hwnd, hdc, printWindowFlags);
if ((bits & OS.WS_VISIBLE) == 0) {
OS.ShowWindow (hwnd, OS.SW_HIDE);
}
Expand All @@ -334,6 +334,14 @@ void printWidget (long hwnd, long hdc, GC gc) {
Control [] children = _getChildren ();
Rectangle rect = getBoundsInPixels ();
OS.IntersectClipRect (hdc, 0, 0, rect.width, rect.height);
// When looping over child windows and printWindowFlags has
// PW_RENDERFULLCONTENT set, then the printed content is always
// rendered at the top-left of the passed hdc.
// clear that flag
// This should be not an issue, since with PW_RENDERFULLCONTENT set
// the problem above (push button) does not appear to occurr.
// To be on the safe side, clear the flag when dealing with children
printWindowFlags &= ~OS.PW_RENDERFULLCONTENT;
for (int i=children.length - 1; i>=0; --i) {
Point location = children [i].getLocationInPixels ();
int graphicsMode = OS.GetGraphicsMode(hdc);
Expand All @@ -346,7 +354,7 @@ void printWidget (long hwnd, long hdc, GC gc) {
long topHandle = children [i].topHandle();
int bits = OS.GetWindowLong (topHandle, OS.GWL_STYLE);
if ((bits & OS.WS_VISIBLE) != 0) {
children [i].printWidget (topHandle, hdc, gc);
children [i].printWidget (topHandle, hdc, gc, printWindowFlags);
}
if (graphicsMode == OS.GM_ADVANCED) {
float [] lpXform = {1, 0, 0, 1, -location.x, -location.y};
Expand Down
Loading