BBString *bbSystemRequestDir( BBString *text,BBString *dir ){ BBString *str=&bbEmptyString; if( _usew ){ LPMALLOC shm; ITEMIDLIST *idlist; BROWSEINFOW bi={0}; wchar_t buf[MAX_PATH],*p; GetFullPathNameW( bbTmpWString(dir),MAX_PATH,buf,&p ); bi.hwndOwner=GetActiveWindow(); bi.lpszTitle=bbTmpWString( text ); bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE; bi.lpfn=BrowseForFolderCallbackW; bi.lParam=(LPARAM)buf; beginPanel(); idlist=SHBrowseForFolderW(&bi); endPanel(); if( idlist ){ SHGetPathFromIDListW( idlist,buf ); str=bbStringFromWString( buf ); //SHFree( idlist ); //?!? } } else { LPMALLOC shm; ITEMIDLIST *idlist; BROWSEINFOA bi={0}; char buf[MAX_PATH],*p; GetFullPathNameA( bbTmpCString(dir),MAX_PATH,buf,&p ); bi.hwndOwner=GetActiveWindow(); bi.lpszTitle=bbTmpCString( text ); bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE; bi.lpfn=BrowseForFolderCallbackA; bi.lParam=(LPARAM)buf; beginPanel(); idlist=SHBrowseForFolderA(&bi); endPanel(); if( idlist ){ SHGetPathFromIDListA( idlist,buf ); str=bbStringFromCString( buf ); //SHFree( idlist ); //?!? } } return str; }
static int systemPanel( BBString *text,int flags ){ int n; beginPanel(); if( _usew ){ n=MessageBoxW( GetActiveWindow(),bbTmpWString(text),appTitleW(),flags ); }else{ n=MessageBoxA( GetActiveWindow(),bbTmpCString(text),appTitleA(),flags ); } endPanel(); return n; }
bbString bbRequesters::RequestDir( bbString title,bbString dir ){ CoInitialize( 0 ); dir=dir.replace( "/","\\" ); LPMALLOC shm; BROWSEINFOW bi={0}; WCHAR buf[MAX_PATH],*p; GetFullPathNameW( dir.toWString(),MAX_PATH,buf,&p ); bi.hwndOwner=GetActiveWindow(); bi.lpszTitle=tmpWString( title ); bi.ulFlags=BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE; bi.lpfn=BrowseForFolderCallbackW; bi.lParam=(LPARAM)buf; beginPanel(); bbString str; if( ITEMIDLIST *idlist=SHBrowseForFolderW( &bi ) ){ SHGetPathFromIDListW( idlist,buf ); str=bbString( buf ); //SHFree( idlist ); //?!? } endPanel(); free( (void*)bi.lpszTitle ); str=str.replace( "\\","/" ); if( !str.endsWith( "/" ) ) str+="/"; return str; }
BBString *bbSystemRequestFile( BBString *text,BBString *exts,int defext,int save,BBString *file,BBString *dir ){ BBString *str=&bbEmptyString; if( _usew ){ wchar_t buf[MAX_PATH]; OPENFILENAMEW of={sizeof(of)}; wcscpy( buf,bbTmpWString( file ) ); of.hwndOwner=GetActiveWindow(); of.lpstrTitle=bbTmpWString( text ); of.lpstrFilter=bbTmpWString( exts ); of.nFilterIndex=defext; of.lpstrFile=buf; of.lpstrInitialDir=dir->length ? bbTmpWString( dir ) : 0; of.nMaxFile=MAX_PATH; of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR; beginPanel(); if( save ){ of.lpstrDefExt=L""; of.Flags|=OFN_OVERWRITEPROMPT; if( GetSaveFileNameW( &of ) ){ str=bbStringFromWString( buf ); } }else{ of.Flags|=OFN_FILEMUSTEXIST; if( GetOpenFileNameW( &of ) ){ str=bbStringFromWString( buf ); } } endPanel(); }else{ char buf[MAX_PATH]; OPENFILENAMEA of={sizeof(of)}; strcpy( buf,bbTmpCString( file ) ); of.hwndOwner=GetActiveWindow(); of.lpstrTitle=bbTmpCString( text ); of.lpstrFilter=bbTmpCString( exts ); of.nFilterIndex=defext; of.lpstrFile=buf; of.lpstrInitialDir=dir->length ? bbTmpCString( dir ) : 0; of.nMaxFile=MAX_PATH; of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR; beginPanel(); if( save ){ of.lpstrDefExt=""; of.Flags|=OFN_OVERWRITEPROMPT; if( GetSaveFileNameA( &of ) ){ str=bbStringFromCString( buf ); } }else{ of.Flags|=OFN_FILEMUSTEXIST; if( GetOpenFileNameA( &of ) ){ str=bbStringFromCString( buf ); } } endPanel(); } return str; }
bbString bbRequesters::RequestFile( bbString title,bbString exts,bbBool save,bbString path ){ bbString file,dir; path=path.replace( "/","\\" ); int i=path.findLast( "\\" ); if( i!=-1 ){ dir=path.slice( 0,i ); file=path.slice( 1+1 ); }else{ file=path; } if( file.length()>MAX_PATH ) return ""; if( exts.length() ){ if( exts.find( ":" )==-1 ){ exts=bbString( "Files\0*.",8 )+exts; }else{ exts=exts.replace( ":",bbString( "\0*.",3 ) ); } exts=exts.replace( ";",bbString( "\0",1 ) ); exts=exts.replace( ",",";*." )+bbString( "\0",1 ); } WCHAR buf[MAX_PATH+1]; memcpy( buf,file.data(),file.length()*2 ); buf[file.length()]=0; OPENFILENAMEW of={sizeof(of)}; of.hwndOwner=GetActiveWindow(); of.lpstrTitle=tmpWString( title ); of.lpstrFilter=tmpWString( exts ); of.lpstrFile=buf; of.lpstrInitialDir=dir.length() ? tmpWString( dir ) : 0; of.nMaxFile=MAX_PATH; of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR; bbString str; beginPanel(); if( save ){ of.lpstrDefExt=L""; of.Flags|=OFN_OVERWRITEPROMPT; if( GetSaveFileNameW( &of ) ){ str=bbString( buf ); } }else{ of.Flags|=OFN_FILEMUSTEXIST; if( GetOpenFileNameW( &of ) ){ str=bbString( buf ); } } endPanel(); free( (void*)of.lpstrTitle ); free( (void*)of.lpstrFilter ); free( (void*)of.lpstrInitialDir ); str=str.replace( "\\","/" ); return str; }