代码之家  ›  专栏  ›  技术社区  ›  CuriousGeorge

非MFC CalcWindowRect()?

  •  1
  • CuriousGeorge  · 技术社区  · 14 年前

    有人知道这个API是否有非MFC版本吗?

    CalcIndowRect()

    谢谢

    2 回复  |  直到 14 年前
        1
  •  3
  •   Leo Davidson    14 年前
        2
  •  3
  •   Adam Rosenfield    14 年前

    没有精确的一对一替换函数,但是 AdjustWindowRectEx 很接近。如果使用 CWnd::adjustOutside 你需要自己调整滚动条。

    例如:

    // 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);
    }