MFC enlisting local drives
-
Hey I want to enlist local drives in combo box ...in similar way as in "Look in :" combo box of Search in Windows 2000 professional ....Does any one knows answer..? Drushti
hi, try this Code Add A Button [OpenFolder] Edit Box For display Selected File Path[IDC_EDIT_FILEPATH] -----------------In OnOpenFolderClick function----------- { LPITEMIDLIST pidlRoot = NULL; LPITEMIDLIST pidlSelected = NULL; BROWSEINFO bi = {0}; LPMALLOC pMalloc = NULL; TCHAR szDisplayName[MAX_PATH]; SHGetMalloc(&pMalloc); pidlRoot = NULL; bi.hwndOwner = m_hWnd; bi.pidlRoot = pidlRoot; bi.pszDisplayName = szDisplayName; bi.lpszTitle = "Choose a folder"; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT; bi.lpfn = BrowseCallbackProc; bi.lParam = 0; pidlSelected = SHBrowseForFolder(&bi); if(!pidlSelected) return; if(pidlRoot) { pMalloc->Free(pidlRoot); } pMalloc->Release(); SHGetPathFromIDList(pidlSelected,szDisplayName); GetDlgItem(IDC_EDIT_FILEPATH)->SetWindowText(szDisplayName); } --------------------------------------- ------add Below Code For Call Back Fuction. Above the function ----------------------------------------------- CString g_csDefaultPath = ""; INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg,LPARAM lp, LPARAM pData) { TCHAR szDir[MAX_PATH]; strcpy(szDir,(LPSTR)(LPCSTR)g_csDefaultPath); switch(uMsg) { case BFFM_INITIALIZED: //if (GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir)) { // WParam is TRUE since you are passing a path. // It would be FALSE if you were passing a pidl. SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir); } break; case BFFM_SELCHANGED: // Set the status window to the currently selected path. if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) { SendMessage(hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir); } break; } return 0; } by baijumax
-
Hey I want to enlist local drives in combo box ...in similar way as in "Look in :" combo box of Search in Windows 2000 professional ....Does any one knows answer..? Drushti
Check out A Drop-Down-Listbox for Drives[^]Personal stuff:: Ericahist | Homepage Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ ---- You cannot truly appreciate Dilbert unless you've read it in the original Klingon.