Overriding the Open button handler of CFileDialog
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Overriding the Open button handler of CFileDialog

  1. #1
    Join Date
    May 2011
    Posts
    4

    Overriding the Open button handler of CFileDialog

    Hi,

    I have subclassed CFileDialog.
    I need to select both file and folder on certain case only.
    Suppose I have a folder selected and it is containing desired file type.
    Then in such situation, On clicking open button will not open the selected folder. But just close the CFileDialog with IDOK.

    For doing this I need to provide my own implementation for Open button handler. I am not getting how I can do this.

    Any suggestion or advice will be greatly appreciated!

    Thanks

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,391

    Re: Overriding the Open button handler of CFileDialog

    It is not clear what you mean by "select both file and folder on certain case only"...
    Perhaps SHBrowseForFolder is what you need instead?
    Victor Nijegorodov

  3. #3
    Join Date
    May 2011
    Posts
    4

    Re: Overriding the Open button handler of CFileDialog

    sorry or unclear information.

    I have added "Select All" button on CFileDialog, which select all images file and subfolder containing images on clicking it. So currently I have both files and folder selected. So on clicking the open, opens one of the selected subfolder.

    Here I just want to close the CFileDialog wih IDOK.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,391

    Re: Overriding the Open button handler of CFileDialog

    Try EndDialog(IDOK).
    For additional info: http://msgroups.net/microsoft.public...problem/557578
    Victor Nijegorodov

  5. #5
    Join Date
    May 2011
    Posts
    4

    Re: Overriding the Open button handler of CFileDialog

    Thanks VictorN,
    It worked!

  6. #6
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,013

    Re: Overriding the Open button handler of CFileDialog

    Quote Originally Posted by VictorN View Post
    You should be careful with the solution proposed in this link.
    Code:
    ((CDialog*)GetParent())->EndDialog(IDOK);
    I've had problems before on Windows 7 with a class derived from CFileDialog that called GetParent() in some overridden function. I can't recall exactly, but the problem was that GetParent() returned NULL. The fix was to store the parent's HWND as a member variable in OnInitDialog and then later use the member variable instead of calling GetParent().
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Tags for this Thread

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center