我可以在桌面上绘制圆圈,但我无法绘制透明。 这是在桌面上绘制圆圈的代码。
public static void drawCircle(int x, int y, int radius) {
try {
NativeCall.init();
int brush = -1;
IntCall ic = new IntCall("user32", "GetDesktopWindow");
int screenHDC = ic.executeCall(new Object[]{});
ic.destroy();
ic = new IntCall("user32", "GetWindowDC");
int hdc = ic.executeCall(new Object[]{screenHDC});
ic.destroy();
int pen = 0;
ic = new IntCall("gdi32", "CreateSolidBrush");
brush = ic.executeCall(new Object[]{0x000000FF});
ic.destroy();
VoidCall x1 = new VoidCall("Gdi32", "SelectObject");
x1.executeCall(new Object[]{hdc, brush});
x1.destroy();
if (brush == -1) {
ic = new IntCall("gdi32", "CreateSolidBrush");
brush = ic.executeCall(new Object[]{0x00FFFFFF});
ic.destroy();
x1 = new VoidCall("Gdi32", "SelectObject");
x1.executeCall(new Object[]{hdc, brush});
x1.destroy();
} else if (brush == 0) {
ic = new IntCall("Gdi32", "CreatePen");
pen = ic.executeCall(new Object[]{0, 3, 0x00FFFFFF});
ic.destroy();
x1 = new VoidCall("Gdi32", "SelectObject");
x1.executeCall(new Object[]{hdc, pen});
x1.destroy();
}
ic = new IntCall("gdi32", "Ellipse");
ic.executeCall(new Object[]{hdc, x, y, (x + radius), (y + radius)});
ic.destroy();
ic = new IntCall("gdi32", "DeleteObject");
ic.executeCall(new Object[]{pen});
ic.destroy();
ic = new IntCall("gdi32", "DeleteObject");
ic.executeCall(new Object[]{brush});
ic.destroy();
ic = new IntCall("gdi32", "DeleteDC");
ic.executeCall(new Object[]{hdc});
ic = new IntCall("user32", "ReleaseDC");
ic.executeCall(new Object[]{screenHDC, hdc});
ic.destroy();
} catch (Exception e) {
e.printStackTrace();
}
}
我想在桌面上绘制透明圆圈'。 有任何方法可以在桌面窗口上绘制透明形状。