Microsoft KB Archive/29996

INF: Simulating a Sizeable List Box in Windows

PSS ID Number: Q29996 Article last modified on 11-04-1993

2.00 2.03 2.10 3.00 WINDOWS

= SUMMARY =

In Windows 3.0, a list box that has the WS_THICKFRAME style may be sized using the mouse. Although a sizeable list box is not supported in Windows 2.x, it is possible to simulate one by creating a list box in a child window that has a thick frame. The file LISTSIZE in the Software/Data Library contains an example of using this technique. LISTSIZE can be found in the Software/Data Library by searching on the word LISTSIZE, the Q number of this article, or S12039. LISTSIZE was archived using the PKware file-compression utility.

= MORE INFORMATION =

When the child window is sized (that is, the window receives a WM_SIZE message), the list box can be moved to fit exactly within the child window. Under Windows versions 2.x, list boxes can be sized only to an integral number of system-font text heights. Otherwise, the child window would be larger than the list box. In Windows version 3.00, the control style LBS_NOINTEGRALHEIGHT has been defined. Using this style allows the list box to be sized arbitrarily, without regard for the system font height. For backward compatibility, this control style is not used. In the LISTSIZE example, the maximum vertical height of the child window (and of the list box) is limited by the number of items in the list box. Constraints on the height of the child window also prevent the list box from being sized shorter than two list-box item heights. These limitations prevent any problems resulting from an attempt to size a window smaller than the minimum allowed by Windows. SetWindowPos is used to size the child window. MoveWindow is used to move the list box within the child window. It is possible to change the size of the window borders with the control panel while the application is running. To get the current window-frame height and caption height, GetTextMetrics is called every time a WM_SIZE message is received. Window dimensions are necessary because while the client area must be an integral number of system-font text heights, the height passed to SetWindowPos is the entire window size, including the borders.

Additional reference words: 2.00 2.03 2.10 3.00 KBCategory: KBSubcategory: UsrCtlListbox Copyright Microsoft Corporation 1993.