uLib  User mode C/C++ extended API library for Win32 programmers.
StdDlg.cpp
Go to the documentation of this file.
1 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 // Project: uLib - User mode utility library.
3 // Module: Standard dialog wrapper classes.
4 // Author: Copyright (c) Love Nystrom
5 // License: NNOSL (BSD descendant, see NNOSL.txt in the base directory).
6 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 
8 #include <uLib/StdDlg.h>
9 #include <uLib/UtilFunc.h>
10 #include <uLib/StrFunc.h>
11 #include <uLib/Debug.h>
12 
13 UINT WM_CommonHelp = 0; // HELPMSGSTRING
14 UINT WM_FileOk = 0; // FILEOKSTRING
15 UINT WM_SelChange = 0; // LBSELCHSTRING
16 UINT WM_ShareViolation = 0; // SHAREVISTRING
17 UINT WM_FindReplace = 0; // FINDMSGSTRING
18 UINT WM_ColorOk = 0; // COLOROKSTRING
19 UINT WM_SetRGB = 0; // SETRGBSTRING
20 
21 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22 
24 {
25  #define TBLENTRY(x) { x, #x }
26  struct _cdErr { DWORD code; ACSTR msg; }
27  static const knownErr[] =
28  {
29  TBLENTRY( CDERR_DIALOGFAILURE ), // 0xFFFF
30  TBLENTRY( CDERR_GENERALCODES ),
31  TBLENTRY( CDERR_STRUCTSIZE ),
32  TBLENTRY( CDERR_INITIALIZATION ),
33  TBLENTRY( CDERR_NOTEMPLATE ),
34  TBLENTRY( CDERR_NOHINSTANCE ),
35  TBLENTRY( CDERR_LOADSTRFAILURE ),
36  TBLENTRY( CDERR_FINDRESFAILURE ),
37  TBLENTRY( CDERR_LOADRESFAILURE ),
38  TBLENTRY( CDERR_LOCKRESFAILURE ),
39  TBLENTRY( CDERR_MEMALLOCFAILURE ),
40  TBLENTRY( CDERR_MEMLOCKFAILURE ),
41  TBLENTRY( CDERR_NOHOOK ),
42  TBLENTRY( CDERR_REGISTERMSGFAIL ),
43  TBLENTRY( PDERR_PRINTERCODES ),
44  TBLENTRY( PDERR_SETUPFAILURE ),
45  TBLENTRY( PDERR_PARSEFAILURE ),
46  TBLENTRY( PDERR_RETDEFFAILURE ),
47  TBLENTRY( PDERR_LOADDRVFAILURE ),
48  TBLENTRY( PDERR_GETDEVMODEFAIL ),
49  TBLENTRY( PDERR_INITFAILURE ),
50  TBLENTRY( PDERR_NODEVICES ),
51  TBLENTRY( PDERR_NODEFAULTPRN ),
52  TBLENTRY( PDERR_DNDMMISMATCH ),
53  TBLENTRY( PDERR_CREATEICFAILURE ),
54  TBLENTRY( PDERR_PRINTERNOTFOUND ),
55  TBLENTRY( PDERR_DEFAULTDIFFERENT ),
56  TBLENTRY( CFERR_CHOOSEFONTCODES ),
57  TBLENTRY( CFERR_NOFONTS ),
58  TBLENTRY( CFERR_MAXLESSTHANMIN ),
59  TBLENTRY( FNERR_FILENAMECODES ),
60  TBLENTRY( FNERR_SUBCLASSFAILURE ),
61  TBLENTRY( FNERR_INVALIDFILENAME ),
62  TBLENTRY( FNERR_BUFFERTOOSMALL ),
63  TBLENTRY( FRERR_FINDREPLACECODES ),
64  TBLENTRY( FRERR_BUFFERLENGTHZERO ),
65  TBLENTRY( CCERR_CHOOSECOLORCODES )
66  };
67  #undef TBLENTRY
68 
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;
73 
74  static CHAR msgBuf[80];
75  sprintf_s( msgBuf, "Error %04X(%u)", Err, Err );
76  return msgBuf;
77 }
78 
79 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
80 // FileDialog
81 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
82 
83 const CSTR ALLFILE_FILTER = _T("All Files\0*.*\0");
84 
86 {
87  memset( &lStructSize, 0, sizeof(OPENFILENAME) );
88  memset( FullName, 0, sizeof(FullName) );
89 
90  lStructSize = sizeof(OPENFILENAME);
91  lpstrFilter = ALLFILE_FILTER; // provide a default
92  nFilterIndex = 1;
93  nMaxFile = dimof(FullName); //_MAX_PATH;
94  lpstrFile = FullName;
95  #if FDLG_USEINITDIR
96  memset( InitDir, 0, sizeof(InitDir) );
97  lpstrInitialDir = InitDir;
98  #endif
99  Flags = OFN_EXPLORER | OFN_ENABLESIZING
100  | OFN_PATHMUSTEXIST | OFN_SHAREAWARE;
101 
102  SetOwner( owner, hInstance );
104  REGISTER_FileOk();
107 }
108 
109 void FileDialog::SetOwner( HWND owner, HINSTANCE hInst )
110 {
111  hwndOwner = owner;
112  if (!hInst) hInst = ::hInstance; // Fallback
113  this->hInstance = hInst;
114 }
115 
117 {}
118 
119 bool FileDialog::Execute( UINT mode )
120 {
121  static const UINT
122  FDF_OPEN = OFN_FILEMUSTEXIST| OFN_ALLOWMULTISELECT,
123  FDF_SAVE = OFN_CREATEPROMPT| OFN_OVERWRITEPROMPT;
124 
125  switch( mode ) {
126 
127  case FDLG_OPEN:
128  Flags &= ~FDF_SAVE;
129  Flags |= FDF_OPEN;
130  return bool_cast( GetOpenFileName( this ));
131 
132  case FDLG_SAVE:
133  Flags &= ~FDF_OPEN;
134  Flags |= FDF_SAVE;
135  return bool_cast( GetSaveFileName( this ));
136 
137  default: return false;
138  }
139 }
140 
141 CSTR FileDialog::PickFile( HWND owner, CSTR caption, CSTR filter )
142 {
143  TSTR rtn = NULL;
144  OPENFILENAME ofn = *this; // Use temporary ofn struct copy for this
145 
146  ofn.nFilterIndex = 1;
147  ofn.Flags = OFN_EXPLORER | OFN_ENABLESIZING | OFN_PATHMUSTEXIST | OFN_CREATEPROMPT;
148  ofn.lpstrFilter = filter ? filter : ALLFILE_FILTER;
149  ofn.hwndOwner = owner;
150  ofn.lpstrTitle = caption;
151 
152  if (!caption && owner) // If no caption, use owner's title.
153  {
154  TCHAR szTitle[128] = S_BLANK;
155  GetWindowText( owner, szTitle, dimof(szTitle) );
156  ofn.lpstrTitle = szTitle;
157  }
158 
159  if (GetOpenFileName( &ofn ))
160  {
161  rtn = FullName;
162  _updateOffsets();
163  }
164  return rtn;
165 }
166 
168 {
169  return lpstrFile + nFileOffset;
170 }
171 
173 {
174  return lpstrFile + nFileExtension;
175 }
176 
178 {
179  _tcscpy_s( FullName, dimof(FullName), src );
180  _updateOffsets();
181 
182  #if FDLG_USEINITDIR
183  TSTR pzSep = (TSTR)_tcsrchr( src, BSLASH );
184  if (pzSep)
185  {
186  _tcscpy_s( InitDir, dimof(InitDir), src );
187  pzSep = (TSTR)_tcsrchr( InitDir, BSLASH );
188  if (pzSep) *pzSep = 0;
189  }
190  #endif
191  return src; // Note!
192 }
193 
194 void FileDialog::_updateOffsets()
195 {
196  // Compute file offset
197 
198  TSTR pch = _tcsrchr( FullName, BSLASH );
199  nFileOffset = WORD( pch ? pch - FullName + 1 : 0 );
200 
201  // Compute extension offset
202 
203  pch = _tcsrchr( FullName, DOT );
204  // Let nFileExtension point to terminating NUL if no extension.
205  if (pch) nFileExtension = WORD( pch - FullName + 1 );
206  else nFileExtension = WORD( _tcschr( FullName, 0 ) - FullName );
207 }
208 
209 bool FileDialog::ForEach( FDLG_ItemProc Action, PVOID UserData )
210 {
211  TCHAR path[ MAX_PATH ];
212 
213  if (FileExist( FullName )) // If single file selected
214  {
215  #if FDLG_USEINITDIR
216  TSTR bslash = _tcsrchr( FullName, BSLASH ); // Get last bkslash
217  if (!bslash)
218  _tcscpy_s( InitDir, dimof(InitDir), FullName ); // Consider the string a dir name
219  else { // If none, keep fname for init
220  size_t span = bslash - FullName; // Length of dir part
221  _tcsncpy_s( InitDir, dimof(InitDir), FullName, span ); // Keep dir as initializer
222  InitDir[ span ] = 0; // Make sure it's NUL terminated
223  }
224  #endif
225  if (!Action( FullName, UserData )) return false; // Call action proc
226  }
227  else // Multiple files selected
228  {
229  #if FDLG_USEINITDIR
230  _tcscpy_s( InitDir, dimof(InitDir), FullName ); // Keep dir as next time initializer
231  #endif
232  TSTR src = _tcschr( FullName, 0 ); // Get end of dir, next ch is first file
233  TSTR fn = _tcsecpy( path, FullName ); // Get directory, fn = ptr to nul termin
234  *fn++ = BSLASH; // Append bkslash to dir, point to fname
235  #ifdef HAVE_SAFE_CSTRINGS
236  size_t remain = dimof(path) - (fn - path); // Remaining buffer space
237  #endif
238  while( *++src ) // Pre-increment, check if chr or NUL
239  {
240  _tcscpy_s( fn, remain, src ); // Append filename.ext after dir bkslash
241  if (!Action( path, UserData )) return false;
242  src = _tcschr( src, 0 ); // Get next nul term
243  }
244  }
245  return true;
246 }
247 
248 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
249 // FindDialog
250 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251 
253 {
254  memset( this, 0, sizeof(FINDREPLACE) );
255  memset( What, 0, sizeof(What) );
256  memset( With, 0, sizeof(With) );
257 
258  lStructSize = sizeof(FINDREPLACE);
259  lpstrFindWhat = What;
260  lpstrReplaceWith = With;
261  wFindWhatLen = dimof(What);
262  wReplaceWithLen = dimof(With);
263  Flags = FR_DOWN;
264 
265  hWnd = NULL;
266  SetOwner( Owner );
267 
270 }
271 
272 void FindDialog::SetOwner( HWND Owner, HINSTANCE hInst )
273 {
274  hwndOwner = Owner;
275  if (!hInst) hInst = ::hInstance; // Fallback
276  this->hInstance = hInst;
277 }
278 
280 {
281  if (hWnd) DestroyWindow( hWnd );
282 }
283 
284 bool FindDialog::Execute( UINT Mode )
285 {
286  Flags &= ~FR_ACTIONMASK; // Clear any previous action flags
287 
288  switch( Mode )
289  {
290  case FD_FIND:
291  hWnd = FindText( this );
292  TRACE_IF( !hWnd, DP_ERROR, _F("FindText(): %s\n"), CDErrorMsg() );
293  break;
294 
295  case FD_REPLACE:
296  hWnd = ReplaceText( this );
297  TRACE_IF( !hWnd, DP_ERROR, _F("ReplaceText(): %s\n"), CDErrorMsg() );
298  break;
299 
300  case FD_CLOSE:
301  if (hWnd) DestroyWindow( hWnd );
302  hWnd = NULL;
303  break;
304  }
305  hCurrDlg = hWnd; // (uLib) Find/Replace dialog is modeless
306  return (hWnd != NULL);
307 }
308 
310 {
311  Flags &= ~(FR_REPLACE| FR_REPLACEALL);
312  Flags |= FR_FINDNEXT;
313  SendMessage( hwndOwner, WM_FindReplace, 0, (LPARAM)this );
314 }
315 
316 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
317 // Font dialog
318 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
319 
321 {
322  memset( this, 0, sizeof(CHOOSEFONT) );
323  lStructSize = sizeof(CHOOSEFONT);
324 
325  Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT
326  | CF_EFFECTS | CF_NOSIMULATIONS | CF_FORCEFONTEXIST;
327 
328  lpLogFont = &LogFont;
329  SetTypeface( _T("Arial"), 10, FW_NORMAL, ANSI_CHARSET );
330 
331  LogFont.lfOutPrecision = OUT_OUTLINE_PRECIS; // OUT_DEFAULT_PRECIS
332  LogFont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
333  LogFont.lfQuality = ANTIALIASED_QUALITY; //PROOF_QUALITY; //CLEARTYPE_QUALITY; //DEFAULT_QUALITY;
334  LogFont.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
335 }
336 
337 void FontDialog::SetOwner( HWND Owner, HINSTANCE hInst )
338 {
339  hwndOwner = Owner;
340  if (!hInst) hInst = ::hInstance; // Fallback
341  this->hInstance = hInst;
342 }
343 
345 {
346  _tcscpy_s( LogFont.lfFaceName, dimof(LogFont.lfFaceName), Face );
347 }
348 
349 void FontDialog::SetTypeface( CSTR Face, WORD Points, WORD Weight, BYTE ChrSet )
350 {
351  SetFaceName( Face );
352  LogFont.lfHeight = ScreenFontHeight( Points );
353  LogFont.lfWeight = Weight;
354  LogFont.lfCharSet = ChrSet;
355 }
356 
358 {
359  HFONT font = (HFONT) GetCurrentObject( hDC, OBJ_FONT );
360  LOGFONT tmpLf;
361  bool ok = (GetObject( font, sizeof(tmpLf), &tmpLf ) == sizeof(LOGFONT));
362  if (ok) LogFont = tmpLf;
363  return ok;
364 }
365 
366 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367 // Color dialog
368 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
369 
371 {
372  memset( this, 0, sizeof(CHOOSECOLOR) );
373  lStructSize = sizeof(CHOOSECOLOR);
374  lpCustColors = Colors;
375  Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
376 
377  BYTE lum = 16, delta = 15; // Grayscale luminocity
378  for( BYTE i=0; i < 16; ++i, lum += delta )
379  Colors[ i ] = RGB( lum,lum,lum );
380 }
381 
382 void ColorDialog::SetOwner( HWND Owner, HINSTANCE hInst )
383 {
384  hwndOwner = Owner;
385  if (!hInst) hInst = ::hInstance; // Fallback
386  this->hInstance = (HWND) hInst;
387  // There's an error in the declaration of CHOOSECOLOR which MS never fixed.
388  // Hence the wonky typecast on the instance handle.
389 }
390 
391 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
392 // DirDialog
393 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
394 
396  _T("Select a folder in the directory tree\n")
397  _T("or click [Cancel] to abort the operation.");
398 
399 IFolderFilter* DirDialog::FolderFilter = NULL; // Preliminary
400 
401 #ifdef __GNUC__
402 #pragma GCC diagnostic push
403 #pragma GCC diagnostic ignored "-Wcast-function-type"
404 #endif
405 
406 DirDialog::DirDialog( HWND Owner, UINT Flags )
407 {
408  memset( &hwndOwner, 0, sizeof(BROWSEINFO) );
409  // HWND hwndOwner;
410  // PCIDLIST_ABSOLUTE pidlRoot;
411  // LPTSTR pszDisplayName;
412  // LPCTSTR lpszTitle;
413  // UINT ulFlags;
414  // BFFCALLBACK lpfn;
415  // LPARAM lParam;
416  // int iImage;
417  memset( Folder, 0, sizeof(Folder) );
418  pszDisplayName = Folder;
419  hwndOwner = Owner;
420  lpszTitle = DefaultTitle;
421  ulFlags = Flags;
422  lParam = (LPARAM) this; // NB: Caller must not use lParam, but pData instead.
423  lpfn = (BFFCALLBACK)_Hook; // GCC gives misleading warning here..
424  //
425  pIdl = NULL;
426  pData = NULL; // User data.
427  pFilterSite = NULL;
428 }
429 #ifdef __GNUC__
430 #pragma GCC diagnostic pop
431 #endif
432 
434 {
435  Done();
436 }
437 
439 {
440  IMalloc* tmpShmall = NULL;
441  if ((pIdl || pidlRoot) && !ShMalloc) // Oops.. ShMalloc's gone.
442  {
443  // This can happen with a global DirDialog, as the user would have
444  // already called DoneShellFunc before the global destructor executes.
445 
446  CoGetMalloc( MEMCTX_TASK, &tmpShmall );
447  ShMalloc = tmpShmall;
448  }
449 
450  pIdl = (LPITEMIDLIST) ShellFreeEx( pIdl ); // (ShMalloc wrap)
451  pidlRoot = (LPCITEMIDLIST) ShellFreeEx( (PVOID)pidlRoot );
452 
453  if (tmpShmall)
454  {
455  tmpShmall->Release();
456  ShMalloc = NULL; // NOTE: tmpShmall only exist if ShMalloc was NULL.
457  }
458 
460 }
461 
462 void DirDialog::SetOwner( HWND Owner )
463 {
464  hwndOwner = Owner;
465 }
466 
467 bool DirDialog::SetInitialDir( CSTR Dir ) // Initially selected item.
468 {
469  LPITEMIDLIST pidl = GetPathNamePIDL( Dir );
470  bool ok = (pidl != NULL);
471  if (ok)
472  {
473  ShellFreeEx( pIdl );
474  pIdl = pidl; // This is effectuated later by the _Hook callback.
475  }
476  return ok;
477 }
478 
479 void DirDialog::SetRoot( LPITEMIDLIST pidl ) // Set root by PIDL.
480 {
481  ShellFreeEx( (PVOID)pidlRoot );
482  pidlRoot = pidl;
483 }
484 
485 bool DirDialog::SetRootCsid( int csId ) // Set root by a CSIDL.
486 {
487  LPITEMIDLIST pidl;
488  bool ok = SUCCEEDED(
489  SHGetSpecialFolderLocation( hwndOwner, csId, (ITEMIDLIST**)&pidl )
490  );
491  if (ok) SetRoot( pidl );
492  return ok;
493 }
494 
495 bool DirDialog::SetRootDir( CSTR Dir ) // Set root by a dir path.
496 {
497  LPITEMIDLIST pidl = GetPathNamePIDL( Dir );
498  bool ok = (pidl != NULL);
499  if (ok) SetRoot( pidl );
500  return ok;
501 }
502 
504 {
505  if (!lpfn && pIdl) ShellFreeEx( pIdl ); // If no _Hook, dispose of pIdl here.
506 
507  // Quirk: This always raises exception 0x6BA (The RPC server is unavailable)
508  // *first time it's called*, regardless if CoInitialize/Ex was called first.
509  // The shell handles the exception transparently, so just ignore it.
510 
511  pIdl = SHBrowseForFolder( this );
512  // Get the full path (SHBrowseForFolder sets Folder to only the last subdir).
513  return pIdl ? bool_cast( SHGetPathFromIDList( pIdl, Folder )) : false;
514 }
515 
516 #ifndef BFFM_IUNKNOWN // Missing in MinGW's ShlObj.h
517 #define BFFM_IUNKNOWN 5
518 #endif
519 
520 DLGHOOKPROC DirDialog::_Hook( HWND hdlg, UINT msg, LPARAM lp, LPARAM data ) // static
521 {
522  DirDialog* This = (DirDialog*) data;
523  UINT_PTR rc = 0;
524 
525  IUnknown* punk;
526  LPITEMIDLIST pidl;
527  CSTR psz;
528 
529  #ifdef NT4_COMP
530  #define DDM_SELECT BFFM_SETSELECTION // Supported on NT4++: Selects the node
531  #else
532  #define DDM_SELECT BFFM_SETEXPANDED // Supported on XP++: Selects and expands the node
533  #endif
534 
535  switch( msg )
536  {
537  case BFFM_INITIALIZED:
538  if (This->pIdl) // Was a directory selected before ?
539  {
540  // If so, then select it again, as starting point.
541 
542  SendMessage( hdlg, DDM_SELECT, FALSE, (LPARAM)This->pIdl );
543  This->pIdl = (LPITEMIDLIST) ShellFreeEx( This->pIdl ); // Discard previous selection.
544  }
545  CenterWindow( hdlg, This->hwndOwner ); //<<-- PONDER: May or may not be a good idea...
546  break;
547 
548  case BFFM_IUNKNOWN:
549  punk = (IUnknown*) lp;
550  // This is called just twice in the dialog lifetime. Once at the start,
551  // with a valid IUnknown pointer, and once at the end with a NULL pointer
552  // to indicate we need to unset any filter we installed.
553 
554  if (FolderFilter) // NB: static member
555  {
556  // [MSDN] "To set a custom filter, call QueryInterface on the IUnknown
557  // to obtain a pointer to an instance of IFolderFilterSite. Then call
558  // IFolderFilterSite::SetFilter with a pointer to your IFolderFilter."
559 
560  if (punk)
561  {
562  static REFIID riid = IID_IFolderFilterSite; //__uuidof( IFolderFilterSite );
563 
564  // Because we need to call the IFolderFilterSite at the end, we must
565  // retain the pointer to it, as we can't QI a NULL pointer later.
566  // The pointer is kept in our extended BROWSEINFO record.
567 
568  if (SUCCEEDED( punk->QueryInterface( riid, (void**)&This->pFilterSite )))
569  {
570  if (FAILED( This->pFilterSite->SetFilter( FolderFilter )))
571  goto __releaseFilterSite;
572  }
573  }
574  else // punk == NULL. The browser has Released it's shell folder interface.
575  {
576  if (This->pFilterSite)
577  {
578  This->pFilterSite->SetFilter( NULL ); // Release the filter
579  __releaseFilterSite:
580  RELEASE_OBJ( This->pFilterSite );
581  }
582  }
583  }
584  break;
585 
586  case BFFM_SELCHANGED:
587  pidl = (LPITEMIDLIST) lp;
588  // FIXME: Kludge to recenter the selected item...
589  //if (This->_centerSel)
590  //{
591  // static enum { IDC_TREE = 0x3741 };
592  // This->_centerSel = This->_keepCenterSel;
593  //
594  // SCROLLINFO si = { sizeof(SCROLLINFO), SIF_POS| SIF_RANGE| SIF_PAGE, 0,0,0,0,0 };
595  // HWND htree = GetDlgItem( hdlg, IDC_TREE );
596  // HTREEITEM htir, htic, htis;
597  // int count, pos;
598  //
599  // if (IsWindow( htree ))
600  // {
601  // htir = TreeView_GetRoot( htree );
602  // htis = TreeView_GetSelection( htree );
603  // htic = TreeView_GetChild( htree, htir );
604  // for( count = pos = 0; htic; htic = TreeView_GetNextVisible( htree, htic ), count++ )
605  // if (htis == htic)
606  // {
607  // pos = count;
608  // break;
609  // }
610  // GetScrollInfo( htree, SB_VERT, &si );
611  // si.nPage /= 2;
612  // if ((pos > int(si.nMin + si.nPage)) && (pos <= int(si.nMax - si.nMin - si.nPage)))
613  // {
614  // si.nMax = si.nPos - si.nMin + si.nPage;
615  // for( ; pos < si.nMax; pos++ ) PostMessage( htree, WM_VSCROLL, MAKEWPARAM( SB_LINEUP,0 ),0 );
616  // for( ; pos > si.nMax; pos-- ) PostMessage( htree, WM_VSCROLL, MAKEWPARAM( SB_LINEDOWN,0 ),0 );
617  // }
618  // }
619  //}
620  break;
621 
622  case BFFM_VALIDATEFAILED:
623  psz = (CSTR) lp;
624  rc = TRUE;
625  break;
626  }
627  return rc;
628  //UNUSED( punk );
629  UNUSED( pidl );
630  UNUSED( psz );
631 }
632 
633 // EOF
#define RELEASE_OBJ(Ifc)
Definition: Common.h:994
unsigned long DWORD
Definition: Common.h:414
#define DDM_SELECT
static CCSTR DefaultTitle
Definition: StdDlg.h:325
const CSTR ALLFILE_FILTER
Definition: StdDlg.cpp:83
FindDialog(HWND Owner=NULL)
Definition: StdDlg.cpp:252
bool ForEach(FDLG_ItemProc Action, PVOID UserData)
Definition: StdDlg.cpp:209
UINT WM_ShareViolation
Definition: StdDlg.cpp:16
#define DOT
Definition: Common.h:1216
bool CenterWindow(HWND hWnd, HWND hOwner)
Definition: UserUtil.cpp:563
UINT WM_FileOk
Definition: StdDlg.cpp:14
LPITEMIDLIST pIdl
Definition: StdDlg.h:321
const char * ACSTR
Definition: Common.h:345
CSTR Name()
Definition: StdDlg.cpp:167
#define REGISTER_CommonHelp()
Definition: StdDlg.h:43
TCHAR FullName[MAX_PATH]
Definition: StdDlg.h:114
TCHAR Folder[MAX_PATH]
Definition: StdDlg.h:322
#define CSTR
Definition: Common.h:329
#define S_BLANK
Definition: Common.h:1235
#define BFFM_IUNKNOWN
Definition: StdDlg.cpp:517
unsigned short WORD
Definition: Common.h:413
void SetFaceName(CSTR Face)
Definition: StdDlg.cpp:344
HWND hCurrDlg
Definition: Common.cpp:13
bool SetRootCsid(int csId)
Definition: StdDlg.cpp:485
bool Execute(UINT mode)
Definition: StdDlg.cpp:119
bool GetLogFontFromDC(HDC hDC)
Definition: StdDlg.cpp:357
bool FileExist(CSTR PathName)
Definition: IoUtil.cpp:24
DirDialog(HWND Owner=NULL, UINT Flags=(BIF_RETURNONLYFSDIRS|BIF_NEWDIALOGSTYLE|BIF_EDITBOX))
Definition: StdDlg.cpp:406
int WINAPI ScreenFontHeight(WORD Points)
Definition: GdiUtil.cpp:52
void SendFindNext()
Definition: StdDlg.cpp:309
#define TSTR
Definition: Common.h:328
#define dimof(x)
Definition: Common.h:949
#define FD_REPLACE
Definition: StdDlg.h:201
~FindDialog()
Definition: StdDlg.cpp:279
CSTR Ext()
Definition: StdDlg.cpp:172
IFolderFilterSite * pFilterSite
Definition: StdDlg.h:346
LPITEMIDLIST GetPathNamePIDL(CSTR Dir, ULONG *pAttrib OPTIONAL=NULL)
void SetTypeface(CSTR Face, WORD Points, WORD Weight, BYTE ChrSet=ANSI_CHARSET)
Definition: StdDlg.cpp:349
bool SetInitialDir(CSTR Dir)
Definition: StdDlg.cpp:467
COLORREF Colors[16]
Definition: StdDlg.h:281
CSTR PickFile(HWND owner, CSTR caption, CSTR filter)
Definition: StdDlg.cpp:141
FontDialog()
Definition: StdDlg.cpp:320
ACSTR CDErrorMsg(DWORD Err)
Definition: StdDlg.cpp:23
void SetOwner(HWND owner, HINSTANCE hInst=NULL)
Definition: StdDlg.cpp:109
#define FD_CLOSE
Definition: StdDlg.h:202
static UINT_PTR CALLBACK _Hook(HWND hwnd, UINT msg, LPARAM lp, LPARAM data)
Definition: StdDlg.cpp:520
LOGFONT LogFont
Definition: StdDlg.h:236
FileDialog(HWND owner=NULL)
Definition: StdDlg.cpp:85
#define _tcsecpy
Definition: StrFunc.h:74
#define REGISTER_FindReplace()
Definition: StdDlg.h:55
CSTR SetFilename(CSTR PathName)
Definition: StdDlg.cpp:177
#define TRACE_IF(cond,...)
Definition: Debug.h:227
UINT WM_SelChange
Definition: StdDlg.cpp:15
const LPCTSTR CCSTR
Definition: Common.h:335
bool Execute(UINT Mode)
Definition: StdDlg.cpp:284
UINT WM_ColorOk
Definition: StdDlg.cpp:18
TCHAR With[256]
Definition: StdDlg.h:189
#define DLGHOOKPROC
Definition: StdDlg.h:21
#define REGISTER_SelChange()
Definition: StdDlg.h:49
PVOID ShellFreeEx(PVOID pBlk)
Definition: ShellUtil.cpp:79
#define FDLG_OPEN
Definition: StdDlg.h:127
~DirDialog()
Definition: StdDlg.cpp:433
void Done()
Definition: StdDlg.cpp:438
void SetOwner(HWND Owner, HINSTANCE hInst=NULL)
Definition: StdDlg.cpp:337
bool __forceinline bool_cast(BOOL B52)
Definition: Common.h:767
#define DP_ERROR
Definition: Debug.h:82
HWND hWnd
Definition: StdDlg.h:187
#define REGISTER_ShareViolation()
Definition: StdDlg.h:52
UINT WM_FindReplace
Definition: StdDlg.cpp:17
static IFolderFilter * FolderFilter
Definition: StdDlg.h:326
~FileDialog()
Definition: StdDlg.cpp:116
void SetOwner(HWND Owner, HINSTANCE hInst=NULL)
Definition: StdDlg.cpp:272
UINT WM_SetRGB
Definition: StdDlg.cpp:19
void SetOwner(HWND Owner)
Definition: StdDlg.cpp:462
#define UNUSED(x)
Definition: Common.h:970
bool(CALLBACK * FDLG_ItemProc)(CSTR FileName, PVOID UserData)
Definition: StdDlg.h:79
Debug and error handling support.
HINSTANCE hInstance
Definition: Common.cpp:10
PVOID pData
Definition: StdDlg.h:323
bool Execute()
Definition: StdDlg.cpp:503
#define TBLENTRY(x)
bool SetRootDir(CSTR Dir)
Definition: StdDlg.cpp:495
IMalloc * ShMalloc
Definition: ShellUtil.cpp:17
void SetOwner(HWND Owner, HINSTANCE hInst=NULL)
Definition: StdDlg.cpp:382
#define BSLASH
Definition: Common.h:1217
#define _F(s)
Definition: Debug.h:49
TCHAR What[256]
Definition: StdDlg.h:188
TCHAR InitDir[MAX_PATH]
Definition: StdDlg.h:116
UINT WM_CommonHelp
Definition: StdDlg.cpp:13
#define REGISTER_FileOk()
Definition: StdDlg.h:46
unsigned char BYTE
Definition: Common.h:412
#define FR_ACTIONMASK
Definition: StdDlg.h:160
#define FD_FIND
Definition: StdDlg.h:200
#define FDLG_SAVE
Definition: StdDlg.h:128
void SetRoot(LPITEMIDLIST pidl)
Definition: StdDlg.cpp:479