PDA

Click to See Complete Forum and Search --> : Browse for folder the MFC way


noble
May 7th, 2002, 12:01 AM
Anyone know the correct way to implement a browse for folder
dialog with MFC?

CornedBee
May 7th, 2002, 10:03 AM
Take a look at CListBox, ::DlgDirList and ::DlgDirSelectEx. This should give you all the knowledge you need to build your own directory selection dialog.

A more modern way involves CListBox (owner drawn with strings), CComboBoxEx and the ::Find*File family. Or maybe the shell namespace. To make a directory selection box in real modern explorer style, use SHGetDesktopFolder to retrieve a IShellFolder interface pointer. Use this interface to walk the complete directory tree (the EnumObjects and BindToObject methods mainly). The retrieved information should be displayed in a tree control.

Sorry, I can't give you any code, this will require some time to learn...

The simplest method (the one listed at the top) can be looked up for API way at
Platform SDK->User Interface Services->Controls->List Boxes->Using List Boxes->Creating a Directory Listing in a Single-Selection List Box

It lists a complete DlgProc for a dialog that does just this. It shouldn't be too hard to translate that to MFC, but be aware that it looks like a relic from Win16

noble
May 7th, 2002, 10:20 AM
yeah unfortunately i chose to go the API way, however in my
search i found some code at codeguru where someone
wrapped the SHBrowseForFolder API for MFC

i'm changing that a bit around now for my likings, thx again