FileOpen
jjuiddong
Open File Dialog Sample
char szFile[] = "filename.txt"; OPENFILENAMEA ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL; ofn.lpstrFile = szFile; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile); ofn.lpstrFilter = "All\0*.*\0Text\0*.TXT\0"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; GetOpenFileNameA(&ofn);
wstring
WStrPath fileName(L"filename.txt"); OPENFILENAMEW ofn; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = m_owner->getSystemHandle(); ofn.lpstrFile = fileName.m_str; ofn.nMaxFile = fileName.SIZE; ofn.lpstrFilter = L"All\0*.*\0Text\0*.txt\0"; ofn.nFilterIndex = 1; if (!GetOpenFileNameW(&ofn)) return false;