4.2.5 Setting the Text Rectangles

To establish the client-area rectangles in which different messages are displayed, add the following statements to the InitInstance function:

hDC = GetDC(hWnd);
GetTextMetrics(hDC, &tm);
ReleaseDC(hWnd, hDC);
nLineHeight = tm.tmExternalLeading + tm.tmHeight;

rect.left = GetDeviceCaps(hDC, LOGPIXELSX) / 4;   /* 1/4 inch */
rect.right = GetDeviceCaps(hDC, HORZRES);
rect.top = GetDeviceCaps(hDC, LOGPIXELSY) / 4;   /* 1/4 inch */
rect.bottom = rect.top + nLineHeight;
rectMouse = rect;

rect.top += nLineHeight;
rect.bottom += nLineHeight;
rectButton = rect;

rect.top += nLineHeight;
rect.bottom += nLineHeight;
rectKeyboard = rect;



rect.top += nLineHeight;
rect.bottom += nLineHeight;
rectCharacter = rect;

rect.top += nLineHeight;
rect.bottom += nLineHeight;
rectScroll = rect;

rect.top += nLineHeight;
rect.bottom += nLineHeight;
rectTimer = rect;