MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / DoFind

Method DoFind

WinArk/PiDDBCacheTable.cpp:243–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241}
242
243void CPiDDBCacheTable::DoFind(const CString& text, DWORD flags) {
244 auto searchDown = flags & FR_DOWN;
245
246 int start = 0;
247 CString find(text);
248 auto ignoreCase = !(flags & FR_MATCHCASE);
249 if (ignoreCase)
250 find.MakeLower();
251
252 int from = searchDown ? start + 1 : start - 1 + m_Table.data.n;
253 int to = searchDown ? m_Table.data.n + start : start + 1;
254 int step = searchDown ? 1 : -1;
255
256 int findIndex = -1;
257 for (int i = from; i != to; i += step) {
258 int index = i % m_Table.data.n;
259 const auto& item = m_Table.data.info[i];
260 CString text(item.DriverName.c_str());
261 if (ignoreCase)
262 text.MakeLower();
263 if (text.Find(find) >= 0) {
264 findIndex = index;
265 break;
266 }
267
268 text.Format(L"0x%X ", item.TimeDateStamp);
269 if (ignoreCase)
270 text.MakeLower();
271 if (text.Find(find) >= 0) {
272 findIndex = index;
273 break;
274 }
275 }
276 RECT client, bar;
277 GetClientRect(&client);
278 memcpy(&bar, &client, sizeof(bar));
279 if (m_Table.showbar == 1) {
280 client.top = g_AvHighFont + 4;
281 bar.bottom = g_AvHighFont + 4;
282 }
283 else {
284 bar.bottom = bar.top;
285 }
286 int rows = (client.bottom - client.top) / g_AvHighFont;
287 if (findIndex >= 0) {
288 m_Table.offset = findIndex - findIndex%rows;
289 m_Table.data.selected = findIndex;
290 InvalidateRect(nullptr);
291 }
292 else
293 AtlMessageBox(m_hWnd, L"Not found");
294}

Callers

nothing calls this directly

Calls 1

FindMethod · 0.80

Tested by

no test coverage detected