From: <arn...@us...> - 2008-03-29 07:16:09
|
Revision: 1079 http://dcplusplus.svn.sourceforge.net/dcplusplus/?rev=1079&view=rev Author: arnetheduck Date: 2008-03-29 00:16:04 -0700 (Sat, 29 Mar 2008) Log Message: ----------- Sanitize smartwin folder dialog and use it Modified Paths: -------------- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp dcplusplus/trunk/win32/CertificatesPage.cpp dcplusplus/trunk/win32/DirectoryListingFrame.cpp dcplusplus/trunk/win32/DownloadPage.cpp dcplusplus/trunk/win32/FavoriteDirsPage.cpp dcplusplus/trunk/win32/LogPage.cpp dcplusplus/trunk/win32/QueueFrame.cpp dcplusplus/trunk/win32/SearchFrame.cpp dcplusplus/trunk/win32/UploadPage.cpp dcplusplus/trunk/win32/WinUtil.cpp dcplusplus/trunk/win32/WinUtil.h Added Paths: ----------- dcplusplus/trunk/smartwin/include/smartwin/widgets/FolderDialog.h dcplusplus/trunk/smartwin/source/widgets/FolderDialog.cpp Removed Paths: ------------- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h Property Changed: ---------------- dcplusplus/trunk/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: bzr:revision-info - timestamp: 2008-03-27 14:07:03.299000025 +0100 committer: zouzou123gen properties: branch-nick: bzr + timestamp: 2008-03-27 22:58:31.127000093 +0100 committer: Jacek Sieka <arn...@gm...> properties: branch-nick: dcplusplus Name: bzr:file-ids - help/dialog_adls_properties.html dialog_adls_properti-20080327130650-2gvj3h7gyx1brkrc-1 help/dialog_favorite_hub.html dialog_favorite_hub.-20080327130637-c5ov7rnec0b8vtnl-1 help/links.html 486@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:help%2FLinks.html + smartwin/include/smartwin/widgets/FolderDialog.h 712@f586c4b0-9d0d-0410-bc51-f1fe239209fc:dcplusplus%2Ftrunk:smartwin%2Finclude%2Fsmartwin%2Fwidgets%2FWidgetChooseFolder.h smartwin/source/widgets/FolderDialog.cpp folderdialog.cpp-20080327215752-664xme4q5cf4ka0s-1 Name: bzr:revision-id:v3-trunk1 - 1027 arn...@gm...-20080323183926-schknwnkgeo7ivdn 1028 zouzou123gen-20080323220411-r8usuc3qxwuh7zsn 1029 zouzou123gen-20080323221249-0su72zaj13e706mk 1030 arn...@gm...-20080324140623-muba1dl46m000o8c 1031 zouzou123gen-20080324141933-qbgr93ugpe0297m6 1032 arn...@gm...-20080324153706-siidja05n84i00b1 1033 arn...@gm...-20080324153823-lhn3awurnu77riln 1034 arn...@gm...-20080324165650-zapppziji67yf5a2 1035 zouzou123gen-20080324175936-4mqc2kh0lo5wtdu2 1036 zouzou123gen-20080325004602-6wdsoym95mjuhwd3 1037 arn...@gm...-20080325100659-8fqy6q65itmghlep 1038 zouzou123gen-20080325175216-s297sdiucukfvijh 1039 arn...@gm...-20080325210137-3dfqyoi8ykosy087 1040 arn...@gm...-20080325211747-nwwy1eb33r071sca 1041 arn...@gm...-20080326084110-qbselrjckku275xi 1042 zouzou123gen-20080326123631-35642mgbk2i4ty32 1043 zouzou123gen-20080326124345-f4xwn2d3ty8ubd6r 1044 arn...@gm...-20080326162031-il0nyms30w0mky43 1045 arn...@gm...-20080326164801-8dru8mjc06xgzjpv 1046 arn...@gm...-20080326170438-uzl2rx8fqnohak7g 1047 zouzou123gen-20080326172821-d6uqcbmfb0c6rwlv 1048 arn...@gm...-20080326213257-qlgdh7m2712p2l0q 1049 arn...@gm...-20080326214313-ktnoekgk3s0wmatz 1050 arn...@gm...-20080326215256-0j1iqrf286b9g7zf 1051 arn...@gm...-20080327082121-hoi22wh1gwjdfbyd 1052 arn...@gm...-20080327120639-um3tukdt374rwvgm 1053 zouzou123gen-20080327130703-6vtek6uxy3vua543 + 1027 arn...@gm...-20080323183926-schknwnkgeo7ivdn 1028 zouzou123gen-20080323220411-r8usuc3qxwuh7zsn 1029 zouzou123gen-20080323221249-0su72zaj13e706mk 1030 arn...@gm...-20080324140623-muba1dl46m000o8c 1031 zouzou123gen-20080324141933-qbgr93ugpe0297m6 1032 arn...@gm...-20080324153706-siidja05n84i00b1 1033 arn...@gm...-20080324153823-lhn3awurnu77riln 1034 arn...@gm...-20080324165650-zapppziji67yf5a2 1035 zouzou123gen-20080324175936-4mqc2kh0lo5wtdu2 1036 zouzou123gen-20080325004602-6wdsoym95mjuhwd3 1037 arn...@gm...-20080325100659-8fqy6q65itmghlep 1038 zouzou123gen-20080325175216-s297sdiucukfvijh 1039 arn...@gm...-20080325210137-3dfqyoi8ykosy087 1040 arn...@gm...-20080325211747-nwwy1eb33r071sca 1041 arn...@gm...-20080326084110-qbselrjckku275xi 1042 zouzou123gen-20080326123631-35642mgbk2i4ty32 1043 zouzou123gen-20080326124345-f4xwn2d3ty8ubd6r 1044 arn...@gm...-20080326162031-il0nyms30w0mky43 1045 arn...@gm...-20080326164801-8dru8mjc06xgzjpv 1046 arn...@gm...-20080326170438-uzl2rx8fqnohak7g 1047 zouzou123gen-20080326172821-d6uqcbmfb0c6rwlv 1048 arn...@gm...-20080326213257-qlgdh7m2712p2l0q 1049 arn...@gm...-20080326214313-ktnoekgk3s0wmatz 1050 arn...@gm...-20080326215256-0j1iqrf286b9g7zf 1051 arn...@gm...-20080327082121-hoi22wh1gwjdfbyd 1052 arn...@gm...-20080327120639-um3tukdt374rwvgm 1053 zouzou123gen-20080327130703-6vtek6uxy3vua543 1054 arn...@gm...-20080327215831-dmg5mkufskabwkro Modified: dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/smartwin/include/smartwin/WidgetFactory.h 2008-03-29 07:16:04 UTC (rev 1079) @@ -30,9 +30,9 @@ #include "../SmartUtil.h" #include "widgets/Button.h" +#include "widgets/FolderDialog.h" #include "widgets/WidgetCheckBox.h" #include "widgets/WidgetChooseColor.h" -#include "widgets/WidgetChooseFolder.h" #include "widgets/WidgetComboBox.h" #include "widgets/WidgetListView.h" #include "widgets/WidgetDateTimePicker.h" @@ -96,6 +96,14 @@ : public WidgetFactoryPlatformImplementation< ContainerWidgetType, CurrentPlatform > { public: + // Bring widgets into the namespace of the class that inherits from us + + typedef SmartWin::Button Button; + typedef typename Button::ObjectType ButtonPtr; + + typedef SmartWin::FolderDialog FolderDialog; + + /// MessageBox class and object type. typedef SmartWin::WidgetMessageBox WidgetMessageBox; @@ -129,12 +137,6 @@ /// StatusBarSections object type. typedef typename WidgetStatusBarSections::ObjectType WidgetStatusBarSectionsPtr; - /// Button class type. - typedef SmartWin::Button Button; - - /// Button object type. - typedef typename Button::ObjectType ButtonPtr; - /// MDIWindow class type. typedef SmartWin::WidgetMDIParent WidgetMDIParent; @@ -177,9 +179,6 @@ /// RadioButton object type. typedef typename WidgetRadioButton::ObjectType WidgetRadioButtonPtr; - /// WidgetChooseFolder class type. - typedef SmartWin::WidgetChooseFolder WidgetChooseFolder; - /// LoadFileDialog class type. typedef SmartWin::WidgetLoadFile WidgetLoadFile; @@ -251,7 +250,7 @@ /// Creates a ChooseFolderDialog and returns a pointer to it. /** Use this one to construct a ( stack object ) to show a Choose folder Dialog */ - WidgetChooseFolder createChooseFolder(); + FolderDialog createFolderDialog(); /// Creates a LoadFileDialog and returns a pointer to it. /** Use this one to construct a ( stack object ) to show a Load File Dialog @@ -480,10 +479,10 @@ {} template<typename ContainerWidgetType> -typename WidgetFactory< ContainerWidgetType >::WidgetChooseFolder -WidgetFactory< ContainerWidgetType >::createChooseFolder() +typename WidgetFactory< ContainerWidgetType >::FolderDialog +WidgetFactory< ContainerWidgetType >::createFolderDialog() { - return WidgetChooseFolder ( this ); + return FolderDialog ( this ); } template<typename ContainerWidgetType> Copied: dcplusplus/trunk/smartwin/include/smartwin/widgets/FolderDialog.h (from rev 1078, dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h) =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/FolderDialog.h (rev 0) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/FolderDialog.h 2008-03-29 07:16:04 UTC (rev 1079) @@ -0,0 +1,122 @@ +/* + Copyright (c) 2005, Thomas Hansen + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the SmartWin++ nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +#ifndef WidgetChooseFolder_h +#define WidgetChooseFolder_h + +#include "../Widget.h" +#include "../../SmartUtil.h" +#include <shlobj.h> + +namespace SmartWin +{ +// begin namespace SmartWin + +/// ChooseFolderDialog class +/** \ingroup WidgetControls + * \image html ChooseFolder.PNG + * Class for showing a ChooseFolderDialog box. <br> + * Either derive from it or call WidgetFactory::createChooseFolder. <br> + * Note! <br> + * If you wish to use this class with Parent classes other than those from SmartWin + * you need to expose a public function called "parent" taking no arguments returning + * and HWND in the Parent template parameter. <br> + * the complete signature of the function will then be "HWND parent()" + */ +class FolderDialog +{ +public: + /// Class type + typedef FolderDialog ThisType; + + /// Object type + /** Note, not a pointer!!!! + */ + typedef ThisType ObjectType; + + // Constructor Taking pointer to parent + explicit FolderDialog( Widget * parent = 0 ); + + /// Shows the dialog + /** Returns string() or "empty string" if user press cancel. <br> + * Returns a "folder path" if user presses ok. <br> + * Use the inherited functions AspectfolderFilter::addFilter and + * AspectfolderFilter::activeFilter <br> + * before calling this function, if you wish the dialog to show only certain + * types of folders. + */ + bool open(SmartUtil::tstring& folder); + + /// Sets the root directory in the WidgetChooseFolder Widget + /** If given your dialog will try to start with the given directory as root, otherwise it + * will use the desktop directory. + */ + FolderDialog& setRoot( const int CSIDL = CSIDL_DESKTOPDIRECTORY ); + + FolderDialog& setTitle( const SmartUtil::tstring& title ); + + ~FolderDialog(); + +private: + static int CALLBACK browseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) + { + if(lpData && uMsg == BFFM_INITIALIZED) { + ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); + } + return 0; + } + + Widget* itsParent; + SmartUtil::tstring itsTitle; + LPITEMIDLIST itsPidlRoot; + + HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } + +}; + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// Implementation of class +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +inline FolderDialog::FolderDialog( Widget * parent ) + : itsParent( parent ), itsPidlRoot(NULL) +{ +} + +inline FolderDialog& FolderDialog::setTitle( const SmartUtil::tstring& title ) { + itsTitle = title; + return *this; +} + +inline FolderDialog::~FolderDialog() { + ::CoTaskMemFree(itsPidlRoot); +} + +// end namespace SmartWin +} + +#endif Deleted: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetChooseFolder.h 2008-03-29 07:16:04 UTC (rev 1079) @@ -1,165 +0,0 @@ -/* - Copyright (c) 2005, Thomas Hansen - All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, - are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - * Neither the name of the SmartWin++ nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -#ifndef WidgetChooseFolder_h -#define WidgetChooseFolder_h - -#include "../Widget.h" -#include "../../SmartUtil.h" -#include <shlobj.h> - -namespace SmartWin -{ -// begin namespace SmartWin - -/// ChooseFolderDialog class -/** \ingroup WidgetControls - * \image html ChooseFolder.PNG - * Class for showing a ChooseFolderDialog box. <br> - * Either derive from it or call WidgetFactory::createChooseFolder. <br> - * Note! <br> - * If you wish to use this class with Parent classes other than those from SmartWin - * you need to expose a public function called "parent" taking no arguments returning - * and HWND in the Parent template parameter. <br> - * the complete signature of the function will then be "HWND parent()" - */ -class WidgetChooseFolder -{ -public: - /// Class type - typedef WidgetChooseFolder ThisType; - - /// Object type - /** Note, not a pointer!!!! - */ - typedef ThisType ObjectType; - - /// Shows the dialog - /** Returns string() or "empty string" if user press cancel. <br> - * Returns a "folder path" if user presses ok. <br> - * Use the inherited functions AspectfolderFilter::addFilter and - * AspectfolderFilter::activeFilter <br> - * before calling this function, if you wish the dialog to show only certain - * types of folders. - */ - SmartUtil::tstring showDialog(); - - // Constructor Taking pointer to parent - explicit WidgetChooseFolder( Widget * parent = 0 ); - - /// Sets the root directory in the WidgetChooseFolder Widget - /** If given your dialog will try to start with the given directory as root, otherwise it - * will use the desktop directory. - */ - void setRootDirectory( const int CSIDL = CSIDL_DESKTOPDIRECTORY ) - { - bool ok = false; - ///WARNING: WINDOWSNT SHOULD NOT SUPPORT THIS FUNCTION - if ( itsParent != NULL ) - ok = SUCCEEDED( SHGetSpecialFolderLocation( itsParent->handle(), CSIDL, & itsPidlRoot ) ); - else - ok = SUCCEEDED( SHGetSpecialFolderLocation( NULL, CSIDL, & itsPidlRoot ) ); - if ( !ok ) - itsPidlRoot = NULL; - } - - void setTitleText( SmartUtil::tstring TitleText ) - { - itsTitleText = TitleText; - } - - /// Sets the starting directory selected in the WidgetChooseFolder widget - /** If given your dialog will try to start with the given directory selected. - */ - void setStartDirectory( SmartUtil::tstring startDir ) - { - itsStartDir = startDir; - } - - ~WidgetChooseFolder() - { - ::CoTaskMemFree(itsPidlRoot); - } - -private: - static int CALLBACK browseCallbackProc( HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData ) - { - if(lpData && uMsg == BFFM_INITIALIZED) { - ::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData); - } - return 0; - } - - Widget* itsParent; - SmartUtil::tstring itsTitleText; - LPITEMIDLIST itsPidlRoot; - SmartUtil::tstring itsStartDir; - - HWND getParentHandle() { return itsParent ? itsParent->handle() : NULL; } - -}; - -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Implementation of class -/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -inline SmartUtil::tstring WidgetChooseFolder::showDialog() -{ - SmartUtil::tstring retVal = _T( "" ); - BROWSEINFO bws = { 0 }; - bws.hwndOwner = itsParent->handle(); - bws.pidlRoot = itsPidlRoot; - bws.pszDisplayName = NULL; - bws.lpszTitle = itsTitleText.c_str(); - bws.ulFlags = BIF_USENEWUI; - bws.lpfn = NULL; - bws.lParam = !itsStartDir.empty() ? reinterpret_cast<LPARAM>(itsStartDir.c_str()) : 0; - bws.lpfn = &browseCallbackProc; - - LPITEMIDLIST lpIDL = SHBrowseForFolder( & bws ); - if ( lpIDL ) - { - TCHAR temp_path[MAX_PATH + 1]; - temp_path[0] = _T( '\0' ); - if ( !SHGetPathFromIDList( lpIDL, & temp_path[0] ) ) - temp_path[0] = _T( '\0' ); - else - retVal = temp_path; - - ::CoTaskMemFree(lpIDL); - } - return retVal; -} - -inline WidgetChooseFolder::WidgetChooseFolder( Widget * parent ) - : itsParent( parent ), itsPidlRoot(NULL) -{ -} - -// end namespace SmartWin -} - -#endif Modified: dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h =================================================================== --- dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/smartwin/include/smartwin/widgets/WidgetTreeView.h 2008-03-29 07:16:04 UTC (rev 1079) @@ -406,7 +406,6 @@ inline void WidgetTreeView::setSelectedImpl(HTREEITEM item) { TreeView_SelectItem( this->handle(), item ); - TreeView_EnsureVisible(this->handle(), item); } inline size_t WidgetTreeView::countSelectedImpl() const { Added: dcplusplus/trunk/smartwin/source/widgets/FolderDialog.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/FolderDialog.cpp (rev 0) +++ dcplusplus/trunk/smartwin/source/widgets/FolderDialog.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -0,0 +1,49 @@ +#include "../../include/smartwin/widgets/FolderDialog.h" + +namespace SmartWin { + +FolderDialog& FolderDialog::setRoot( const int csidl ) { + if (FAILED(SHGetSpecialFolderLocation( getParentHandle(), csidl, &itsPidlRoot ))) { + itsPidlRoot = NULL; + } + return *this; +} + +bool FolderDialog::open(SmartUtil::tstring& folder) { + BROWSEINFO bws = { 0 }; + bws.hwndOwner = getParentHandle(); + bws.pidlRoot = itsPidlRoot; + if(!itsTitle.empty()) { + bws.lpszTitle = itsTitle.c_str(); + } + bws.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS | BIF_EDITBOX; + if(!folder.empty()) { + bws.lParam = reinterpret_cast<LPARAM>(folder.c_str()); + bws.lpfn = &browseCallbackProc; + } + + // Avoid errors about missing cdroms, floppies etc.. + UINT oldErrorMode = ::SetErrorMode(SEM_FAILCRITICALERRORS); + + LPITEMIDLIST lpIDL = SHBrowseForFolder( & bws ); + + ::SetErrorMode(oldErrorMode); + + if(lpIDL) { + TCHAR buf[MAX_PATH + 1]; + if ( ::SHGetPathFromIDList( lpIDL, buf ) ) { + folder = buf; + + if(folder.size() > 0 && folder[folder.size()-1] != _T('\\')) { + folder += _T('\\'); + } + + ::CoTaskMemFree(lpIDL); + return true; + } + ::CoTaskMemFree(lpIDL); + } + return false; +} + +} Modified: dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp =================================================================== --- dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/smartwin/source/widgets/WidgetListView.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -106,9 +106,7 @@ } void WidgetListView::setSelectedImpl(int item) { - clearSelection(); ListView_SetItemState(handle(), item, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); - ListView_EnsureVisible(handle(), item, FALSE); } void WidgetListView::clearSelection() { Modified: dcplusplus/trunk/win32/CertificatesPage.cpp =================================================================== --- dcplusplus/trunk/win32/CertificatesPage.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/CertificatesPage.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -102,7 +102,7 @@ void CertificatesPage::handleBrowseTrustedPathClicked() { tstring target = trustedCertificatesPath->getText(); - if(WinUtil::browseDirectory(target, handle())) + if(createFolderDialog().open(target)) trustedCertificatesPath->setText(target); } Modified: dcplusplus/trunk/win32/DirectoryListingFrame.cpp =================================================================== --- dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/DirectoryListingFrame.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -482,7 +482,7 @@ ItemInfo* ii = dirs->getSelectedData(); if(ii) { tstring target = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { WinUtil::addLastDir(target); download(ii, Text::fromT(target)); } @@ -499,7 +499,7 @@ } } else { tstring target = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { WinUtil::addLastDir(target); dl->download(ii->dir, Text::fromT(target), WinUtil::isShift()); } @@ -509,7 +509,7 @@ } } else { tstring target = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { WinUtil::addLastDir(target); downloadFiles(Text::fromT(target)); } Modified: dcplusplus/trunk/win32/DownloadPage.cpp =================================================================== --- dcplusplus/trunk/win32/DownloadPage.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/DownloadPage.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -120,7 +120,7 @@ void DownloadPage::handleBrowseDir() { tstring dir = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(dir, handle())) + if(createFolderDialog().open(dir)) { // Adjust path string if(dir.size() > 0 && dir[dir.size() - 1] != '\\') @@ -132,7 +132,7 @@ void DownloadPage::handleBrowseTempDir() { tstring dir = Text::toT(SETTING(TEMP_DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(dir, handle())) + if(createFolderDialog().open(dir)) { // Adjust path string if(dir.size() > 0 && dir[dir.size() - 1] != '\\') Modified: dcplusplus/trunk/win32/FavoriteDirsPage.cpp =================================================================== --- dcplusplus/trunk/win32/FavoriteDirsPage.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/FavoriteDirsPage.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -149,8 +149,9 @@ void FavoriteDirsPage::handleAddClicked() { tstring target; - if(WinUtil::browseDirectory(target, handle())) + if(createFolderDialog().open(target)) { addDirectory(target); + } } void FavoriteDirsPage::addDirectory(const tstring& aPath) { Modified: dcplusplus/trunk/win32/LogPage.cpp =================================================================== --- dcplusplus/trunk/win32/LogPage.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/LogPage.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -118,12 +118,7 @@ void LogPage::handleBrowseClicked() { tstring dir = Text::toT(SETTING(LOG_DIRECTORY)); - if(WinUtil::browseDirectory(dir, handle())) - { - // Adjust path string - if(dir.size() > 0 && dir[dir.size() - 1] != '\\') - dir += '\\'; - + if(createFolderDialog().open(dir)) { setItemText(IDC_LOG_DIRECTORY, dir); } } Modified: dcplusplus/trunk/win32/QueueFrame.cpp =================================================================== --- dcplusplus/trunk/win32/QueueFrame.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/QueueFrame.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -727,7 +727,7 @@ if(showTree->getChecked()) { name = Text::toT(curDir); } - if(WinUtil::browseDirectory(name, handle())) { + if(createFolderDialog().open(name)) { int i = -1; while( (i = files->getNext(i, LVNI_SELECTED)) != -1) { QueueItemInfo* ii = files->getData(i); @@ -745,7 +745,7 @@ dcassert(!curDir.empty()); tstring name = Text::toT(curDir); - if(WinUtil::browseDirectory(name, handle())) { + if(createFolderDialog().open(name)) { moveDir(item, Text::fromT(name)); } } Modified: dcplusplus/trunk/win32/SearchFrame.cpp =================================================================== --- dcplusplus/trunk/win32/SearchFrame.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/SearchFrame.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -673,14 +673,14 @@ } } else { tstring target = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { WinUtil::addLastDir(target); results->forEachSelectedT(SearchInfo::Download(target)); } } } else { tstring target = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { WinUtil::addLastDir(target); results->forEachSelectedT(SearchInfo::Download(target)); } @@ -716,7 +716,7 @@ void SearchFrame::handleDownloadDirTo() { tstring target = Text::toT(SETTING(DOWNLOAD_DIRECTORY)); - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { WinUtil::addLastDir(target); results->forEachSelectedT(SearchInfo::DownloadWhole(target)); } Modified: dcplusplus/trunk/win32/UploadPage.cpp =================================================================== --- dcplusplus/trunk/win32/UploadPage.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/UploadPage.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -242,7 +242,7 @@ void UploadPage::handleAddClicked() { tstring target; - if(WinUtil::browseDirectory(target, handle())) { + if(createFolderDialog().open(target)) { addDirectory(target); HashProgressDlg(this, true).run(); } Modified: dcplusplus/trunk/win32/WinUtil.cpp =================================================================== --- dcplusplus/trunk/win32/WinUtil.cpp 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/WinUtil.cpp 2008-03-29 07:16:04 UTC (rev 1079) @@ -402,43 +402,6 @@ lastDirs.push_back(dir); } -static int CALLBACK browseCallbackProc(HWND hwnd, UINT uMsg, LPARAM /*lp*/, LPARAM pData) { - switch(uMsg) { - case BFFM_INITIALIZED: - SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData); - break; - } - return 0; -} - -bool WinUtil::browseDirectory(tstring& target, HWND owner /* = NULL */) { - TCHAR buf[MAX_PATH]; - LPMALLOC ma; - - BROWSEINFO bi = { 0 }; - - bi.hwndOwner = owner; - bi.pszDisplayName = buf; - tstring title = T_("Choose folder"); - bi.lpszTitle = title.c_str(); - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; - bi.lParam = (LPARAM)target.c_str(); - bi.lpfn = &browseCallbackProc; - LPITEMIDLIST pidl = ::SHBrowseForFolder(&bi); - if(pidl != NULL) { - ::SHGetPathFromIDList(pidl, buf); - target = buf; - - if(target.size() > 0 && target[target.size()-1] != _T('\\')) - target+=_T('\\'); - - ::CoTaskMemFree(pidl); - - return true; - } - return false; -} - bool WinUtil::browseFile(tstring& target, HWND owner /* = NULL */, bool save /* = true */, const tstring& initialDir /* = Util::emptyString */, const TCHAR* types /* = NULL */, const TCHAR* defExt /* = NULL */) { TCHAR buf[MAX_PATH]; OPENFILENAME ofn = { 0 }; // common dialog box structure Modified: dcplusplus/trunk/win32/WinUtil.h =================================================================== --- dcplusplus/trunk/win32/WinUtil.h 2008-03-29 07:15:05 UTC (rev 1078) +++ dcplusplus/trunk/win32/WinUtil.h 2008-03-29 07:16:04 UTC (rev 1079) @@ -155,7 +155,6 @@ static void openLink(const tstring& url); static bool browseFile(tstring& target, HWND owner = NULL, bool save = true, const tstring& initialDir = Util::emptyStringT, const TCHAR* types = NULL, const TCHAR* defExt = NULL); - static bool browseDirectory(tstring& target, HWND owner = NULL); static int getOsMajor(); static int getOsMinor(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |