Adding Multiselection to TFileOpenDialogs ADVANCED

Date: 7 February 1997
Author: Brice VIDAL
Platform: 32 bits environement
In memory of: Carcass

Overview



 

Changing the size of the FileName member

#include <owl/opensave.h>

TOpenSaveDialog::TData FileData(
    (uint32)OFN_EXPLORER | OFN_ALLOWMULTISELECT,                     // the FLAGS
    (char*)"Your App Files (*.app)|*.app| All Files (*.*)|*.*|",    // the Filter
    (char*)"*.app",                                                 // the Custom Filter
    (char*)"C:\\BC5",                                               // the Initial Dir
    (char*)"app",                                                   // the Default Extension
    (int)500,                                                       // the Size of FileName
    (int)0);                                                        // the Filter Index

#include <owl/opensave.h>

TOpenSaveDialog::TData FileData;

FileData.Flags = OFN_EXPLORER | OFN_ALLOWMULTISELECT;

FileData.MaxPath = 500;

if(FileData.FileName)
    delete[] FileData.FileName;

FileData.FileName = new char[FileData.MaxPath];

Most common flags 

#include <cstring.h>

if(TFileOpenDialog(this, FileData).Execute()==ID_OK)
{
    char* p;
    p = strtok(FileData.FileName, ' ');

    string path(p);

    while(p = strtok(NULL, ' '))
    {
        string openName(p);
        openName = path + openName;
        OpenFile(openName.c_str());
    }
}
 

Going further

#include <owl/opensave.h>

class TYourOpenSaveDialog : private TOpenSaveDialog
{
    // all you need

    protected:
        void Init(TResId templateID);

    // all you need
};

void TYourOpenSaveDialog::Init(TResId templateId)
{
    // call the usual Init

  TOpenSaveDialog::Init(templateID);

    // all you need
}

class TYourFileOpenDialog : public TYourOpenSaveDialog
{
    // all you need

    public:
        int DoExecute();

    // all you need
};

int TYourFileOpenDialog::DoExecute()
{
    // have a look at opensave.h
}


That's all folks, have fun !