RestrictedFileDialog.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. // RestrictedFileDialog.cpp : implementation file
  19. //
  20. #include "StdAfx.H"
  21. #include "W3DView.H"
  22. #include "RestrictedFileDialog.H"
  23. #include "Utils.H"
  24. #ifdef _DEBUG
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif
  29. /////////////////////////////////////////////////////////////////////////////
  30. // RestrictedFileDialogClass
  31. IMPLEMENT_DYNAMIC(RestrictedFileDialogClass, CFileDialog)
  32. RestrictedFileDialogClass::RestrictedFileDialogClass(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
  33. DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
  34. CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
  35. {
  36. m_ExpectedFilename = lpszFileName;
  37. return ;
  38. }
  39. BEGIN_MESSAGE_MAP(RestrictedFileDialogClass, CFileDialog)
  40. //{{AFX_MSG_MAP(RestrictedFileDialogClass)
  41. // NOTE - the ClassWizard will add and remove mapping macros here.
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. /////////////////////////////////////////////////////////////////
  45. //
  46. // OnFileNameChange
  47. //
  48. void
  49. RestrictedFileDialogClass::OnFileNameChange (void)
  50. {
  51. // Force the original filename into the filename control
  52. CommDlg_OpenSave_SetControlText (::GetParent (m_hWnd), 0x480, (LPCTSTR)m_ExpectedFilename);
  53. return ;
  54. }
  55. /////////////////////////////////////////////////////////////////
  56. //
  57. // OnFileNameOK
  58. //
  59. BOOL
  60. RestrictedFileDialogClass::OnFileNameOK (void)
  61. {
  62. // Force the original filename into the filename control
  63. CommDlg_OpenSave_SetControlText (::GetParent (m_hWnd), 0x480, (LPCTSTR)m_ExpectedFilename);
  64. // Fill the filename fields of the OPENFILESTRUCT structure with the
  65. // original filename and the new path
  66. CString path = ::Strip_Filename_From_Path (m_ofn.lpstrFile);
  67. path += "\\";
  68. path += m_ExpectedFilename;
  69. ::lstrcpy (m_ofn.lpstrFile, path);
  70. ::lstrcpy (m_ofn.lpstrFileTitle, m_ExpectedFilename);
  71. return FALSE;
  72. }
  73. /////////////////////////////////////////////////////////////////
  74. //
  75. // OnInitDone
  76. //
  77. void
  78. RestrictedFileDialogClass::OnInitDone (void)
  79. {
  80. // Disable the controls we don't want the user to change
  81. ::EnableWindow (::GetDlgItem (::GetParent (m_hWnd), 0x480), FALSE);
  82. ::EnableWindow (::GetDlgItem (::GetParent (m_hWnd), 0x470), FALSE);
  83. return ;
  84. }