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);
}
精彩评论