Professional UI Solutions
Site Map   /  Register


Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Answer please Collapse All
Subject Author Date
Offer Har Jan 25, 2011 - 11:42 AM
Rado Manzela Jan 25, 2011 - 3:36 PM

I was asking for this 1 or 2 years ago, then I’ve implemented it by myself, but not exactly like this, more like contact list search in miranda instant messenger. I can give you most important part of the code:

bool CChildView::OnGbwAnalyzeCellKeyEvent(    bool bKeyDownEvent,    UINT nChar,    UINT nRepCnt,    UINT nFlags) {

 CString tmp;

 UINT wScanCode = ::MapVirtualKey( nChar, 0 );  BYTE lpKeyState[256];  ::GetKeyboardState( lpKeyState );  HKL hKeyboardLayout = ::GetKeyboardLayout( ( ::AfxGetThread() ) -> m_nThreadID );  WORD nMapped = 0;  ::ToAsciiEx( nChar, wScanCode, lpKeyState, &nMapped, 1, hKeyboardLayout );  TCHAR ch = (TCHAR)nMapped;


 if (isprint(ch) || nChar == VK_BACK)  {   if (!bKeyDownEvent)    return true;     if (nChar == VK_BACK)   {    if (m_quickSearch.GetLength()>0) m_quickSearch.Delete(m_quickSearch.GetLength()-1);    else return true;   }   else   {    m_quickSearch += (TCHAR)ch;    m_quickSearch.MakeLower();   }

  if (FindAndFocus(m_quickSearch))    return true;

  m_quickSearch = ch;   m_quickSearch.MakeLower();   if (!FindAndFocus(m_quickSearch))    m_quickSearch = "";   return true;  }    m_quickSearch = "";  return CExtTreeGridWnd::OnGbwAnalyzeCellKeyEvent(bKeyDownEvent,nChar,nRepCnt,nFlags); }

m_quickSearch is buffer for  matching string typed by user while searching. FindAndFocus() focuses first matched item (in my case it is custom drawn where matched part of string is drawn with differernt color).

I hope it helps. I think it’s easy to adapt it to explorer style, you just need to remember timestamp of last key typed and invalidate (erase) whole m_quickSearch when it was too long time ago.