Positioning and Sizing the Popup

The DIGCLOCK popup window is positioned at the lower right corner of the display. The window must be large enough to accommodate two lines of text of 16 characters each. The SizeTheWindow procedure in DIGCLOCK.C determines the correct parameters to use in the CreateWindow call. Normally, a program cannot obtain a text size without first creating a window, because it needs the window handle to obtain a device context handle. DIGCLOCK gets around this problem by obtaining an information device context handle for the screen using CreateIC. This function is similar to CreateDC (used in the BLOWUP program in Chapter 4) but is used to obtain information from the device context. The text size in combination with information available from GetSystemMetrics is enough to derive an initial starting position and window size.