Microsoft KB Archive/78241

-

{| The information in this article applies to: Microsoft Windows Software Development Kit (SDK) versions 3.1 Microsoft Win32 Application Programming Interface (API) included with: - Microsoft Windows NT versions 3.5 and 3.51 - Microsoft Windows 95 version 4.0
 * width="100%"|

SUMMARY
Although there is no single message that restricts the number of entries (lines) allowed in a list box, the limit can be imposed through the use of subclassing.

MORE INFORMATION
The following code fragment is an excerpt from a subclassing function that can be used to restrict the number of entries in a list box to no more than the constant MAXENTRIES where the lpfnOldLBFn variable points to the original list box window procedure:

long FAR PASCAL SubClassFn(hWnd, message, wParam, lParam) HWND hWnd; unsigned message; WORD wParam; LONG lParam; {

int iCount;

switch (message) {  case LB_ADDSTRING: case LB_INSERTSTRING: iCount = SendMessage(hWnd, LB_GETCOUNT, 0, 0L); if (iCount > MAXENTRIES) { /* Insert action here to inform user of limit violation */ break; }     /* fall through if less entries than maximum */

default: return CallWindowProc(lpfnOldLBProc, hWnd, message, wParam,           lParam); } }
 * }

-

Last reviewed: November 2, 1995

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.