DlgCreateVirtualDirectory.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /* Copyright (c) 2002-2012 Croteam Ltd.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of version 2 of the GNU General Public License as published by
  4. the Free Software Foundation
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License along
  10. with this program; if not, write to the Free Software Foundation, Inc.,
  11. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
  12. // DlgCreateVirtualDirectory.cpp : implementation file
  13. //
  14. #include "stdafx.h"
  15. #include "DlgCreateVirtualDirectory.h"
  16. #ifdef _DEBUG
  17. #undef new
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CDlgCreateVirtualDirectory dialog
  24. CDlgCreateVirtualDirectory::CDlgCreateVirtualDirectory(CTString strOldName /*= ""*/,
  25. CTString strTitle /*="Create virtual directory"*/, CWnd* pParent /*=NULL*/)
  26. : CDialog(CDlgCreateVirtualDirectory::IDD, pParent)
  27. {
  28. m_strTitle = strTitle;
  29. //{{AFX_DATA_INIT(CDlgCreateVirtualDirectory)
  30. m_strDirectoryName = CString(strOldName);
  31. //}}AFX_DATA_INIT
  32. }
  33. void CDlgCreateVirtualDirectory::DoDataExchange(CDataExchange* pDX)
  34. {
  35. INDEX i;
  36. CDialog::DoDataExchange(pDX);
  37. // if dialog is receiving data
  38. if( pDX->m_bSaveAndValidate == FALSE)
  39. {
  40. }
  41. //{{AFX_DATA_MAP(CDlgCreateVirtualDirectory)
  42. DDX_Control(pDX, IDC_DIRECTORY_ICON_LIST, m_DirectoryIconsList);
  43. DDX_Text(pDX, IDC_EDIT1, m_strDirectoryName);
  44. DDV_MaxChars(pDX, m_strDirectoryName, 32);
  45. //}}AFX_DATA_MAP
  46. // if dialog gives data
  47. if( pDX->m_bSaveAndValidate != FALSE)
  48. {
  49. m_strCreatedDirName = CTString( CStringA(m_strDirectoryName));
  50. m_iSelectedIconType = 0;
  51. // Now set selected directory icon type
  52. for( i=0; i<m_DirectoryIconsList.GetItemCount(); i++)
  53. {
  54. if( m_DirectoryIconsList.GetItemState( i, LVIS_SELECTED) != 0)
  55. {
  56. m_iSelectedIconType = i;
  57. break;
  58. }
  59. }
  60. }
  61. }
  62. BEGIN_MESSAGE_MAP(CDlgCreateVirtualDirectory, CDialog)
  63. //{{AFX_MSG_MAP(CDlgCreateVirtualDirectory)
  64. ON_NOTIFY(NM_DBLCLK, IDC_DIRECTORY_ICON_LIST, OnDblclkDirectoryIconList)
  65. //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CDlgCreateVirtualDirectory message handlers
  69. BOOL CDlgCreateVirtualDirectory::OnInitDialog()
  70. {
  71. CDialog::OnInitDialog();
  72. SetWindowText( CString(m_strTitle));
  73. m_IconsImageList.Create( IDB_DIRECTORY_ICONS, 16, 1, CLR_NONE);
  74. m_DirectoryIconsList.SetImageList( &m_IconsImageList, LVSIL_SMALL);
  75. for( INDEX i=0; i<NO_OF_ICONS; i++)
  76. {
  77. m_DirectoryIconsList.InsertItem( i, L"", i);
  78. }
  79. return TRUE; // return TRUE unless you set the focus to a control
  80. // EXCEPTION: OCX Property Pages should return FALSE
  81. }
  82. void CDlgCreateVirtualDirectory::OnDblclkDirectoryIconList(NMHDR* pNMHDR, LRESULT* pResult)
  83. {
  84. UpdateData();
  85. if( m_strCreatedDirName != "")
  86. EndDialog(IDOK);
  87. *pResult = 0;
  88. }