bool ChooseFile(HWND hEditBox) { char File[MAX_PATH]; OPENFILENAME ofn; ZeroMemory(File,sizeof(File)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = GetActiveWindow(); ofn.hInstance = GetModuleHandle(NULL); ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = NULL; ofn.nFilterIndex = 0; ofn.lpstrFile = File; ofn.nMaxFile = sizeof(File); ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = NULL; ofn.lpstrInitialDir = NULL; ofn.nFileOffset = NULL; ofn.nFileExtension = NULL; ofn.lpstrDefExt = "*.lst"; ofn.lCustData = NULL; ofn.lpfnHook = NULL; ofn.lpTemplateName = NULL; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST; ofn.lpstrTitle = "Choisir le fichier à ouvrir"; ofn.lpstrFilter = "Executable (*.exe)\0*.exe\0Tous les fichiers\0*.*\0\0"; if( !GetOpenFileName( &ofn ) ) return false; else { SetWindowText(hEditBox,File); return true; } return false; }
HWND hEdit1; hEdit1 = GetDlgItem(hWnd,IDC_EDIT1); if(!ChooseFile(hEdit1)) MessageBox(hWnd,"Il y a eu une erreur!",NULL,MB_ICONSTOP);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question