开发者

non-MFC CalcWindowRect()?

开发者 https://www.devze.com 2023-01-27 13:24 出处:网络
does anybody know if there is a non-M开发者_高级运维FC version of this API? CalcWindowRect() thanksAdjustWindowRectExThere\'s no exact one-to-one replacement function for it, but AdjustWindowRectEx

does anybody know if there is a non-M开发者_高级运维FC version of this API?

CalcWindowRect()

thanks


AdjustWindowRectEx


There's no exact one-to-one replacement function for it, but AdjustWindowRectEx is pretty close. If using the CWnd::adjustOutside flag to account for scroll bars, you'll need to do that adjustment yourself.

For example:

// MFC version
RECT desiredClientRect = {0, 0, 640, 480};
myCwnd->CalcWindowRect(&desiredClientRect,
    ignoreScrollBars ? CWnd::adjustBorder : CWnd::adjustOutside);

// Win32 version
RECT desiredClientRect = {0, 0, 640, 480};
DWORD dwStyle = GetWindowLong(myHwnd, GWL_STYLE);
AdjustWindowRectEx(&desiredClientRect,
    dwStyle,
    (GetMenu(myHwnd) != NULL),           // bMenu
    GetWindowLong(myHwnd, GWL_EXSTYLE)); // dwExStyle
if(!ignoreScrollBars)
{
    if(dwStyle & WS_HSCROLL)
        desiredClientRect.right += GetSystemMetrics(SM_CXHSCROLL);
    if(dwStyle & WS_VSCROLL)
        desiredClientRect.bottom += GetSystemMetrics(SM_CXVSCROLL);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号