 |
|
 |
Enable the Ok button if the folder contains a particular file:
***************************************************** FolderDlg.cpp ***************************************************** Fix (CFolderDialog::EnableOK(..)): ***************************************************** - ::SendMessage( m_hWnd, BFFM_ENABLEOK, (LPARAM)bEnable, 0L); -> ::SendMessage( m_hWnd, BFFM_ENABLEOK, 0L, (LPARAM)bEnable); Replace (in CFolderDialog::CFolderDialog(..)): ***************************************************** - At the end of CFolderDialog::CFolderDialog(..) if( pszSelPath ) SetSelectedFolder( pszSelPath ); By: lstrcpy(m_InitialFolder,_T("")); if ( pszSelPath ) { if ( lstrlen(pszSelPath) < MAX_PATH ) { lstrcpy( m_InitialFolder, pszSelPath ); } SetSelectedFolder( m_InitialFolder ); } m_bIsFileRequested = FALSE; Add (at the end of CFolderDialog::OnSelChanged(..)): ***************************************************** - UpdateOkButton(szSelFol); Add (in CFolderDialog::OnIUnknown(..)): ***************************************************** - UpdateOkButton(m_InitialFolder); Add the following methods ***************************************************** VOID CFolderDialog::UpdateOkButton( IN LPCTSTR szSelFol ) { // Look if the request filename exist under this path if ( m_bIsFileRequested ) { TCHAR szFullPathName[MAX_PATH]; if ( (lstrlen(szSelFol) + lstrlen(m_strRequestFileName) + 2) > MAX_PATH ) { //Enable the Ok bttn in any cases EnableOK(TRUE); return; } lstrcpy( szFullPathName, szSelFol ); lstrcat( szFullPathName, _T("\\") ); lstrcat( szFullPathName, m_strRequestFileName ); // Try to open the file FILE *hFile; if ( (hFile = _tfopen(szFullPathName,_T("r"))) != NULL ) { // File exist, enable the Ok bttn! EnableOK(TRUE); Invalidate(); RedrawWindow(); fclose(hFile); } else { // File didn't exist, disable the Ok bttn! EnableOK(FALSE); } } else { //Enable the Ok bttn EnableOK(TRUE); } } BOOL CFolderDialog::SetRequestedFileName( IN LPCTSTR pszFileName ) { ASSERT( AfxIsValidString( pszFileName, MAX_PATH ) ); if ( lstrcpy( m_strRequestFileName, pszFileName ) ) { m_bIsFileRequested = TRUE; return (TRUE); } return (FALSE); } ***************************************************** FolderDlg.h ***************************************************** Add private: - BOOL m_bIsFileRequested; - TCHAR m_strRequestFileName[ MAX_PATH ]; - TCHAR m_InitialFolder[ MAX_PATH ]; Add public: - BOOL SetRequestedFileName( IN LPCTSTR pszFileName ); Ivan K.
|
|
|
|
 |
|
 |
Thanks, will update the article soon Ivan Krukoff
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Is there any way to reduce the scroll flickering? I tried overriding the "OnMouseWheel" handler but it never seems to get called.
This is a great class Thanks!
|
|
|
|
 |
|
 |
Thank you, this is really nice and helpful article .
I am working on a project that needs to browse into portable media devices (set root folder to browse only under particular device).
In general, if the device supports mass storage interface, it will be working perfect as a filesystem folder. However, I encounter problem with the "Portable Media Center" (such as, Creative Zen Portable Media Center) which is supporting MTP (Media Transport Protocol).
1. I have problem first at ParseDisplayName(), where I cannot even get a PIDL to the device root folder. Although I can see "+Zen Portable Media Center" under "My Computer" in Windows XP's File Explorer, but just cannot render it in the SHBrowseForFolder().
I tried to EnumObjects() and GetDisplayNameOf() from IShellFolder of MyComputer or Desktop, I do find the name of "Zen Portable Media Center", but when I use the parsing name (CLSID),
L"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}\Zen Portable Media Center"
to retrieve a PIDL, it fails all the time(E_INVALIDARG from ParseDisplayName).
2. then I tried to use "Portable Media Devices" under "Control Panel" as a root folder to browse into it. Problem is the SHBrowseForFolder() won't show any devices under "Portable Media Devices". (But the attached devices do show in Windows XP's File Explorer).
I almost gave up with using SHBrowseForFolder() for MTP supported devices. Just want to see if anyone could shed light with it.
Again, appreciate your efforts.
MTP in Windows Media Device Manager 10 SDK
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmdm10/htm/whatisnew.asp[^]
|
|
|
|
 |
|
 |
Hello,
I want to get network folder path like "\\NetworkPC\ShareFolder", but SHGetPathFromIDList returns string like
"C:\Documents and Settings\UserName\NetHood\ShareFolder - (NetworkPC)NetworkPC" ***OnSelChanged***.
SHBrowseForFolder with BIF_RETURNONLYFSDIRS flag returns "\\NetworkPC\ShareFolder" but I want to get this in callback.
Best Begards
|
|
|
|
 |
|
 |
Hi,
I sloved opening the shortcut file like "C:\Documents and Settings\UserName\NetHood\ShareFolder - (NetworkPC)NetworkPC\target.link" and then retrieve "\\NetworkPC\ShareFolder".
Thanks
|
|
|
|
 |
|
 |
Hello,
Thanks for the code, I was looking for an option to select a folder using copy-paste, which was never found in the browse-for-folder dialogs.
I ask your permission to post the adaptation of your code into a matlab DLL, in the Mathworks website (of course with credit for you)
Thanks,
Ohad Gal.
|
|
|
|
 |
|
 |
Feel free to use it, better with credits ).
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Posted:
www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8391&objectType=FILE
Thanks again,
Ohad.
|
|
|
|
 |
|
 |
Compiled and added everything alright. But the New Folder button does not show up. Any clues?
Thanks.
|
|
|
|
 |
|
 |
Make sure the BIF_NONEWFOLDERBUTTON bit is cleared in the ulFlags parameter of the CFolderDialog creation function call.
Steve
|
|
|
|
 |
|
 |
The 'New folder' button only appears to be available in the new dialog style (at least with WinXP & VS2003).
Add 'BIF_NEWDIALOGSTYLE' to the ulFlags used to initialize the instance.
Darren.
|
|
|
|
 |
|
 |
Thats very useful.
just like this:
CFolderDialog dlg(_T( "Select Folder" ), FoldPath, this,BIF_NEWDIALOGSTYLE);
|
|
|
|
 |
|
 |
Hi,
I'm getting compile errors on your demo, like:
error C2039: 'GetClassLongPtr' : is not a member of '`global namespace''
I did a search on msdn on this and it looks like it's part of the ms layer for unicode (mslu). There's an mslu sdk that you can download that contains a dll. The instruction indicate that you need to add the .lib to your project and other steps in your project to make it work. But the download didn't include the .lib and your project file doesn't seem to call out the unicows.lib.
It seems like I'm missing something here... can you tell me what I need to do to be able to compile the demo?
Thanks much!
|
|
|
|
 |
|
 |
You have 2 choices:
1. Download the newer Platform SDK
2. Rename GetClassLongPtr to GetClassLong
No Microsoft Layer for UNICODE is required.
#define __ARMEN_H__
|
|
|
|
 |
|
|
 |
|
 |
Hello,
What flag to I need to set for the call to SHBrowseForFolder() so that I will see a digital camera folder
I tried any combination of : BIF_RETURNONLYFSDIRS | BIF_RETURNFSANCESTORS , BIF_RETURNONLYFSDIRS
BUT, I do not get the Camera folder???
Thanks
Alex
|
|
|
|
 |
|
 |
Maybe Your digital camera should be installed as a removeable disk to appear in the dialogue? Try different combinations of the BROWSEINFO flags then to get it visisble in the removable drives list.
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Thanks man, but as it is installed now - it shows up when Ijust use the normal Windows Explorer - so what / how does explorer know about that folder?
Any other idea will be appreciated
Cheers
Alex
|
|
|
|
 |
|
 |
Try removing all of the flags or their diff. combinations, that's all that I can say at the moment. Never had digital camera attached to the PC. It seems to be a special folder.
#define __ARMEN_H__
|
|
|
|
 |
|
 |
Hello
That indeed seems to have done the trick... I can now see the camera folder in the listbox - BUT still have a problem - this is NOT where the images are stored...
In Windows explorer, once you click the camera folder - it shows on the right hand side window the actual folders inside the camera - then I can click to view the files in them, but in this class - clicking the camera icon - does NOT expand the tree.. so I can still not get to that folder where the actual JPG images are..
Hope you can suggest something else I could try
Cheers
Alex
|
|
|
|
 |
|
|
 |
|
 |
Yes, this looks "Interesting" BUT
1) The link to the Microsoft samples is broken - AND
2) If I use this, there is no connection to the TWAIN interface
Anyway, thanks again
Alex
|
|
|
|
 |
|
|
 |
|
 |
Hi
I am aware of this site, the problem is in that TWAIN only "Knows" about the device driver, but has ne interface into the "file system" of the digital device, so I can READ a file from the device, save it to my local hard disk - but there is no TWAIN functionality to tell me what the FILENAME of that image file is on the device like IP00027.JPG
So, any other idea how to get this will be appreciated
Thanks
Alex
|
|
|
|
 |