hi guy's
here is one problem i am facing.
actually i am a new bee in mfc so please help.
it is a problem related with multiple file selection.
i am able to get only upto 10 filenames by following method.
my problem is the folllowing code is working for only 10-12 files.

void CMainFrame::OnProjectAddfile()
{
CFileDialog openDialog( TRUE, _T(""),_T(""),
OFN_READONLY|
OFN_HIDEREADONLY|
OFN_PATHMUSTEXIST|
OFN_ALLOWMULTISELECT,
_T("C Files (*.c)|*.c|(*.s)|*.s|(*.h)|*.h||"));

if(openDialog.DoModal()==IDOK)
{
POSITION ps;
CString MultiFileName[MAX_PATH];
int FileNumber=0;
ps=openDialog.GetStartPosition();
while(ps)
{
MultiFileName[FileNumber]=openDialog.GetNextPathName(ps);
FileNumber++;
}
}

}

so i tried this

void CMainFrame::OnProjectAddfile()
{
CFileDialog openDialog( TRUE, _T(""),_T(""),
OFN_READONLY|
OFN_HIDEREADONLY|
OFN_PATHMUSTEXIST|
OFN_ALLOWMULTISELECT,
_T("C Files (*.c)|*.c|(*.s)|*.s|(*.h)|*.h||"));

LPSTR ptr = new char[50 * MAX_PATH];
memset(ptr,0,50*MAX_PATH);
openDialog.m_ofn.lpstrFile = ptr;

if(openDialog.DoModal()==IDOK)
{
POSITION ps;
CString MultiFileName[MAX_PATH];
int FileNumber=0;
ps=openDialog.GetStartPosition();
while(ps)
{
MultiFileName[FileNumber]=openDialog.GetNextPathName(ps);
FileNumber++;
}
}
delete []ptr;
}

but then also the problem did not got solved.
openDialog.DoModal() is actually returning IDCANCEL when i select more
than 12 files

please help me it's very important for my project.

Regards and thank's in advance
Harshal shete

Re: hi group i got CFileDialog multiselect problem please help by Doug

Doug
Mon Apr 10 10:39:47 CDT 2006

On 10 Apr 2006 05:50:33 -0700, "harsha_shete@rediffmail.com"
<harshalshete@gmail.com> wrote:

>hi guy's
>here is one problem i am facing.
>actually i am a new bee in mfc so please help.
>it is a problem related with multiple file selection.
>i am able to get only upto 10 filenames by following method.
>my problem is the folllowing code is working for only 10-12 files.
>
>void CMainFrame::OnProjectAddfile()
>{
>CFileDialog openDialog( TRUE, _T(""),_T(""),
> OFN_READONLY|
> OFN_HIDEREADONLY|
> OFN_PATHMUSTEXIST|
> OFN_ALLOWMULTISELECT,
> _T("C Files (*.c)|*.c|(*.s)|*.s|(*.h)|*.h||"));
>
> if(openDialog.DoModal()==IDOK)
> {
> POSITION ps;
> CString MultiFileName[MAX_PATH];
> int FileNumber=0;
> ps=openDialog.GetStartPosition();
> while(ps)
> {
> MultiFileName[FileNumber]=openDialog.GetNextPathName(ps);
> FileNumber++;
> }
> }
>
>}
>
>so i tried this
>
>void CMainFrame::OnProjectAddfile()
>{
>CFileDialog openDialog( TRUE, _T(""),_T(""),
> OFN_READONLY|
> OFN_HIDEREADONLY|
> OFN_PATHMUSTEXIST|
> OFN_ALLOWMULTISELECT,
> _T("C Files (*.c)|*.c|(*.s)|*.s|(*.h)|*.h||"));
>
> LPSTR ptr = new char[50 * MAX_PATH];
> memset(ptr,0,50*MAX_PATH);
> openDialog.m_ofn.lpstrFile = ptr;
>
> if(openDialog.DoModal()==IDOK)
> {
> POSITION ps;
> CString MultiFileName[MAX_PATH];
> int FileNumber=0;
> ps=openDialog.GetStartPosition();
> while(ps)
> {
> MultiFileName[FileNumber]=openDialog.GetNextPathName(ps);
> FileNumber++;
> }
> }
> delete []ptr;
> }
>
>but then also the problem did not got solved.
>openDialog.DoModal() is actually returning IDCANCEL when i select more
>than 12 files
>
>please help me it's very important for my project.
>
>Regards and thank's in advance
>Harshal shete

Read the documentation for OPENFILENAME. You didn't set the nMaxFile
member.

--
Doug Harrison
Visual C++ MVP

Re: hi group i got CFileDialog multiselect problem please help by harsha_shete

harsha_shete
Tue Apr 11 01:43:12 CDT 2006

thanks Doug,
now the program is working well.
regards
harshal