www.pudn.com > MyPlayerbylqh.rar > DirDialog.cpp


 
#include "DirDialog.h" 
#include  
 
static int __stdcall BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) 
{ 
  CDirDialog* pDirDialogObj = (CDirDialog*)lpData; 
 
  if (uMsg == BFFM_INITIALIZED && !pDirDialogObj->m_strSelDir != NULL) 
  { 
   
  } 
  else  
  { 
 
  } 
 
  return 0; 
} 
 
 
CDirDialog::CDirDialog() 
{ 
	this->m_strPath    = (char *) new char[32768]; 
    this->m_strInitDir = NULL; 
    this->m_strSelDir  = NULL; 
    this->m_strTitle   = NULL; 
} 
 
CDirDialog::~CDirDialog() 
{ 
 
} 
 
int CDirDialog::DoBrowse() 
{ 
 
  BROWSEINFO bInfo; 
  LPITEMIDLIST pidl; 
  ZeroMemory ( (PVOID) &bInfo,sizeof (BROWSEINFO)); 
 
  if (m_strInitDir != NULL) 
  { 
    OLECHAR       olePath[MAX_PATH]; 
    ULONG         chEaten; 
    ULONG         dwAttributes; 
    HRESULT       hr; 
    LPSHELLFOLDER pDesktopFolder; 
 
 
     
	if (SUCCEEDED(SHGetDesktopFolder(&pDesktopFolder))) 
    { 
  
 
      MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, m_strInitDir, -1, 
                          olePath, MAX_PATH); 
 
  
      hr = pDesktopFolder->ParseDisplayName(NULL, 
                                            NULL, 
                                            olePath, 
                                            &chEaten, 
                                            &pidl, 
                                            &dwAttributes); 
      bInfo.pidlRoot = pidl; 
 
    } 
  } 
  
  bInfo.hwndOwner      = NULL; 
  bInfo.pszDisplayName = m_strPath; 
  bInfo.lpszTitle      = "Select Directory"; 
  bInfo.ulFlags        = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS; 
  bInfo.lpfn           = BrowseCtrlCallback; 
  bInfo.lParam         = (LPARAM)this; 
 
  if ((pidl = SHBrowseForFolder(&bInfo)) == NULL) 
  { 
	  return 0; 
  } 
 
  m_iImageIndex = bInfo.iImage; 
 
  if (SHGetPathFromIDList(pidl, m_strPath) == FALSE) 
  { 
    return 0; 
  } 
 
  return 1; 
}