2
on the keypad, only names starting with the letter
a
,
b
or
c
will be displayed (both first-name and sur-name
are considered).
The control is a subclassed LISTVIEW
control.
Two columns are displayed with the control - and this is a
fixed number. The second column displays a single character
item only.
Internally the control manages its own item list, repopulates
the entire list when the filter changes and uses
a pattern matching algorithm to filter the items.
Supporting Backspace
The filter is reset when the "Back" key is pressed. However, Smartphone is real picky about the backspace key and you need to shuffle it a bit to get it working. There's an article on the Microsoft web-site that explains it, but basically you need to send aSHCMBM_OVERRIDEKEY
message to the Command Bar to override
the default behaviour and then handle WM_HOTKEY
to
relay the key-down message to the active window.
How to use it
To use it, place aLISTVIEW
control on your dialog.
This control must be created with or have the
Fixed Ownerdrawn property set in the resource editor.
Add a member variable to your dialog implementation file...
CFilterListCtrl m_list
In the OnInitDialog()
event handler, add the following line:
LRESULT OnInitDialog(UINT /*uMsg*/,
WPARAM /*wParam*/,
LPARAM /*lParam*/,
BOOL& /*bHandled*/)
{
...
m_list.SubclassWindow(GetDlgItem(IDC_LIST1));
...
}
Also add this reflection macro to your main message map:
BEGIN_MSG_MAP(CMainDlg)
...
REFLECT_NOTIFICATIONS()
END_MSG_MAP()
There's no support for images and sub-items, though the
supporting methods have not been disabled.
To insert new items, use the overloaded InsertItem()
method.
m_list.InsertItem(_T("Duck, Donald"), _T("D"));
If you need sorting and other of the LISTVIEW
control's features,
you can simply add the styles as usual to the control.
Use the GetItemData()
method to retrieve the original index of an item
once it has been selected or while you are enumerating items.
Source Code Dependencies
MS Smartphone 2003Microsoft WTL 7.5 Library
Download Files
![]() | Source Code (27 Kb) |