25 #define TBLENTRY(x) { x, #x } 27 static const knownErr[] =
69 if (!Err) Err = CommDlgExtendedError();
70 for(
short i=0; i < short(
dimof(knownErr)); ++i )
71 if (knownErr[i].code == Err)
72 return knownErr[i].msg;
74 static CHAR msgBuf[80];
75 sprintf_s( msgBuf,
"Error %04X(%u)", Err, Err );
87 memset( &lStructSize, 0,
sizeof(OPENFILENAME) );
90 lStructSize =
sizeof(OPENFILENAME);
99 Flags = OFN_EXPLORER | OFN_ENABLESIZING
100 | OFN_PATHMUSTEXIST | OFN_SHAREAWARE;
122 FDF_OPEN = OFN_FILEMUSTEXIST| OFN_ALLOWMULTISELECT,
123 FDF_SAVE = OFN_CREATEPROMPT| OFN_OVERWRITEPROMPT;
130 return bool_cast( GetOpenFileName(
this ));
135 return bool_cast( GetSaveFileName(
this ));
137 default:
return false;
144 OPENFILENAME ofn = *
this;
146 ofn.nFilterIndex = 1;
147 ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_PATHMUSTEXIST | OFN_CREATEPROMPT;
149 ofn.hwndOwner = owner;
150 ofn.lpstrTitle = caption;
152 if (!caption && owner)
155 GetWindowText( owner, szTitle,
dimof(szTitle) );
156 ofn.lpstrTitle = szTitle;
159 if (GetOpenFileName( &ofn ))
169 return lpstrFile + nFileOffset;
174 return lpstrFile + nFileExtension;
188 if (pzSep) *pzSep = 0;
194 void FileDialog::_updateOffsets()
211 TCHAR path[ MAX_PATH ];
225 if (!Action(
FullName, UserData ))
return false;
235 #ifdef HAVE_SAFE_CSTRINGS 236 size_t remain =
dimof(path) - (fn - path);
240 _tcscpy_s( fn, remain, src );
241 if (!Action( path, UserData ))
return false;
242 src = _tcschr( src, 0 );
254 memset(
this, 0,
sizeof(FINDREPLACE) );
258 lStructSize =
sizeof(FINDREPLACE);
259 lpstrFindWhat =
What;
260 lpstrReplaceWith =
With;
291 hWnd = FindText(
this );
296 hWnd = ReplaceText(
this );
306 return (
hWnd != NULL);
311 Flags &= ~(FR_REPLACE| FR_REPLACEALL);
312 Flags |= FR_FINDNEXT;
322 memset(
this, 0,
sizeof(CHOOSEFONT) );
323 lStructSize =
sizeof(CHOOSEFONT);
325 Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT
326 | CF_EFFECTS | CF_NOSIMULATIONS | CF_FORCEFONTEXIST;
329 SetTypeface( _T(
"Arial"), 10, FW_NORMAL, ANSI_CHARSET );
331 LogFont.lfOutPrecision = OUT_OUTLINE_PRECIS;
332 LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
333 LogFont.lfQuality = ANTIALIASED_QUALITY;
334 LogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
359 HFONT font = (HFONT) GetCurrentObject( hDC, OBJ_FONT );
361 bool ok = (GetObject( font,
sizeof(tmpLf), &tmpLf ) ==
sizeof(LOGFONT));
372 memset(
this, 0,
sizeof(CHOOSECOLOR) );
373 lStructSize =
sizeof(CHOOSECOLOR);
375 Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
377 BYTE lum = 16, delta = 15;
378 for(
BYTE i=0; i < 16; ++i, lum += delta )
379 Colors[ i ] = RGB( lum,lum,lum );
396 _T(
"Select a folder in the directory tree\n")
397 _T("or click [Cancel] to abort the operation.");
399 IFolderFilter*
DirDialog::FolderFilter = NULL;
402 #pragma GCC diagnostic push 403 #pragma GCC diagnostic ignored "-Wcast-function-type" 408 memset( &hwndOwner, 0,
sizeof(BROWSEINFO) );
422 lParam = (LPARAM)
this;
423 lpfn = (BFFCALLBACK)
_Hook;
430 #pragma GCC diagnostic pop 440 IMalloc* tmpShmall = NULL;
446 CoGetMalloc( MEMCTX_TASK, &tmpShmall );
451 pidlRoot = (LPCITEMIDLIST)
ShellFreeEx( (PVOID)pidlRoot );
455 tmpShmall->Release();
470 bool ok = (pidl != NULL);
489 SHGetSpecialFolderLocation( hwndOwner, csId, (ITEMIDLIST**)&pidl )
498 bool ok = (pidl != NULL);
511 pIdl = SHBrowseForFolder(
this );
516 #ifndef BFFM_IUNKNOWN // Missing in MinGW's ShlObj.h 517 #define BFFM_IUNKNOWN 5 530 #define DDM_SELECT BFFM_SETSELECTION // Supported on NT4++: Selects the node 532 #define DDM_SELECT BFFM_SETEXPANDED // Supported on XP++: Selects and expands the node 537 case BFFM_INITIALIZED:
549 punk = (IUnknown*) lp;
562 static REFIID riid = IID_IFolderFilterSite;
568 if (SUCCEEDED( punk->QueryInterface( riid, (
void**)&This->
pFilterSite )))
571 goto __releaseFilterSite;
586 case BFFM_SELCHANGED:
587 pidl = (LPITEMIDLIST) lp;
622 case BFFM_VALIDATEFAILED:
static CCSTR DefaultTitle
const CSTR ALLFILE_FILTER
FindDialog(HWND Owner=NULL)
bool ForEach(FDLG_ItemProc Action, PVOID UserData)
bool CenterWindow(HWND hWnd, HWND hOwner)
#define REGISTER_CommonHelp()
void SetFaceName(CSTR Face)
bool SetRootCsid(int csId)
bool GetLogFontFromDC(HDC hDC)
bool FileExist(CSTR PathName)
DirDialog(HWND Owner=NULL, UINT Flags=(BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE|BIF_EDITBOX))
int WINAPI ScreenFontHeight(WORD Points)
IFolderFilterSite * pFilterSite
LPITEMIDLIST GetPathNamePIDL(CSTR Dir, ULONG *pAttrib OPTIONAL=NULL)
void SetTypeface(CSTR Face, WORD Points, WORD Weight, BYTE ChrSet=ANSI_CHARSET)
bool SetInitialDir(CSTR Dir)
CSTR PickFile(HWND owner, CSTR caption, CSTR filter)
ACSTR CDErrorMsg(DWORD Err)
void SetOwner(HWND owner, HINSTANCE hInst=NULL)
static UINT_PTR CALLBACK _Hook(HWND hwnd, UINT msg, LPARAM lp, LPARAM data)
FileDialog(HWND owner=NULL)
#define REGISTER_FindReplace()
CSTR SetFilename(CSTR PathName)
#define TRACE_IF(cond,...)
#define REGISTER_SelChange()
PVOID ShellFreeEx(PVOID pBlk)
void SetOwner(HWND Owner, HINSTANCE hInst=NULL)
bool __forceinline bool_cast(BOOL B52)
#define REGISTER_ShareViolation()
static IFolderFilter * FolderFilter
void SetOwner(HWND Owner, HINSTANCE hInst=NULL)
void SetOwner(HWND Owner)
bool(CALLBACK * FDLG_ItemProc)(CSTR FileName, PVOID UserData)
Debug and error handling support.
bool SetRootDir(CSTR Dir)
void SetOwner(HWND Owner, HINSTANCE hInst=NULL)
#define REGISTER_FileOk()
void SetRoot(LPITEMIDLIST pidl)