如何获取窗口的真实边框大小

因为Windows 10在左侧,右侧和底部都有细小的看不见的边框,它用于握住鼠标以调整大小。

边框可能看起来像这样:(7,0,7,7 左,上,右,下)

第一种方法,使用GetWindowRect()

GetWindowRect(hwnd, &rect);
rect.left += 7;
rect.top -= 0;
rect.right -= 7;
rect.bottom -= 7;

第二种方法,使用DwmGetWindowAttribute()

DwmGetWindowAttribute(hWnd, DWMWA_EXTENDED_FRAME_BOUNDS, (PVOID)&rect, sizeof(rect));

  

posted @ 2019-10-29 11:08  strive-sun  阅读(1235)  评论(0)    收藏  举报