CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Open Dialog

  1. #1
    Join Date
    Jun 1999
    Posts
    3

    Open Dialog

    Hey everyone,

    I don't really care whether there's an example of this in either VC or VB, but I'm not sure how to a an Open File Dialog where users should only be able to open or select directories. Although the VB dialog interface is very simple...it doesn't look like there's a simple way to filter out all files except directories and allow users to both do directory crawls and select directories.



  2. #2
    Join Date
    May 1999
    Location
    Wisconsin, USA
    Posts
    953

    Re: Open Dialog

    Not sure if this helps but check out the constructor for CFileDialog.




  3. #3
    Join Date
    May 1999
    Location
    Mass, USA.
    Posts
    103

    Re: Open Dialog

    There are 5 examples of this at:

    http://www.codeguru.com/dialog/index.shtml

    /ravi



  4. #4
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266

    Re: Open Dialog

    An aternative is to use SHBrowseForFolder. The following is not exactly what you would need, but it is probably close.


    void CDialogsDlg::OnSysFldrs() {
    LPITEMIDLIST pidlBrowse=NULL;
    CString SystemFolder;
    LPMALLOC g_pMalloc;
    BROWSEINFO bi;
    if (!SUCCEEDED(SHGetMalloc(&g_pMalloc))) {
    MessageBox("Internal error: Malloc failure", AfxGetAppName());
    return;
    }
    if (!SUCCEEDED(SHGetSpecialFolderLocation(m_hWnd, CSIDL_DESKTOP, &pidlBrowse))) // CSIDL_NETWORK
    MessageBox("Internal error: special folder not found", AfxGetAppName());
    else {
    bi.hwndOwner = m_hWnd;
    bi.pidlRoot = pidlBrowse;
    bi.pszDisplayName = SystemFolder.GetBuffer(MAX_PATH);
    bi.lpszTitle = "Sample System Folders Dialog";
    bi.ulFlags = 0; // BIF_BROWSEFORCOMPUTER;
    bi.lpfn = NULL;
    bi.lParam = 0;
    pidlBrowse = SHBrowseForFolder(&bi);
    SystemFolder.ReleaseBuffer(-1);
    MessageBox(SystemFolder, AfxGetAppName());
    }
    if (pidlBrowse != NULL)
    g_pMalloc->Free(pidlBrowse);
    }





    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured