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 handleint *nClientWidth Width in and width outint *nClientHeight Height in and height outint *nRightBarThickness Resulting thickness of the Y scrollbarint *nBottomBarThickness Resulting thickness of the X scrollbarProtoType: Color.hNotes: Use this function to interpret the client area width andheight parameters from the WM_SIZE message. The incomingparameters attempt to give us the correct client area, excludingscrollbars. But, because while processing this message weshow or hide the scrollbars, the incoming parameters often arenot correct. Therefore, we must get the true client areadimensions, including scrollbars, and get the thickness ofscrollbars. The caller can then make its own decisions aboutthe 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 reportscrollbar 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;}
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
