I want to write my own function that shows an "OpenFile DialogBox" and when somebody selects a file, I want to return the filename at the end of my function
Here is the code:
VB Code:
void ShowOpenFile(HWND hwndowner) { OPENFILENAME ofn; char chosenfile[MAX_PATH]; ZeroMemory(&ofn, sizeof(ofn)); chosenfile[0] = 0; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST, OFN_HIDEREADONLY; ofn.hInstance = hinst; ofn.hwndOwner = hwndowner; ofn.lpstrFilter = "Web Page(*.html)\0*.html\0\0"; ofn.lpstrDefExt = "html"; ofn.lStructSize = MAX_PATH; ofn.lpstrFile = chosenfile; if(GetOpenFileName(&ofn)) { return chosenfile[MAX_PATH]; } }
That code does not work and I have tried lots of other things like making a char function instead of void function but it does not solve the problem.
So simply... How do return the name of the file at the end of my function?




Reply With Quote