Index: base/applications/rapps/winmain.c =================================================================== --- base/applications/rapps/winmain.c (revision 59187) +++ base/applications/rapps/winmain.c (working copy) @@ -8,13 +8,37 @@ #include "rapps.h" +const DWORD SEARCH_TIMER_ID = 0x5352; /* 'SR' in hex */ + HWND hMainWnd; HINSTANCE hInst; HIMAGELIST hImageTreeView = NULL; INT SelectedEnumType = ENUM_ALL_COMPONENTS; SETTINGS_INFO SettingsInfo; +WCHAR szSearchPattern[MAX_STR_LEN] = {0}; +BOOL +SearchPatternMatch(const WCHAR* str, const WCHAR* ptn) +{ + /* TODO: Improve pattern search beyond a simple case-insensitive substring search. */ + + int i, range; + int ptnLen = wcslen(ptn); + + if(ptnLen == 0) return TRUE; + + range = wcslen(str) - ptnLen; + + for(i=0;i<=range;i++) + { + if(_wcsnicmp(str+i,ptn,ptnLen)==0) + return TRUE; + } + + return FALSE; +} + VOID FillDefaultSettings(PSETTINGS_INFO pSettingsInfo) { @@ -103,6 +127,9 @@ PINSTALLED_INFO ItemInfo; WCHAR szText[MAX_PATH]; INT Index; + + if(!SearchPatternMatch(lpName,szSearchPattern)) + return TRUE; ItemInfo = HeapAlloc(GetProcessHeap(), 0, sizeof(INSTALLED_INFO)); if (!ItemInfo) return FALSE; @@ -143,6 +170,9 @@ PAPPLICATION_INFO ItemInfo; INT Index; + if(!SearchPatternMatch(Info.szName,szSearchPattern) && !SearchPatternMatch(Info.szName,szSearchPattern)) + return TRUE; + /* Only add a ListView entry if... - no RegName was supplied (so we cannot determine whether the application is installed or not) or - a RegName was supplied and the application is not installed @@ -211,7 +241,7 @@ /* Destroy old image list */ if (hImageListView) - ImageList_Destroy(hImageListView); + ImageList_Destroy(hImageListView); SelectedEnumType = EnumType; @@ -337,6 +367,13 @@ return FALSE; } +VOID CALLBACK +SearchTimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) +{ + KillTimer(hwnd, SEARCH_TIMER_ID); + UpdateApplicationsList(-1); +} + VOID MainWndOnCommand(HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -370,8 +407,23 @@ break; case EN_CHANGE: - /* TODO: Implement search */ - break; + { + WCHAR szWndText[MAX_STR_LEN]; + + LoadStringW(hInst, IDS_SEARCH_TEXT, szBuf, sizeof(szBuf) / sizeof(WCHAR)); + GetWindowTextW(hSearchBar, szWndText, MAX_STR_LEN); + if (wcscmp(szBuf, szWndText) != 0) + { + wcscpy(szSearchPattern, szWndText); + } + else + { + szSearchPattern[0]=0; + } + + SetTimer(hwnd, SEARCH_TIMER_ID, 250, SearchTimerProc); + } + break; } return;