Professional UI Solutions
Site Map   /  Register
 
 

Forum

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 General Discussion » Shell dialog problem while opening the first entry Collapse All
Subject Author Date
Vinit Patil Sep 29, 2009 - 10:39 PM

In shell dialog ,first entry of the dialog not selected directly, I am using shell dialog for open file.


Below is the sample code :


CExtShellDialogFile dlgShellFile(NULL,CExtShellDialogFile::__EFDT_OPEN_SINGLE);

        dlgShellFile.m_comboFileTypes.SetFilter(

          filter

            );

        if( dlgShellFile.DoModal() == IDOK )

        {

            CString pathname;

            pathname = LPCTSTR(dlgShellFile.m_arrRetValNames[0]);

            OpenDocumentFile( pathname );

        }


I check this code for Operating System " Vista "

Also I check the prof UI available  sample examples. (e.g AviFrames) I got the same action, first entry from dialog box is not selecting.


Any thing else please let me know.


Thanks in advance.

Technical Support Oct 1, 2009 - 12:47 PM

Thank you for reporting this issue. To fix it, please update the source code for the following method:

INT CExtShellListCtrl::FindItemByName(
      __EXT_MFC_SAFE_LPCTSTR strName,
      INT nStartIndex, // = -1
      bool bCompareNoCase // = true
      )
{
      ASSERT_VALID( this );
      if( _tcslen( strName ) == 0 )
            return -1;
      if( GetSafeHwnd() == NULL )
            return -1;
INT nItemCount = GetItemCount();
      if( nItemCount <= 0 )
            return -1;

      INT nItemIndex, nRetVal = -1;
      for(  nItemIndex = ( nStartIndex < 0 ) ? 0 : ( nStartIndex + 1 );
                  nItemIndex < nItemCount;
                  nItemIndex ++
            )
      {
            CExtShellItemData * pShellItemData = (CExtShellItemData*)GetItemData( nItemIndex );
            // first, try display name
            CExtSafeString _strNameBuffer = pShellItemData->m_pidlAbsolute.GetDisplayNameOf();
            LPCTSTR _strName = LPCTSTR(_strNameBuffer);
            bool bEqual = false;
            if( bCompareNoCase )
                  bEqual = ( ::_tcsicmp( _strName, LPCTSTR(strName) ) == 0 ) ? true : false;
            else
                  bEqual = ( ::_tcscmp( _strName, LPCTSTR(strName) ) == 0 ) ? true : false;
            if( bEqual )
            {
                  nRetVal = nItemIndex;
                  break;
            }
            // second, try file name
            _strNameBuffer = pShellItemData->m_pidlAbsolute.GetPath();
            _strName = LPCTSTR(_strNameBuffer);
            INT nPosChr = _strNameBuffer.ReverseFind( _T(’\\’) );
            if( nPosChr > 0 )
                  _strName += nPosChr + 1;
            bEqual = false;
            if( bCompareNoCase )
                  bEqual = ( ::_tcsicmp( _strName, LPCTSTR(strName) ) == 0 ) ? true : false;
            else
                  bEqual = ( ::_tcscmp( _strName, LPCTSTR(strName) ) == 0 ) ? true : false;
            if( bEqual )
            {
                  nRetVal = nItemIndex;
                  break;
            }
      }
      return nRetVal;
}
Please note, the automatic shell list view item selection is performed for the file open dialogs only and only of the CExtShellDialogFile::m_bFilesMustExist or CExtShellDialogFile::m_bPathMustExist property is set to true.