fmx::errcode UpdateProgressDialog ( const unsigned long value, const WStringAutoPtr description )
{
    fmx::errcode error = kNoError;

    BOOL user_cancelled = progress_dialog->HasUserCancelled();

    if ( (user_cancelled != 0) || (value > progress_dialog_maximum) ) {

        progress_dialog->StopProgressDialog();
        progress_dialog->Release();
        progress_dialog = NULL;

        error = user_cancelled ? kUserCancelledError : error;

    } else {

        HRESULT result;

        if ( !description->empty () ) {
            result = progress_dialog->SetLine ( 2, description->c_str (), false, NULL );
        }

        if ( result == S_OK ) {
            result = progress_dialog->SetProgress ( value, progress_dialog_maximum );
            error = result == S_FALSE ? kNoError : (fmx::errcode)result;
        }
    }

    return error;
}
fmx::errcode UpdateProgressDialog ( const long value, const WStringAutoPtr description )
{
	fmx::errcode error = kNoError;

	bool user_cancelled = progress_dialog->HasUserCancelled();

	if ( user_cancelled || value > progress_dialog_maximum ) {

		progress_dialog->StopProgressDialog();
		progress_dialog->Release();
        progress_dialog = NULL;

		error = user_cancelled ? kUserCancelledError : error;

	} else {

		if ( !description->empty () ) {
			error = progress_dialog->SetLine ( 2, description->c_str (), false, NULL );
		}

		if ( error == S_OK ) {
			error = progress_dialog->SetProgress ( value, progress_dialog_maximum );
			error = error == S_FALSE ? kNoError : error;
		}
	}

	return error;
}
WStringAutoPtr SelectFolder ( WStringAutoPtr prompt, WStringAutoPtr in_folder )
{
    BROWSEINFO browse_info = { 0 };
    browse_info.hwndOwner = GetActiveWindow();
    browse_info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
    browse_info.lpszTitle = prompt->c_str();
    if ( !in_folder->empty() ) {
        browse_info.lpfn = SelectFolderCallback;
        browse_info.lParam = (LPARAM)in_folder->c_str();
    }

    LPITEMIDLIST item_list = SHBrowseForFolder ( &browse_info );

    // if the user hasn't cancelled the dialog get the path to the folder

    wchar_t path[MAX_PATH] = L"";

    if ( item_list != 0 ) {
        SHGetPathFromIDList ( item_list, path );
    }

    return WStringAutoPtr ( new wstring ( path ) );

}	//	SelectFolder