|
|
Comments and Discussions
|
|
 |
|

|
hi? how to use it in vc6.0? thanks!
|
|
|
|

|
But executable has no functionality:
1. "Multiple" select will highlight more than one file in the open dialog.
2. textbox actually fills with the highlighted items -> "x" "y" "z" "aa" etc.
3. items remain highlighted there but the button "Open" causes complete freeze.
4. "Cancel" will dismiss the opn dialog but the original dialog can't be closed by any method.
5. Must open task manager to shutdown frozen application.
|
|
|
|

|
Working on a project with XP, this was working great. Before project completion I switched to Windows 7 and suddenly SelectDialog crashes in CSelectDialog::OnFileNameOK() because GetParent() returns NULL. Don't know MFC that much, so I can't estimate whether something has changed with Win7. MSDN says When you are using the Windows Vista style of the CFileDialog, you cannot use message maps and dialog templates. Instead, you will need to use the COM interfaces for similar functionality. I set VistaStyle to false as suggested, but maybe it does default to true in win7. Has anyone tested this with Windows 7 and could share it?
|
|
|
|

|
Hi,
I removed my message from yesterday as looking into this further, and using the original code as is, I cannot fault it on any version of windows 7 or 2008, it seems to work fine.
|
|
|
|

|
Hi everybody
I tested attached demo in Win 7 and saw that everything is fine except in new special folders such as Library and My docs(folders are not selected and path is not full from root).
I would try to solve it as soon as possible after I recover my deleted partitions!!! :(
|
|
|
|

|
As mentioned by some users OnInitDone function does not works in Win7 so we should add two new parameters at the end of constructor as shown below:
CSelectDialog(
BOOL bOpenFileDialog,
LPCTSTR lpszDefExt,
LPCTSTR lpszFileName,
DWORD dwFlags,
LPCTSTR lpszFilter,
CWnd* pParentWnd)
:CFileDialog(
bOpenFileDialog,
lpszDefExt,
lpszFileName,
dwFlags | OFN_EXPLORER | OFN_HIDEREADONLY &(~OFN_SHOWHELP),
lpszFilter,
pParentWnd,
0, FALSE)
|
|
|
|

|
Well, it's been some time since I posted this,
but thx, that did the trick.
I had just passed one more parameter instead of two
Now it works as expected.
|
|
|
|

|
I just downloaded and ran the demo project and it's exactly what I need. However, I'm coding in C#. Would this project be possible in C#?
Thank you...very nice work!
|
|
|
|

|
I think a lot of people could use this in c# ... help is welcome
|
|
|
|

|
Dear Hojjat Bohlooli
When I ran the demoproject, I found it only lists 16 files and the last file that I selected. It can not show all the selected files. How do I conquer this problem ?
Best Reguards
Jiann-Tsair Chang
Nov. 10, 2009
Be Happy Every Day.
|
|
|
|

|
Hi sir
add below code to CSelectDialogTestDlg::OnBrowse
///
ofd.m_ofn.nMaxFile = MAXFILE;
char *pTotalLen = new char[MAXFILE];
ofd.m_ofn.lpstrFile = pTotalLen;
ofd.m_ofn.lpstrFile[0] = NULL;
.
.
.
if( ofd.DoModal() != IDOK )
{
delete []pTotalLen;
return;
}
.
.
.
delete []pTotalLen;
///
maybe solve the problem.
|
|
|
|

|
I found the problem
change the MAX_PATH in the CSelectDialog::WindowProcNew function in line
pDlg->SendMessage(CDM_GETSPEC, (WPARAM)MAX_PATH, ...
to a integer variable with big value such as 10240.
e.g.
int ilen = 10240;
pDlg->SendMessage(CDM_GETSPEC, (WPARAM)ilen, ...
the mentioned problem will be solve.
regards.
|
|
|
|

|
This function doesn't work correctly, when you select multiple files and the file extensions of known file types are hidden in the Explorer settings.
Here ist my corrected while loop (Line 156) in the SelectDialog.cpp:
////////////////// Add directory names to list
while((nSelected--) > 0)
{
strItemText = wndLst1->GetItemText(nItem,1);
strItemText = strDirectory + strItemText;
int pos=-2;
if (fileslist.Find(_T("\""),0)!=-1)
{
pos=fileslist.Find(_T("\"") + strItemText.Right(strItemText.GetLength() - 3) + _T("."),0);
}
else
{
pos=fileslist.Find(strItemText.Right(strItemText.GetLength() - 3) + _T("."),0);
}
DWORD attr = GetFileAttributes(strItemText);
if((attr != 0xFFFFFFFF) && (attr & FILE_ATTRIBUTE_DIRECTORY) && (pos==-1))
m_SelectedItemList.Add(strItemText);
nItem = wndLst1->GetNextItem(nItem, LVNI_SELECTED);
}
|
|
|
|

|
The sample you provided works as stated on XP and Vista when compiled using VS2005 - as how your sample is supplied. However, if you compile using VS2008, XP still works fine, but nothing works on Vista.
On Vista, the dialog control changes do not take and no items are returned in the resulting multi-select list.
Are you planning to update the project to work correctly with VS2008 and Vista?
Thanks,
Peter
|
|
|
|

|
Problem is with OnInitDone() function.
MS says here http://msdn.microsoft.com/de-de/library/77x9ftyf.aspx
Windows Vista style file dialogs do not support this function. Attempting to use this function on a Windows Vista style file dialog will throw CNotSupportedException. See CFileDialog Class for more information.
Both the appearance and the functionality of the CFileDialog with Windows Vista differ from the earlier versions of Windows. The default CFileDialog automatically uses the new Windows Vista style without code changes if a program is compiled and run under Windows Vista. Use the bVistaStyle parameter in the constructor to manually override this automatic update. The exception to the automatic update is customized dialog boxes. They will not be converted to the new style. For more information about the constructor, see CFileDialog::CFileDialog.
So, if you still want to use this functionality, just put bVistaStyle to FALSE in the constructor.
CSelectDialog(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT |
OFN_EXPLORER & (~OFN_SHOWHELP),
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL,
DWORD dwSize = 0,
BOOL bVistaStyle = FALSE);
|
|
|
|

|
I've attempted to add the bVistaStyle flag, but the dialog still doesn't want to play.
Has anyone got this working for vista & VS2008? If so could they post a revised version.
|
|
|
|

|
Well, the preceding tip gave me a hint how to solve this problem.
In SelectDialog.cpp line 23+ the constructor of CFileDialog and of course_not_ CSelectDialog
has to be modified:
CSelectDialog::CSelectDialog(BOOL bOpenFileDialog
[...]
dwFlags | OFN_EXPLORER | OFN_HIDEREADONLY & (~OFN_SHOWHELP),
lpszFilter,
pParentWnd,0,FALSE)
{
[...]
Quite embarrassing to post, but maybe this will help someone else...
|
|
|
|

|
Not sufficiently complete to be an article. Little or no explanation of the code, which is a rather trivial sub classing of the standard file select dialog.
|
|
|
|

|
My vote to this vote is 1.
Maybe the article isn't that fancy but it hit a dry spot and saved me (a newbee) a lot of work.
|
|
|
|
|

|
Hi Hojjat,
Great job you did, a very usefull utility.
I have a single question though - if is ok?
It might be pretty simple but how do I make the dialogbox remember the "Look in" folder, so next time I don't have to browse from the root?
Kind regards
Johannes P. Hansen
|
|
|
|

|
Hi Johannes
I checked the attached sample in vista and it keeps the last browsed path.
Maybe you use OFN_NOCHANGEDIR flag in your app.
Please say your platform specs.
Regards
Hojjat Bohlooli
|
|
|
|

|
Hi Hojjat,
Thanks for answering me back and so quick
Well I didn't chance much of the original code:
CSelectDialog ofd( TRUE, _T("*.dwg"), NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT,
_T("All files and folders(*.dwg)|*.dwg||") );
I'm using Window XP Pro, SP3
Kind regards
Johannes P. Hansen
|
|
|
|

|
Hi Johannes
I tested the sample in XP SP2 too, and it worked well.
Except when an item was selected from removable storages.
Do you have tested your sample on the another OS or PC?
Regards
Hojat Bohlooli
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
|
A multi select files and folders browse window
| Type | Article |
| Licence | CPOL |
| First Posted | 22 Jul 2008 |
| Views | 49,544 |
| Downloads | 2,870 |
| Bookmarked | 27 times |
|
|