본문 바로가기
코드/c/c++

[MFC] 디렉토리 창 띄우기..

by WeZZ 2008. 10. 14.

 
int CALLBACK MyBrowseCallbackProc(
          HWND hwnd,
          UINT uMsg,
          LPARAM lParam,
          LPARAM lpData
          )
{
 switch (uMsg)
 {
  case BFFM_INITIALIZED:
   ::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, lpData );
  break;
 }
 return 0;
}


void CEmptyMFCDlg::DirectoryBrowerFunction()
{
 // Folder 찾기
 LPITEMIDLIST pidl;
 BROWSEINFO bi;
 char root[MAX_PATH] = {0,};
 char defaultd[MAX_PATH] = {0,};

 memcpy( defaultd , "c:\\WinDDK\\" , MAX_PATH);
 bi.hwndOwner      = NULL;
 bi.pidlRoot       = NULL;
 bi.pszDisplayName =  defaultd;
 bi.lpszTitle      = "디렉토리를 선택하세요";
 bi.ulFlags        = 0;
 bi.lpfn           = MyBrowseCallbackProc;
 bi.lParam         = (LPARAM)defaultd;

 pidl = SHBrowseForFolder(&bi);
 if (pidl == NULL) return;
 SHGetPathFromIDList(pidl, root);

 UpdateData(FALSE);
}