DirectoryDialog.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : W3DView *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/W3DView/DirectoryDialog.cpp $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/25/00 2:56p $*
  29. * *
  30. * $Revision:: 3 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #include "stdafx.h"
  36. #include "directorydialog.h"
  37. #include "utils.h"
  38. ////////////////////////////////////////////////////////////////////////////
  39. //
  40. // Browse_For_Folder_Hook_Proc
  41. //
  42. ////////////////////////////////////////////////////////////////////////////
  43. UINT CALLBACK Browse_For_Folder_Hook_Proc
  44. (
  45. HWND hdlg,
  46. UINT message,
  47. WPARAM wparam,
  48. LPARAM lparam
  49. )
  50. {
  51. //
  52. // If the user clicked OK, then stuff a dummy filename
  53. // into the control so the dialog will close...
  54. //
  55. if ( message == WM_COMMAND &&
  56. LOWORD (wparam) == IDOK &&
  57. HIWORD (wparam) == BN_CLICKED)
  58. {
  59. ::SetDlgItemText (hdlg, 1152, "xxx.xxx");
  60. }
  61. return FALSE;
  62. }
  63. ////////////////////////////////////////////////////////////////////////////
  64. //
  65. // Browse_For_Folder
  66. //
  67. ////////////////////////////////////////////////////////////////////////////
  68. bool
  69. Browse_For_Folder (HWND parent_wnd, LPCTSTR initial_path, CString &path)
  70. {
  71. bool retval = false;
  72. OPENFILENAME openfilename = { sizeof (OPENFILENAME), 0 };
  73. TCHAR filename[MAX_PATH] = { 0 };
  74. openfilename.lpstrInitialDir = initial_path;
  75. openfilename.hwndOwner = parent_wnd;
  76. openfilename.hInstance = ::AfxGetResourceHandle ();
  77. openfilename.lpstrFilter = _T("\0\0");
  78. openfilename.lpstrFile = filename;
  79. openfilename.nMaxFile = sizeof (filename);
  80. openfilename.lpstrTitle = _T("Choose Directory");
  81. openfilename.lpfnHook = Browse_For_Folder_Hook_Proc;
  82. openfilename.lpTemplateName = MAKEINTRESOURCE (1536);
  83. openfilename.Flags = OFN_HIDEREADONLY | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_LONGNAMES;
  84. //
  85. // Display the modified 'file-open' dialog.
  86. //
  87. if (::GetOpenFileName (&openfilename) == IDOK) {
  88. path = ::Strip_Filename_From_Path (filename);
  89. retval = true;
  90. }
  91. return retval;
  92. }