After years of finding answers here, this case I could not find anything so I post question about here
I try to get the transparency level of some window using GetLayeredWindowAttributes
function in Win32 API.
In C++/C, to get the transparency level I use the following code:
DWORD flags = LWA_ALPHA;
BYTE alpha;
if (GetLayeredWindowAttributes(target_hwnd, nullptr, &alpha, &flags))
{
// Here I got the value inside alpha variable
}
In Java + JNA, I did not found any straightforward example. But I think that I come with something that should work. Here is what I did in Java:
ByteByReference alpha = new ByteByReference();
if (User32.INSTANCE.GetLayeredWindowAttributes(windowHwnd,null,alpha,new IntByReference((byte) 0x00000002))) {
// Here I got the transparency in alpha.getValue()
}
The issue is that for some reason, the java code will return -27
while the C++ code will return for the same window 229
that is the correct value.
I noticed that when the transparency is 255
, both codes (Java and C++) will return 255
but for some reason, the Java code is return wrong values and I don't know why.
Any idea what I am doing wrong and how to fix it?
Thanks!