 |
|
 |
Thank you very much . You give me so supports
|
|
|
|
 |
|
 |
Is it possible to add to your Dialog button "New Folder", which will create new folder in selected localization?
|
|
|
|
 |
|
 |
hi,
This is great piece of john,considering that i spent a lot of time searching for such a control on the net.
I would like to know if it is possible to show files of a directory as well. It would be really helpful.
Thanks
Sky Walker
|
|
|
|
 |
|
 |
I could not use SHBrowseForFolder to browse a network folder:
I mean if the initial folder is a network folder, the browse dialog does not search to that folder at the first time.
Please help me
|
|
|
|
 |
|
 |
It is nice control. Can you make hybrid control with combobox
(look like combobox but contains your treecontrol inside)
yooyo
|
|
|
|
 |
|
 |
Hi,
I have just included your dialog in an application, and I must say that I am very happy with it.
- it works very nice!
- it's extremely easy to integrate into an application
- it's very easy to use
Thank's a lot for your work and for sharing it!
I have one tiny remark: above the window, a piece of static text is sitting to display the currently selected directory. If the directory grows taller than the window width, only the first part is shown. I would prefer to show the first part, skip the middle (replaced by ... or something) and show the last part again. However I did not find time to do that.
Another option is to just show the last part, which is extremely easy to do:
replace the static text item by an edit box with the following settings:
General:
ID: IDC_EDIT_NOTE
Visible checked, rest unchecked
Styles:
Align text: left
Auto HScroll and read-only checked, rest unchecked
Extended Styles:
all unchecked
It will now look like the original static text item.
Now you'll have to dig into the code. In the file DlgGetPath.h, in the last lines of member OnSelchangedTree you will find:
//
//TODO add code here to process users selection
//
ASSERT( GetDlgItem( IDC_STATIC_NOTE ) );
SetDlgItemText( IDC_STATIC_NOTE, sPath );
Replace the IDC_STATIC_NOTE in both lines by IDC_EDIT_NOTE and add the following line below the SetDlgItemText:
((CEdit*)GetDlgItem(IDC_EDIT_NOTE))->SetSel(sPath.GetLength(), sPath.GetLength());
This last line will scroll to the end of the path.
|
|
|
|
 |
|
 |
Hi,
It does not allow you to select a network drive.
For instance, it allows the user to choose :
\\11-FileServer\MySubFolder
but not
\\11-FileServer\
The problem seems to be in DoModal()
...
if (::SHGetPathFromIDList(pidl, m_strPath.GetBuffer(MAX_PATH)) == FALSE)
...
This returns FALSE for some reasons, but I can't fix this bug...
Any ideas ?
Thanks.
Yannick.
Yannick Namia
|
|
|
|
 |
|
 |
Hi Yannick,
This seems explicitly build in in the OnSelchangedTree member function:
//Disable search on Workstation roots
if( m_Tree.GetItemData( pNMTreeView->itemNew.hItem ) ||
pNMTreeView->itemNew.hItem == m_hNetworkRoot )
{
GetDlgItem( IDOK )->EnableWindow( false );
}
else
{
GetDlgItem( IDOK )->EnableWindow( true );
sPath = GetItemPath( pNMTreeView->itemNew.hItem );
}
If you delete the first part of the if statement, thus make it: if( pNMTreeView->itemNew.hItem == m_hNetworkRoot ), your problem seems solved. However, the disadvantage is that this allows a user to select the 'entire network'... I'm not sure if you want that...
Hope this helps a bit.
Yours,
Freddy
|
|
|
|
 |
|
 |
When the dialog box comes up it displays the top level of drives. Immediately select the 'Cancel' button. A fatal error results and crashes the application.
The problem is in the override for DestroyWindow(). It removes the currently selected item. However, at this point no item has been selected to the pointer that is deleted has value 0. Not nice.
The fix:
BOOL CDlgGetPath::DestroyWindow()
{
HTREEITEM htItem = m_Tree.GetSelectedItem( );
if( htItem == 0 )
return CDialog::DestroyWindow();
//Get the current selection before heading home
m_sPath = GetItemPath( htItem );
Brad Denniston
Viewpoint Engineering
|
|
|
|
 |
|
 |
Well done on a great effort . All I was after was a simple CFileDialog type class that could select directories instead of files. Short of coding something similar myself, this class works a treat. It is so straight forward and the example source compiled the first time, no hassles.
|
|
|
|
 |
 | Icons  |  | pr0phet | 3:23 8 May '03 |
|
 |
Just wondering how you managed to get the system icons loaded into a bitmap file? Probably a very simple solution im sure...
Thanks in advance for any help.
|
|
|
|
 |
|
 |
Use SetImageList only can add 16-color image to the treectrl.
How to display a turecolor image or icon in the treectrl?
|
|
|
|
 |
|
 |
Great code with easy to follow documents had it working in no time at all, just a shame you cant view files.
|
|
|
|
 |
 | Bug.  |  | Lee W. Spencer | 11:42 12 Nov '02 |
|
 |
in the method
bool CDlgGetPath::EnumNetwork( HTREEITEM hParent )
This section of code...
if( dwResult != ERROR_NO_MORE_ITEMS )
{
TRACE( _T("*** ERROR %d - Cannot complete network drive enumeration\n"), dwResult );
break;
}
... which occurs just following the GlobalFree( (HGLOBAL) lpnrDrv );
ensures that the loop will only be executed once. Therefore, large networks will only partially be displayed...or smaller networks where a smaller cbBuffer is used. For the life of me I can not determine what that line of code was trying to accomplish.
Also, some indication to the user that the default path that they were expecting to see on initialization does not exist would be nice.
Otherwise, pretty useful in my case.
|
|
|
|
 |
|
 |
What's the fix?
I'm thinking to remove the
if( dwResult != ERROR_NO_MORE_ITEMS )
section of code that you mentioned.
And change the following code
while( dwResult != ERROR_NO_MORE_ITEMS );
to
while( dwResult == NO_ERROR );
Doing this doesn't seem to break anything but I can't test it on a large network. Can someone test and verify this? Thanks.
|
|
|
|
 |
|
 |
The line should read
if(dwResult != ERROR_NO_MORE_ITEMS && dwResult != ERROR_MORE_DATA )
{
TRACE( _T("*** ERROR %d - Cannot complete network drive enumeration\n"), dwResult );
break;
}
This will ensure the loop continues if more data needs to be read
|
|
|
|
 |
|
 |
How Can I retrieve a special path name???
Thank to all...
Margaria Ivano
|
|
|
|
 |
|
 |
I used an implementation of John's excellent work and only had one minor problem. FAT volumes are not alphabetically sorted. To get around this you can modify John's 'InsertItem' routine by adding another argument thusly:
HTREEITEM InsertItem(CTreeCtrl *pTree, HTREEITEM hParent, NETRESOURCE *const pNetResource, CString sText, int iImage, int iImageSelected = -1, HTREEITEM hInsertAfter = TVI_LAST);
You also need to change this line:
InsertStruct.hInsertAfter = TVI_LAST;
to:
InsertStruct.hInsertAfter = hInsertAfter;
Then in whatever calls you want (I did it for folder items and network share names) you can set the last argument of 'InsertItem' to TVI_SORT so that those nodes will be sorted.
Voila.
|
|
|
|
 |
|
 |
I build a MFC application for Pocket PC using EVC. I want to add this function in it.
I followed the method you mentioned. But there are lots of errors occur. Such as:
DlgGetPath.h(52) : error C2061: syntax error : identifier 'NETRESOURCE'
DlgGetPath.cpp(168) : error C2065: 'GetDriveType':undeclared identifier
...........
...........
Can you help me to solve these problems. Any help will be appreciated
Thanks!
|
|
|
|
 |
|
 |
Yes it can be customized. And I use it all the time, working just fine. Of course, when you do your own, you have more options to customize it. But why not to make your own Windows so?
But have to say, you have done a good work, and for one who need more customizations and/or have to handle all code, your one is better.
BTW, I'll copy here an example of using SHBrowseForFolder from one of my projects. Usage is simple enough
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(BROWSEINFO));
TCHAR szDiplayName[MAX_PATH];
ZeroMemory(szDiplayName, MAX_PATH);
LPITEMIDLIST lpStartFolder = NULL;
SHGetSpecialFolderLocation(GetSafeHwnd(), CSIDL_DRIVES, &lpStartFolder);
bi.hwndOwner = GetSafeHwnd();
bi.pszDisplayName = szDiplayName;
bi.lpszTitle = _T("Choose a folder");
bi.ulFlags = BIF_USENEWUI;
bi.pidlRoot = lpStartFolder;
LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);
LPMALLOC pMalloc = NULL;
SHGetMalloc(&pMalloc);
if(pIDList != NULL){
SHGetPathFromIDList(pIDList, m_csLocation.GetBuffer(MAX_PATH));
m_csLocation.ReleaseBuffer();
pMalloc->Free(pIDList);
}
pMalloc->Free(lpStartFolder);
pMalloc->Release();
Philip Patrick
"Two beer or not two beer?" (Shakesbeer)
Web-site: www.saintopatrick.com
|
|
|
|
 |
|
 |
how can i change the lpStartFolder to a given path? if only they had documented these things well :\
thanks,
-Naeim
Cartoon Law III:
Any body passing through solid matter will leave a perforation conforming to its perimeter.
|
|
|
|
 |
|
 |
Hi Lava,
Check out the sample on my web site it has the capability to set the path
http://www.mctainsh.com/MFC/PathPicker.aspx
See ya.
Have a nice day!
|
|
|
|
 |
|
 |
Thanks John for your reply. However, my question was directed towards Phillip Patrick which I failed to mention in my previous post. I'd like to change the initial folder when using the SHBrowseForFolder API call. I'd appreciate any help.
ciao,
-Naeim
Cartoon Law III:
Any body passing through solid matter will leave a perforation conforming to its perimeter.
|
|
|
|
 |
|
 |
OK after digging up the net I finally found a solution.. I'll post it here for those interested:
Wrap Phillip's code snippet in a function and make the following modifications to it:
void BrowseForDirectory( CWnd* pWndOwner, LPCTSTR title, CString& folderName )
{
TCHAR path[MAX_PATH];
LPTSTR pFolderName = folderName.GetBuffer(folderName.GetLength());
BROWSEINFO bi;
ZeroMemory(&bi, sizeof(BROWSEINFO));
TCHAR szDiplayName[MAX_PATH];
ZeroMemory(szDiplayName, MAX_PATH);
bi.hwndOwner = AfxGetMainWnd()->GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pFolderName;
bi.lpszTitle = title;
bi.ulFlags = BIF_USENEWUI | BIF_RETURNONLYFSDIRS; bi.lpfn = MyBrowseCallbackProc;
bi.lParam = (LPARAM)pFolderName;
LPITEMIDLIST pIDList = SHBrowseForFolder(&bi);
folderName.ReleaseBuffer();
LPMALLOC pMalloc = NULL;
SHGetMalloc(&pMalloc);
if(pIDList != NULL){
SHGetPathFromIDList(pIDList, path);
folderName = path;
pMalloc->Free(pIDList); }
pMalloc->Release();
}
Add the following function somewhere in-scope as well:
int CALLBACK MyBrowseCallbackProc(
HWND hwnd,
UINT uMsg,
LPARAM lParam,
LPARAM lpData
)
{
switch (uMsg) {
case BFFM_INITIALIZED:
::SendMessage( hwnd, BFFM_SETSELECTION, TRUE, lpData );
break;
}
return 0;
}
Now whenever you need the browse for folder dialog box, use the following:
.
.
.
CString folder = "C:\\Program Files\\";
BrowseForDirectory(this, "Please choose a folder", folder);
// NOTE:
// after this call, 'folder' will hold the folder that was
// selected in the browse for folder dialog.
// do some cool stuff here...
.
.
.
Thank you,
-Naeim
ps: The solution was inspired by one of Robin Leatherbarrow's forum posts on CodeGuru.
-------
Cartoon Law III:
Any body passing through solid matter will leave a perforation conforming to its perimeter.
|
|
|
|
 |
|
 |
Thanks very much! That's very helpful indeed. You chaps certainly save me a lot of time...
|
|
|
|
 |