open a file browser from a win32 dialog
I am working in win32 with c++ and using a dialog as my main window. I am trying to open a file browser to select a folder, but nothing happens when i tell it to pop up. Also how do i make it only show files, because i juse want the user to select a directory, not a file. Heres what i have. Thanks
Code:
static OPENFILENAME openFileName;
openFileName.lStructSize = sizeof(OPENFILENAME);
openFileName.hwndOwner = hWnd;
openFileName.hInstance = NULL;
openFileName.lpstrFilter = "text (*.txt)\0*.txt\0)";
openFileName.lpstrCustomFilter = NULL;
openFileName.nMaxCustFilter = 0;
openFileName.lpstrFile = NULL;
openFileName.nMaxFile = MAX_PATH;
openFileName.lpstrFileTitle = NULL;
openFileName.nMaxFileTitle = MAX_PATH;
openFileName.lpstrInitialDir = NULL;
openFileName.lpstrTitle = NULL;
openFileName.Flags = 0;
openFileName.nFileOffset = 0;
openFileName.nFileExtension = 0;
openFileName.lpstrDefExt = "txt";
openFileName.lCustData = 0L;
openFileName.lpfnHook = NULL;
openFileName.lpTemplateName = NULL;
case BTN_BROWSE:
openFileName.hwndOwner = hWnd;
char directory[500];
openFileName.lpstrFile = directory;
openFileName.lpstrFileTitle = "test";
openFileName.Flags = OFN_CREATEPROMPT;
GetOpenFileName(&openFileName);