How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017
Environment: Visual C++ 6, IE 5
This example program and code show you one of the ways to use the new, mostly undocumented, FilterBar feature of the ListView control that is available with IE5.0 (or greater). While the example application works, it is by no means an optimal example of how to use this new feature(!).
With IE5.0 comes a new feature for the ListView Control: the FilterBar. An example of how to use this new feature is in the example application (see above). For more information browse through your CommCtrl.h file. (Actually, this is a very smart thing to do each time you install a new version of the SDK! You might be suprised what you can find! This FilterBar stuff is one example, there is also a new Rebar style! Check it out for yourself!)
Using this new feature is simple. First, apply the HDS_FILTERBAR style to the ListView control's Header control. This tells the ListView's Header control to show the FilterBar (filter controls):
m_lcList.GetHeaderCtrl() -> ModifyStyle( 0, HDS_FILTERBAR ); // Add The FilterBar StyleThen, specify the Filter Types for the Columns. In the following example code, I set the Filter Type to HDFT_ISSTRING, which is the String filter type:
HDITEM hdItem; hdItem.mask = ( HDI_FILTER ); // Set Mask For Filter Type Information hdItem.type = HDFT_ISSTRING; // Set String Filter Type pHeader -> SetItem( 0, &hdItem ); // Set Item Information pHeader -> SetItem( 1, &hdItem ); // Set Item Information pHeader -> SetItem( 2, &hdItem ); // Set Item InformationNow, use the HDM_SETFILTERCHANGETIMEOUT message to set the Timeout value for Filter Change notifications. This allows the user to type in a value without the application constantly processing Filter Change notifications. On the other hand, if you want to get a notification for each character, you could try setting the Timeout value to a very small number. This is useful for incremental filtering.
m_lcList.GetHeaderCtrl() -> SendMessage( HDM_SETFILTERCHANGETIMEOUT, 0, 1000 ); // Set One Second Timeout (Milliseconds)All that is left to do is to process the notification messages sent by the FilterBar. These notification messages are:
HDN_FILTERCHANGE Sent to notify you of changes to the Filter HDN_FILTERBTNCLICK Sent to notify you of the FilterBar button being pressedSee the CommCtrl.h file for more information on the above notification messages, and the structures they use.
To get filter information from the control, you use the HDITEM structure, which now has two additional data members, type and pvFilter. Set the mask member of the HDITEM structure with the HDI_FILTER value to manipulate the FilterBar specific members. The type member is used to specify the Filter type, and can accept the following values:
HDFT_ISSTRING Filter type is String HDFT_ISNUMBER Filter type is Number (int) HDFT_HASNOVALUE Filter is Empty (Setting this value will clear the existing Filter)The pvFilter member is used to obtain the value in the filter. If type is set to HDFT_ISNUMBER, pvFilter should point to an int. If type is set to HDFT_ISSTRING, pvFilter is a pointer to an HDTEXTFILTER structure, which itself contains a pointer to a buffer, and the (character) length of the buffer. (Note that I could not get the Number type to work correctly.)
After calling CHeaderCtrl::GetItem(...), the pvFilter (int or HDTEXTFILTER structure pointer) should be populated with the Filter data. What you do with this data is up to you.
In the Example Application, this filter data is used to perform incremental filtering of the set of data, and then the resulting data set, if any, is displayed.
While I am no expert with the FilterBar stuff, I would be more than happy to try to answer any questions about it. Have fun!
DownloadsDownload demo application - 40 Kb
Download demo project - 8 Kb
Download source - 16 Kb