SAMPLE: Code Simulates Changing List Box Style

Last reviewed: April 7, 1997
Article ID: Q84978
3.00 3.10 WINDOWS kbprg kbfile

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

The windows styles specified when an application creates a list box are fixed throughout its lifetime. LBCHANGE is a file in the Microsoft Software Library that demonstrates using two list boxes to simulate changing the style of a list box.

Download LBCHANGE.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download LBCHANGE.EXE (size: 24180 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get LBCHANGE.EXE (size: 24180 bytes) 
    

MORE INFORMATION

When it creates a new window, Windows stores window style information in several internal data structures. Windows refers to these data structures when it performs window management tasks, including painting the window.

If an application calls the SetWindowLong() function to change the window style dynamically, the new information is not reflected in the internal data structures. For example, an application can't effectively change a list box from the single selection style to the multiple selection style.

An application can work around this situation in two different ways:

  • Create two list boxes with different styles. The application shows the list box with the desired style and hides the other.

    -or-

  • Destroy the existing list box and create a new list box in its place.

The LBCHANGE sample demonstrates the first method, which is simple to implement and runs efficiently. However, this method requires memory space to store two copies of the list box contents.

Although the second method uses memory more efficiently, it requires more work to implement. If the application changes the list box style often, managing the contents of the list box by saving and reloading the contents and tracking the selected items can become quite involved.


Additional reference words: 3.00 3.10 listbox softlib LBCHANGE.EXE
KBCategory: kbprg kbfile
KBSubcategory: UsrWndw
Keywords : UsrWndw kbfile kbprg
Version : 3.00 3.10
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 7, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.