Hello,
when trying to specifiy filters for my windows based file open dialog, I've encountered the problem that whathever filter I set, no files are being shown. Unless I specifiy no filter, where all files are shown like normal. The code is rather simple:
FileDialog::FileDialog(DialogType type, const std::wstring& stTitle, LPCWSTR lpFilter): Widget(0, 0, 0, 0), m_pFileBuffer(nullptr), m_stTitle(stTitle), m_stFilter(lpFilter)
{
m_pFileBuffer = new wchar_t[1024];
memset(m_pFileBuffer, 0, 1024);
m_pNameBuffer = new wchar_t[1024];
memset(m_pNameBuffer, 0, 1024);
memset(&m_ofn, 0, sizeof(m_ofn));
m_ofn.lStructSize = sizeof(m_ofn);
m_ofn.lpstrFile = m_pFileBuffer;
m_ofn.lpstrFileTitle = m_pNameBuffer;
m_ofn.nMaxFileTitle = 1024;
m_ofn.nMaxFile = 1024;
m_ofn.lpstrFilter = m_stFilter.c_str();
m_ofn.nFilterIndex = !m_stFilter.empty();
m_ofn.lpstrTitle = m_stTitle.c_str();
if (type == DialogType::OPEN)
m_ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
else
m_ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
}
So I'm storing the filter thats being passed in an std::wstring. Then I set the c_str() of this as the lpstrFilter. I've tried differnt filters and browsed through different directories making sure that fitting files are present:
L"Acclimate Project files(.acp)\0*.*\0" // my custom fromat I want to support, the first one I tried and lead me to belive it only didn't work for this format first
L"All\0*.*\0Text\0*.TXT\0" // only displays rubbish for the second selection (a filled out dot), and doesn't show any files for neigther of those two selections => I'm not sure if the display problem is related here, or just something else.
Any ideas what I could've missed?