At the end of the Color.CPP file, add the new local function, CalcClientMetrics, which interprets the WM_SIZE message's client area parameters.
/*---[CalcClientMetrics]-------------------------------------------------------
Parameters: HWND hWnd Window handle
int *nClientWidth Width in and width out
int *nClientHeight Height in and height out
int *nRightBarThickness Resulting thickness of the Y scrollbar
int *nBottomBarThickness Resulting thickness of the X scrollbar
ProtoType: Color.h
Notes: Use this function to interpret the client area width and
height parameters from the WM_SIZE message. The incoming
parameters attempt to give us the correct client area, excluding
scrollbars. But, because while processing this message we
show or hide the scrollbars, the incoming parameters often are
not correct. Therefore, we must get the true client area
dimensions, including scrollbars, and get the thickness of
scrollbars. The caller can then make its own decisions about
the size of the client area.
--------------------------------------------------------------------------*/
void CalcClientMetrics (HWND hWnd,
int *nClientWidth,
int *nClientHeight,
int *nRightBarThickness,
int *nBottomBarThickness)
{
DWORD dwStyle, dwVersion;
int cxClient, cyClient, cxScroll, cyScroll;
/* Initialize local variables */
cxClient = *nClientWidth;
cyClient = *nClientHeight;
cxScroll = GetSystemMetrics(SM_CXVSCROLL);
cyScroll = GetSystemMetrics(SM_CYHSCROLL);
dwStyle = GetWindowLong(hWnd, GWL_STYLE);
/* Adjust for the difference in how newer WIN32 versions report
scrollbar thickness when there is a window border */
dwVersion = GetVersion();
if (LOBYTE(LOWORD(dwVersion)) >= 4)
{
cxScroll += GetSystemMetrics(SM_CXBORDER);
cyScroll += GetSystemMetrics(SM_CYBORDER);
}
/* If there is a window border, subtract it from the scrollbar thickness */
if (dwStyle & WS_BORDER)
{
cxScroll -= GetSystemMetrics(SM_CXBORDER);
cyScroll -= GetSystemMetrics(SM_CYBORDER);
}
/* Add the scrollbar thickness to the client area */
if (dwStyle & WS_VSCROLL)
cxClient += cxScroll;
if (dwStyle & WS_HSCROLL)
cyClient += cyScroll;
/* Update the caller's variables */
*nClientWidth = cxClient;
*nClientHeight = cyClient;
*nRightBarThickness = cxScroll;
*nBottomBarThickness = cyScroll;
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document