Common Dialogs ... 
Author Message
 Common Dialogs ...

I am having a very bizarre problem with a multi select Open Dialog Box ...

 OPENFILENAME ofn;
 ofn.lStructSize   = sizeof( ofn );
 ofn.hwndOwner   = ghEditorCtrl;
 ofn.hInstance   = ghInstance;
 ofn.lpstrFilter   = "Hierarchies (*.hrc)\0*.hrc\0\0";
 ofn.lpstrCustomFilter = NULL;
 ofn.nFilterIndex  = 0;

 ofn.lpstrFile   = szFile;
 ofn.nMaxFile   = 256 * 256;
 ofn.lpstrFileTitle  = NULL;
 ofn.lpstrInitialDir  = "c:\\project\\story\\";
 ofn.lpstrTitle   = "Open Hierarchy";
 ofn.Flags    = OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ALLOWMULTISELECT;
 ofn.nFileOffset   = 0;
 ofn.lpstrDefExt   = "hrc\0";
 ofn.nFileExtension  = 0;
 ofn.lCustData   = 0;
 ofn.lpfnHook   = NULL;
 ofn.lpTemplateName  = NULL;

 int nRet = GetOpenFileName( &ofn );

If i select more than one file everything works fine.  HOWEVER, if i select
one file GetOpenFileName() returns 0 and CommDlgExtendedError() gives me
0x008cf6dc.  I cannot find this error anywhere :(

Anyone ever had something similar to this?  Am i doing something stupid?

    Goz



Fri, 28 Mar 2003 03:00:00 GMT  
 Common Dialogs ...

This is a bit of code taken from a project I have been working on. Works a
treat:.

 HRESULT hr;
 TCHAR szBuffer[32000];
 OPENFILENAME ofn;
 ZeroMemory(&ofn,sizeof(ofn));
 ZeroMemory(szBuffer,sizeof(szBuffer));

 ofn.lStructSize = sizeof(ofn);
 ofn.hwndOwner = (HWND) m_lHwndParent;
 ofn.lpstrFile = szBuffer;
 ofn.nMaxFile = sizeof(szBuffer);
 ofn.Flags = OFN_FILEMUSTEXIST
     | OFN_HIDEREADONLY
     | OFN_LONGNAMES
     | OFN_PATHMUSTEXIST
     | OFN_ALLOWMULTISELECT
     | OFN_EXPLORER;

 if (!GetOpenFileName(&ofn))
 {
  DWORD dwError = CommDlgExtendedError();
  if (!dwError)
   return S_FALSE;
  else
   return E_FAIL;
 }


Quote:
> I am having a very bizarre problem with a multi select Open Dialog Box ...

>  OPENFILENAME ofn;
>  ofn.lStructSize   = sizeof( ofn );
>  ofn.hwndOwner   = ghEditorCtrl;
>  ofn.hInstance   = ghInstance;
>  ofn.lpstrFilter   = "Hierarchies (*.hrc)\0*.hrc\0\0";
>  ofn.lpstrCustomFilter = NULL;
>  ofn.nFilterIndex  = 0;

>  ofn.lpstrFile   = szFile;
>  ofn.nMaxFile   = 256 * 256;
>  ofn.lpstrFileTitle  = NULL;
>  ofn.lpstrInitialDir  = "c:\\project\\story\\";
>  ofn.lpstrTitle   = "Open Hierarchy";
>  ofn.Flags    = OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ALLOWMULTISELECT;
>  ofn.nFileOffset   = 0;
>  ofn.lpstrDefExt   = "hrc\0";
>  ofn.nFileExtension  = 0;
>  ofn.lCustData   = 0;
>  ofn.lpfnHook   = NULL;
>  ofn.lpTemplateName  = NULL;

>  int nRet = GetOpenFileName( &ofn );

> If i select more than one file everything works fine.  HOWEVER, if i
select
> one file GetOpenFileName() returns 0 and CommDlgExtendedError() gives me
> 0x008cf6dc.  I cannot find this error anywhere :(

> Anyone ever had something similar to this?  Am i doing something stupid?

>     Goz



Fri, 28 Mar 2003 03:00:00 GMT  
 Common Dialogs ...
Cheers for the help Paul.  It turns out that my buffer at the size of 65536
(256 * 256) is what was causing the problem! ... I take it down to 65535 and
everything works fine.  Me thinks that one should be documented :(

    Goz



Fri, 28 Mar 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. using common dialog HookProc

2. Common Dialog Problem

3. common dialog control directory select

4. ActiveX control like MS Common dialog

5. ATL and Common Dialogs

6. ifstream object and the Common Dialog box

7. Common Dialogs

8. Common Dialog sample problem

9. Common Dialog Box : Directory Select

10. Common Dialogs

11. Modifying common dialogs

12. Common Dialogs

 

 
Powered by phpBB® Forum Software