Skip to content

Commit 286e79c

Browse files
committed
0.8.0.29: Basic custom file picker implementation with arrow key navigation support and single-character type-ahead buffer.
1 parent 073c2fc commit 286e79c

3 files changed

Lines changed: 449 additions & 26 deletions

File tree

src/sqlite-ce-edit/fileops.c

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,50 +43,31 @@ static void GetDataPath(wchar_t *path, int maxLen) {
4343
**============================================================================*/
4444

4545
void DoFileNew(void) {
46-
CE_OPENFILENAME ofn;
4746
wchar_t szFile[MAX_PATH];
4847
wchar_t szDataPath[MAX_PATH];
4948

5049
/* Get data path (storage card or My Documents) */
5150
GetDataPath(szDataPath, MAX_PATH);
5251
lstrcpyW(szFile, L"new.db");
5352

54-
memset(&ofn, 0, sizeof(ofn));
55-
ofn.lStructSize = sizeof(ofn);
56-
ofn.hwndOwner = g_hwndMain;
57-
ofn.lpstrFile = szFile;
58-
ofn.nMaxFile = MAX_PATH;
59-
ofn.lpstrFilter = L"Database Files (*.db)\0*.db\0All Files (*.*)\0*.*\0";
60-
ofn.lpstrDefExt = L"db";
61-
ofn.lpstrTitle = L"New Database";
62-
ofn.lpstrInitialDir = szDataPath;
63-
ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
64-
65-
if (GetSaveFileNameW(&ofn)) {
53+
if (CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
54+
L"New Database", L"Database Files (*.db)\0*.db\0",
55+
L"db", szDataPath, 1)) {
6656
DeleteFileW(szFile);
6757
OpenDatabase(szFile);
6858
}
6959
}
7060

7161
void DoFileOpen(void) {
72-
CE_OPENFILENAME ofn;
7362
wchar_t szFile[MAX_PATH] = L"";
7463
wchar_t szDataPath[MAX_PATH];
7564

7665
/* Get data path (storage card or My Documents) */
7766
GetDataPath(szDataPath, MAX_PATH);
7867

79-
memset(&ofn, 0, sizeof(ofn));
80-
ofn.lStructSize = sizeof(ofn);
81-
ofn.hwndOwner = g_hwndMain;
82-
ofn.lpstrFile = szFile;
83-
ofn.nMaxFile = MAX_PATH;
84-
ofn.lpstrFilter = L"Database Files (*.db)\0*.db\0All Files (*.*)\0*.*\0";
85-
ofn.lpstrTitle = L"Open Database";
86-
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
87-
ofn.lpstrInitialDir = szDataPath;
88-
89-
if (GetOpenFileNameW(&ofn)) {
68+
if (CustomFilePicker(g_hwndMain, szFile, MAX_PATH,
69+
L"Open Database", L"Database Files (*.db)\0*.db\0",
70+
NULL, szDataPath, 0)) {
9071
OpenDatabase(szFile);
9172
}
9273
}

0 commit comments

Comments
 (0)