DwmGetWindowAttribute Windows Declare

I’m trying to use the DwmGetWindowAttribute() call using a declare in a Windows application (32 and 64 bit).

I had been using a declare for GetWindowRect previously, but that function includes extra margins that aren’t helpful.

Here’s what I’m trying:

Const DWMWA_EXTENDED_FRAME_BOUNDS = 8
CONST RECT_SIZE = 16

Declare Sub DwmGetWindowAttribute Lib "Dwmapi.dll" ( w as WindowPtr, dwAttribute As UInt32, pvAttribute As Ptr, cbAttribute As UInt32 )

dim r As New MemoryBlock ( RECT_SIZE )

DwmGetWindowAttribute(App.mainWin, DWMWA_EXTENDED_FRAME_BOUNDS, r, RECT_SIZE )

MessageBox "top: " + r.Long( 4 ).ToString() + ", bottom: " + r.Long( 12 ).ToString() + ", left: "  + r.Long( 0 ).ToString() + ", right: " + r.Long( 8 ).ToString()

I’m getting all zeroes in return. Has anybody had any luck calling into Dwmapi.dll from Xojo?

Thanks!

Should be 9

2 Likes

Thanks! I didn’t realize Windows enums like that weren’t zero-based.

That did the trick.