Apr 4, 2002 #1 Robertus Programmer Feb 16, 2001 81 RO Does anybody have some short source code wich displays the BROWSE for FOLDER Windows dialog ? I'd apreciate your help Thanks in advance!
Does anybody have some short source code wich displays the BROWSE for FOLDER Windows dialog ? I'd apreciate your help Thanks in advance!
Apr 4, 2002 1 #2 LiquidBinary Programmer Jul 27, 2001 148 US #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shlobj.h> #include <iostream> BOOL GetDirectory( HWND hWnd,LPSTR lpzTitle,LPSTR lpzConfirm, LPSTR lpzHoldDir,BOOL bConfirm ); int main() { char sHoldDir[_MAX_PATH]; std::cout << "Choose a directory..." << std::endl; GetDirectory( NULL,"Choose a folder...", "Is this the correct folder?", sHoldDir,TRUE ); std::cout<< "The directory in question: " << sHoldDir << std::endl; return 0; } BOOL GetDirectory( HWND hWnd,LPSTR lpzTitle,LPSTR lpzConfirm, LPSTR lpzHoldDir,BOOL bConfirm ) { LPITEMIDLIST pidl; IMalloc *imalloc=0; LPMALLOC pMalloc=0; BROWSEINFO bi ={ 0 }; while( TRUE ) { bi.hwndOwner =hWnd; bi.lpszTitle =lpzTitle; bi.pszDisplayName=lpzHoldDir; pidl=SHBrowseForFolder( &bi ); if( pidl ) { SHGetPathFromIDList( pidl,lpzHoldDir ); if( strcmp( lpzHoldDir,"" )==0 ) strcpy( lpzHoldDir,"C:\\" ); if( SUCCEEDED( SHGetMalloc( &imalloc ) ) ) { imalloc->Free( pidl ); imalloc->Release(); } if( bConfirm ) { if( MessageBox( hWnd,lpzHoldDir,lpzConfirm, MB_YESNO | MB_ICONQUESTION ) == IDYES ) return TRUE; } else return TRUE; } else { strcpy( lpzHoldDir,"<CANCEL>" ); return FALSE; } } } Mike L.G. mlg400@linuxmail.org Upvote 0 Downvote
#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shlobj.h> #include <iostream> BOOL GetDirectory( HWND hWnd,LPSTR lpzTitle,LPSTR lpzConfirm, LPSTR lpzHoldDir,BOOL bConfirm ); int main() { char sHoldDir[_MAX_PATH]; std::cout << "Choose a directory..." << std::endl; GetDirectory( NULL,"Choose a folder...", "Is this the correct folder?", sHoldDir,TRUE ); std::cout<< "The directory in question: " << sHoldDir << std::endl; return 0; } BOOL GetDirectory( HWND hWnd,LPSTR lpzTitle,LPSTR lpzConfirm, LPSTR lpzHoldDir,BOOL bConfirm ) { LPITEMIDLIST pidl; IMalloc *imalloc=0; LPMALLOC pMalloc=0; BROWSEINFO bi ={ 0 }; while( TRUE ) { bi.hwndOwner =hWnd; bi.lpszTitle =lpzTitle; bi.pszDisplayName=lpzHoldDir; pidl=SHBrowseForFolder( &bi ); if( pidl ) { SHGetPathFromIDList( pidl,lpzHoldDir ); if( strcmp( lpzHoldDir,"" )==0 ) strcpy( lpzHoldDir,"C:\\" ); if( SUCCEEDED( SHGetMalloc( &imalloc ) ) ) { imalloc->Free( pidl ); imalloc->Release(); } if( bConfirm ) { if( MessageBox( hWnd,lpzHoldDir,lpzConfirm, MB_YESNO | MB_ICONQUESTION ) == IDYES ) return TRUE; } else return TRUE; } else { strcpy( lpzHoldDir,"<CANCEL>" ); return FALSE; } } } Mike L.G. mlg400@linuxmail.org
Apr 5, 2002 Thread starter #3 Robertus Programmer Feb 16, 2001 81 RO Thanks a lot, LiquidBinary!!! Upvote 0 Downvote