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 combobox. A virtual combo box can have up to 32,767 items in Windows 95 orWindows 98, and up to 2,147,483,647 items in Windows NT 4.0. The biggestadvantage is that the application does not have to insert the items one byone into the virtual combo box; instead it just needs to specify the numberof items by sending the virtual combo box the VCBM_SETCOUNT message. Italso needs to handle the VCBN_GETDISPINFO notification, sent in the form ofWM_NOTIFY message, by setting the string for the specified index.
The following file is available for download from the Microsoft Download Center:
Release Date: Dec-21-1998
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
Windows 95, Windows 98, and Windows NT 4.0 provide a list box style, calledLBS_NODATA, that enables you to implement a virtual list box. The basicidea is to specify to the list box a count of the number of items using theLB_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 bedrawn, it sends the parent a WM_DRAWITEM message and the parent handlesthis message by displaying the appropriate string.
The virtual combo box uses a virtual list box to implement a combo box. Thesame advantages accrue. However, instead of sending the parent aWM_DRAWITEM message, the virtual combo box simplifies the parent's job bysending a WM_NOTIFY message with a notification code of VCBN_GETDISPINFO.The structure passed with this notification specifies the index of the itemthat needs to be drawn, and requires the parent to copy the correspondingstring 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 patternedafter the corresponding combo box styles, CBS_SIMPLE, CBS_DROPDOWN, andCBS_DROPDOWNLIST, respectively. In the case of the VCBS_SIMPLE andVCBS_DROPDOWN styles, the virtual combo box has an edit control and thecombo box sends a VCBN_DISPCHANGE notification (in the form of a WM_NOTIFYmessage) when the edit control's contents change. The parent needs tohandle this notification if it wants to change the contents of the list boxto 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 theparent. The complete information about the different notifications, thedifferent combo box styles, and the virtual combo box messages is availablein the header file, Vcombobx.h.
The sample has the files for the implementation of the virtual combo boxand a file that has code to test the control. The test file demonstratesthe handling of the VCBN_GETDISPINFO and VCBN_DISPCHANGE notifications. Theedit control and the list box are superclassed and implemented in separatefiles.
There is also a DLL version of the virtual combo box, VIRTCBOX, availableas a self-extracting file. The DLL version is almost the same as theexecutable version, except for the minor differences related to thesignature of the function for initialization of the virtual combo box, andsmall changes for exporting the functions.