Microsoft KB Archive/197690

From BetaArchive Wiki

SAMPLE: VCOMBOBX a Virtual Combo Box

Q197690



The information in this article applies to:


  • Microsoft Windows NT Server version 4.0
  • Microsoft Windows NT Workstation version 4.0
  • Microsoft Windows 98
  • Microsoft Windows 95





SUMMARY

Vcombobx.exe is a sample that shows how to implement a virtual combo box.

The entire data is maintained by the application using the virtual combo box. A virtual combo box can have up to 32,767 items in Windows 95 or Windows 98, and up to 2,147,483,647 items in Windows NT 4.0. The biggest advantage is that the application does not have to insert the items one by one into the virtual combo box; instead it just needs to specify the number of items by sending the virtual combo box the VCBM_SETCOUNT message. It also needs to handle the VCBN_GETDISPINFO notification, sent in the form of WM_NOTIFY message, by setting the string for the specified index.



MORE INFORMATION

The following file is available for download from the Microsoft Download Center:


Vcombobx.exe

Release Date: Dec-21-1998

For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

Q119591 How to Obtain Microsoft Support Files from Online Services

Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.




Windows 95, Windows 98, and Windows NT 4.0 provide a list box style, called LBS_NODATA, that enables you to implement a virtual list box. The basic idea is to specify to the list box a count of the number of items using the LB_SETCOUNT message. No item is inserted. The virtual list box is an owner- drawn list box with the LBS_OWNERDRAWFIXED style. When an item needs to be drawn, it sends the parent a WM_DRAWITEM message and the parent handles this message by displaying the appropriate string.

The virtual combo box uses a virtual list box to implement a combo box. The same advantages accrue. However, instead of sending the parent a WM_DRAWITEM message, the virtual combo box simplifies the parent's job by sending a WM_NOTIFY message with a notification code of VCBN_GETDISPINFO. The structure passed with this notification specifies the index of the item that needs to be drawn, and requires the parent to copy the corresponding string to an array whose address is passed.

There are three styles you can specify for the virtual combo box, VCBS_SIMPLE, VCBS_DROPDOWN, and VCBS_DROPDOWNLIST, which are patterned after the corresponding combo box styles, CBS_SIMPLE, CBS_DROPDOWN, and CBS_DROPDOWNLIST, respectively. In the case of the VCBS_SIMPLE and VCBS_DROPDOWN styles, the virtual combo box has an edit control and the combo box sends a VCBN_DISPCHANGE notification (in the form of a WM_NOTIFY message) when the edit control's contents change. The parent needs to handle this notification if it wants to change the contents of the list box to reflect the contents of the edit control.

The virtual combo box sends notifications such as VCBN_SELCHANGE, VCBN_SETFOCUS, VCBN_KILLFOCUS, and so on, in a WM_COMMAND message to the parent. The complete information about the different notifications, the different combo box styles, and the virtual combo box messages is available in the header file, Vcombobx.h.

The sample has the files for the implementation of the virtual combo box and a file that has code to test the control. The test file demonstrates the handling of the VCBN_GETDISPINFO and VCBN_DISPCHANGE notifications. The edit control and the list box are superclassed and implemented in separate files.

There is also a DLL version of the virtual combo box, VIRTCBOX, available as a self-extracting file. The DLL version is almost the same as the executable version, except for the minor differences related to the signature of the function for initialization of the virtual combo box, and small changes for exporting the functions.

Additional query words:

Keywords : kbComboBox kbOSWinNT400 kbSDKPlatform kbOSWin95 kbOSWin98
Issue type : kbhowto
Technology : kbWinNTsearch kbWinNTWsearch kbWinNTW400 kbWinNTW400search kbWinNT400xsearch kbWinNTSsearch kbWinNTS400xsearch kbWinNTS400 kbWin95search kbWin98search kbZNotKeyword3 kbWin98


Last Reviewed: December 16, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.