I have this openfile() function with OPENFILENAME structure, the lpstrFilter does not filter file types at all, the Dialog Box shows all types of files which I want to prevent, it should normally show only selected file types according to the extension filter , and also when the user select another file type for example .PNG files , it should update the files in the Dialog box and show only PNG files which is not the case , so what is wrong in this code?, is there any specific Flags that help solve the problem?
void openfile() {
ZeroMemory(&opn, sizeof(opn));
opn.lStructSize = sizeof(opn);
opn.hwndOwner = hWindow;
opn.lpstrFile = tz1;
opn.lpstrFile[0] = '\0';
opn.nMaxFile = sizeof(tz1);
opn.lpstrFilter = "JPG - JPEG File\0*.JPG\0PNG File\0*.PNG\0BMP - Bitmat File\0*.BMP\0";
opn.nFilterIndex = 2;
opn.lpstrFileTitle = NULL;
opn.lpstrTitle = "Select an Image";
opn.nMaxFileTitle = 0;
opn.lpstrInitialDir = NULL;
opn.hInstance = hInstance;
opn.lpstrDefExt = ("JPG");
opn.Flags = OFN_ENABLEHOOK | OFN_EXPLORER;
opn.lpfnHook = NULL;
bfile = 0;
if (GetOpenFileName(&opn)) {
if (access(tz1, F_OK) == -1){
// showing some file does not exist message
}
} // if Get
} // openfile()