Click to See Complete Forum and Search --> : to select multiple files using fileopen


K. Kiran
July 28th, 2003, 03:06 AM
I have to display the Fileopen dialog box as in Word, to select a file. The selection needs to be multiple select (example: to select more than two '.doc' files).
I am working on PowerBuilder (PB) ver 8.0.3. Here I can use the GetFileopen function of PB, but it can be used only for single selection.
How can I achieve the multiple file selection using a windows api? also, how can I get the names of the selected files in the fileopen dialog box (is it again using an api?)

My email: kkiran99@indiatimes.com

Andreas Masur
July 28th, 2003, 04:47 PM
[Moved thread]

Andreas Masur
July 28th, 2003, 04:49 PM
Take a look at the 'GetOpenFileName()' (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxreference/commondialogboxfunctions/getopenfilename.asp) function...

char szExtBuffer[MAX_PATH] = "";
OPENFILENAME ofn;

strcpy(szExtBuffer, "*.txt; *.log");

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = 0;
ofn.hInstance = 0;
ofn.lpstrFilter = 0;
ofn.lpstrCustomFilter = 0;
ofn.nMaxCustFilter = 0;
ofn.nFilterIndex = 0;
ofn.lpstrFile = szExtBuffer;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = 0;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = 0;
ofn.lpstrTitle = "Open file";
ofn.Flags = OFN_ALLOWMULTISELECT;
ofn.nFileOffset = 0;
ofn.nFileExtension = 0;
ofn.lpstrDefExt = 0;
ofn.lCustData = 0;
ofn.lpfnHook = 0;
ofn.lpTemplateName = 0;

// Open dialog
if(::GetOpenFileName(&ofn) == FALSE)
// Cancel pressed