-
-
Notifications
You must be signed in to change notification settings - Fork 223
Can't get DwmGetWindowAttribute to work #527
Comments
It looks like we incorrectly use |
The native type for the pvAttribute parameter is PVOID but we were using out as well as �oid* so we were effectively using double-pointers. Fixes #527
Thanks for reporting, @Slion |
Congrats on the quick turn around. @AArnott Any chance of having an overload taking RECT as parameter much like on that stackoverflow post linked above? |
No. Our convention is to use the same types used in the native signature. But it shouldn't be hard for you to use RECT. Much easier than your original code nsippet. Something like this: unsafe void Foo()
{
PInvoke.RECT rect = new PInvoke.RECT();
PInvoke.DwmApi.DwmGetWindowAttribute(hwnd, DwmApi.DWMWINDOWATTRIBUTE.DWMWA_EXTENDED_FRAME_BOUNDS, &rect, sizeof(rect));
} Don't worry about the 'unsafe' code. It doesn't mean your caller has to be unsafe. And honestly, this way you're not responsible for allocating, freeing, and copying native memory that could leak. C# pointer code is much easier than all this |
@AArnott Thanks for that insight. When will that fix make it into a release? |
It looks like it's been quite a while, with quite a bit of work, since our last release. I'll go ahead and release to nuget.org today. |
I tried a bunch of stuff including the following all I get is null reference exception thrown by DwmGetWindowAttribute.
It's a lot faster to get it working using that solution:
https://stackoverflow.com/a/58675103/3969362
The text was updated successfully, but these errors were encountered: