Hi, in the GetOpenFileName, I want to allow multiple files selection:
Code:
UINT CALLBACK CWnd::OFNHookProc( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam )
{
	switch(message)
	{
		case WM_INITDIALOG:
        {
            SetProp(GetParent(hDlg), "OFN", (void *)lParam);
            break;
        }
		case WM_NOTIFY:
        {
            LPOFNOTIFY  lpof = reinterpret_cast<LPOFNOTIFY>(lParam);
            DWORD neededSize = 0;
            if(lpof->hdr.code == CDN_SELCHANGE)
            {
                neededSize = CommDlg_OpenSave_GetSpec(GetParent(hDlg), NULL, 0);
                neededSize += MAX_PATH;
                LPOPENFILENAME pOfn = reinterpret_cast<LPOPENFILENAME>(GetProp(GetParent(hDlg), "OFN"));
                if(pOfn->nMaxFile < neededSize)
                {
                   // need to put comments because it hangs and crush
                    /*LPTSTR lpsz = pOfn->lpstrFile;
                    if (lpsz)
                    {
                        HeapFree(GetProcessHeap(),0,lpsz);
                        lpsz = (TCHAR*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,neededSize);
                        if (lpsz)
                        {
                            pOfn->lpstrFile = lpsz;
                            pOfn->nMaxFile = neededSize;
                        }
                    }*/
                }
            }
            break;
        }
		case WM_DESTROY:
        {
            RemoveProp(GetParent(hDlg), "OFN");
            break;
        }
    }
    return 0;
}

bool CWnd::OpenFileNames(HWND h,const TCHAR *filter,TCHAR *buffer,int buffer_size,int *nMorethenOne)
{
    OPENFILENAME ofn = {0};
    buffer[0] = 0;
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.Flags = OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEHOOK;
	ofn.hwndOwner = h;
	ofn.lpstrFile = buffer;
	ofn.nFilterIndex = 0;
	ofn.lpstrFilter = filter;
	ofn.nMaxFile = buffer_size;
	ofn.lpfnHook = OFNHookProc;
	ofn.lCustData = reinterpret_cast<LPARAM>(&ofn);
	if (!GetOpenFileName(&ofn)) return false;
	*nMorethenOne = ofn.nFileExtension;
	return true;
}

// .. later
case IDM_SOMEMENUITEM:
        {
            TCHAR sz_FileNames[MAX_PATH];
            int off_set = 0,nFiles = 0;
            if (OpenFileNames(hwnd,MakeFilter().c_str(),sz_FileNames,sizeof(sz_FileNames)+1,&off_set))
            {
                if (!off_set)
                {
                    // We have more then 1 files selected
                    
                }
                else
                {
                    // use single file 
                }
                nFiles++;
            }
            break;
        }
it crushes when I choose one file
I'm trying to grow the max file size so the user can grab more files...any ideas?