user
May 12th, 1999, 03:49 AM
I need to select multiple files( more than 300 files ) using CFileDialog. Any suggestions? How can I get all selected files?
Thanks,
user
Thanks,
user
|
Click to See Complete Forum and Search --> : Multiple Selection user May 12th, 1999, 03:49 AM I need to select multiple files( more than 300 files ) using CFileDialog. Any suggestions? How can I get all selected files? Thanks, user Lothar Haensler May 12th, 1999, 05:59 AM the CFileDialog constructor has a dwFlags argument that can be set to (among other things) OFN_ALLOWMULTISELECT. BrianOG May 12th, 1999, 10:43 AM you will also need to supply your own buffer for the filenames. The default is something like _MAX_PATH. Do this by replacing CFileDialog::m_ofn.lpstrFile with a LARGE buffer that you allocate Rem to free it afterwads. sally May 12th, 1999, 08:57 PM more than 300 files??? you might want to think of a better schema than using CFileDialog only for this gigantum task.... Sally Sally May 12th, 1999, 08:57 PM more than 300 files??? you might want to think of a better schema than using CFileDialog only for this gigantum task.... Sally scp May 12th, 1999, 11:53 PM This reply is for sally. If somebody has a question, you don't need to come up with useless suggestions. Why do you want to REPLY to ALL the postings in this site? (I understand that you have more than 100 posting to your credit. I was wondering how many of them are of this type!!) Santhosh sally May 13th, 1999, 08:12 AM Useless? Do you really want to select 300+ files from a CFileDialog? Really? I don't beleive you would, so why should we make the users, of the programs we produce, do it? Selecting so many files from a CFileDialog is NOT user friendly. As both a project manager and a programmer I am quite aware of the need to come up with solutions quickly and also to come up with good solutions that will satisfy the needs of the users. The users are the very people that will buy and use our work, and our salaray is in a direct relation to that simple fact. No sales, no salary, no job. It is that simple! I still recommend a review of the solution and to come up with a revised way to select 300+ files. Sally Sally May 13th, 1999, 08:12 AM Useless? Do you really want to select 300+ files from a CFileDialog? Really? I don't beleive you would, so why should we make the users, of the programs we produce, do it? Selecting so many files from a CFileDialog is NOT user friendly. As both a project manager and a programmer I am quite aware of the need to come up with solutions quickly and also to come up with good solutions that will satisfy the needs of the users. The users are the very people that will buy and use our work, and our salaray is in a direct relation to that simple fact. No sales, no salary, no job. It is that simple! I still recommend a review of the solution and to come up with a revised way to select 300+ files. Sally scp May 13th, 1999, 10:33 AM Hi Sally! Here you are "assuming" a lot of things. Consider the scenario: Suppose I want to develop a sample application by which I can select all my txt files in a specific directory and ask my application to append one by one to create a wordpad document. Now I am in a position to select more than 300 files. I don't know how to do it. I post the question in this site. And you are coming with a suggestion that I should revisit my requirement. How should I feel? I should feel exactly like this: "BUDDY, I GOT A REQUIREMENT. I DON'T KNOW THE SOLUTION. IF YOU KNOW, PLEASE LET ME KNOW. OTHERWISE FORGET IT." Anyway, I respect your wast experience, and am fully agreeing with all the other things you said. I would love to make such comments if I know what EXACTLY the requirements of the project are. Isn't it better that we assumed nothing? Best regards, Santhosh Jeremy Prowse May 13th, 1999, 10:58 AM Yep, that's what you do to set it up, but then you need to allocate yourself a buffer. Here's what I did recently (member Variables: CString m_sCurDir; CStringList m_slFiles; ): CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, "3ds Files (*.3ds)|*.3ds|XOF Files (*.x)|*.x|All Files (*.*)|*.*||"); CString buffer; const char *word; // Allocate a buffer for the multi-select dlg.m_ofn.lpstrFile = buffer.GetBufferSetLength(256*50); // And make sure it doesn't write past the boundries of our buffer dlg.m_ofn.nMaxFile = 256*50; if(dlg.DoModal() == IDOK) { // Now deal with the name selected -- Get the directory, and we'll // display the number of files m_sCurDir = buffer; m_slFiles.RemoveAll(); // Perhaps this is a quick hack, but with a buffer jammed // packed full of NULLs, it saves the CString from any // interpretation word = LPCTSTR(buffer); // Increment the pointer past the word, and past the NULL word += strlen(word) + 1; if(strlen(word) == 0) { // Whoops, the buffer only had one file selected int position; // copy the current directory // Get the filename separate from the directory // In the case of one file selected, it behaves differently // returning 'C:\dir\file.x' instead of separating the // current directory and files with nulls position = m_sCurDir.ReverseFind('\\'); // Add only the filename selected to our list (minus the NULL) m_slFiles.AddTail( m_sCurDir.Right(m_sCurDir.GetLength() - position -1) ); // Now reset the current directory to what it should be m_sCurDir = m_sCurDir.Left(position); return; } while(strlen(word) != 0) { m_slFiles.AddTail(word); // Increment the char pointer so that we move to the next word, // and skip past the null pointer word += strlen(word) + 1; } } Let me know if my style is poor ;) Ack, It killed my spacing. sally May 14th, 1999, 12:38 AM "And you are coming with a suggestion that I should revisit my requirement." wrong, I suggested revisiting the solution, not the requirement..... Sally Sally May 14th, 1999, 12:38 AM "And you are coming with a suggestion that I should revisit my requirement." wrong, I suggested revisiting the solution, not the requirement..... Sally sally May 14th, 1999, 12:57 AM Maybe I answered your post a bit too quickly.... The life/work of a managert/programmer can sometime sbe a bit too stressful. However, I find codeguru to be such a vaste source of information that I never give up my daily visit to the site. Maybe I was a bot too quick in judging, maybe I should have kept my solutions to myself, maybe I should should have pointed out some of the pitfalls with having a user select 300+ files from a directory and presented some of the possible solutions I was thinking about. I am sorry for having upset you and the original poster, and I hope no harm is done. Thanks for your response, I'll be more careflu in the future. Sally Sally May 14th, 1999, 12:57 AM Maybe I answered your post a bit too quickly.... The life/work of a managert/programmer can sometime sbe a bit too stressful. However, I find codeguru to be such a vaste source of information that I never give up my daily visit to the site. Maybe I was a bot too quick in judging, maybe I should have kept my solutions to myself, maybe I should should have pointed out some of the pitfalls with having a user select 300+ files from a directory and presented some of the possible solutions I was thinking about. I am sorry for having upset you and the original poster, and I hope no harm is done. Thanks for your response, I'll be more careflu in the future. Sally BrianOG May 14th, 1999, 04:36 AM Thats basically the idea. You can also use CFileDialog::GetStartPosition & CFileDialog::GetNextPathName to extract the filenames. This will also handle the directory names for you, and I think (not sure) that it will handle the extensions of files that are not shown in the dialog. ( Ya know the way windows annoyingly defaults to hiding extensions of registered filetypes ) codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |