MapOpenDialog.cpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  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. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. // MapOpenDialog.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "MapOpenDialog.h"
  21. #include "inlines.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CMapOpenDialog
  29. UINT CALLBACK OFNHookProc(
  30. HWND hdlg, // handle to child dialog window
  31. UINT uiMsg, // message identifier
  32. WPARAM wParam, // message parameter
  33. LPARAM lParam // message parameter
  34. )
  35. {
  36. if(uiMsg==WM_NOTIFY)
  37. {
  38. OFNOTIFY ofn;
  39. ofn=*((OFNOTIFY*)lParam);
  40. if(ofn.hdr.code==CDN_SELCHANGE)
  41. {
  42. // user selected another file
  43. wchar_t psz[MAX_PATH] = { 0 }; // filename
  44. CommDlg_OpenSave_GetFilePathW(GetParent(hdlg), psz, MAX_PATH);
  45. // lets parse the file. Only load Basic section
  46. CIniFile CurMap;
  47. CurMap.InsertFile(utf16ToUtf8(psz),"Basic");
  48. SetDlgItemText(hdlg, IDC_MAPNAME, CurMap.sections["Basic"].values["Name"]);
  49. }
  50. else if (ofn.hdr.code==CDN_FOLDERCHANGE)
  51. RedrawWindow(GetParent(hdlg),NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE );
  52. }
  53. return 0;
  54. }
  55. IMPLEMENT_DYNAMIC(CMapOpenDialog, CFileDialog)
  56. CMapOpenDialog::CMapOpenDialog(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
  57. DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
  58. CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
  59. {
  60. m_ofn.Flags|=OFN_EXPLORER | OFN_ENABLETEMPLATE | OFN_ENABLEHOOK;
  61. m_ofn.lpTemplateName=MAKEINTRESOURCE(IDD_MYOPENDIALOG);
  62. m_ofn.lpfnHook=OFNHookProc;
  63. }
  64. BEGIN_MESSAGE_MAP(CMapOpenDialog, CFileDialog)
  65. //{{AFX_MSG_MAP(CMapOpenDialog)
  66. // HINWEIS - Der Klassen-Assistent fügt hier Zuordnungsmakros ein und entfernt diese.
  67. //}}AFX_MSG_MAP
  68. END_MESSAGE_MAP()