MoveToGroupDlg.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // MoveToGroupDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "cp_main.h"
  5. #include "MoveToGroupDlg.h"
  6. #include "GroupName.h"
  7. #include "ProcessPaste.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMoveToGroupDlg dialog
  15. CMoveToGroupDlg::CMoveToGroupDlg(CWnd* pParent /*=NULL*/, CString windowTitle /*= _T("")*/)
  16. : CDialog(CMoveToGroupDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CMoveToGroupDlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. m_nSelectedGroup = -1;
  22. m_windowTitle = windowTitle;
  23. }
  24. void CMoveToGroupDlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CMoveToGroupDlg)
  28. DDX_Control(pDX, IDC_TREE, m_Tree);
  29. //}}AFX_DATA_MAP
  30. }
  31. BEGIN_MESSAGE_MAP(CMoveToGroupDlg, CDialog)
  32. //{{AFX_MSG_MAP(CMoveToGroupDlg)
  33. ON_WM_SIZE()
  34. ON_BN_CLICKED(IDC_BUTTON_NEW_GROUP, OnButtonNewGroup)
  35. //}}AFX_MSG_MAP
  36. ON_MESSAGE(NM_GROUP_TREE_MESSAGE, OnTreeSelect)
  37. END_MESSAGE_MAP()
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CMoveToGroupDlg message handlers
  40. BOOL CMoveToGroupDlg::OnInitDialog()
  41. {
  42. CDialog::OnInitDialog();
  43. if(!m_windowTitle.IsEmpty())
  44. {
  45. SetWindowText(m_windowTitle);
  46. }
  47. m_Tree.m_selectedFolderID = m_nSelectedGroup;
  48. m_Tree.SetNotificationWndEx(m_hWnd);
  49. m_Tree.FillTree();
  50. theApp.m_Language.UpdateMoveToGroups(this);
  51. return TRUE; // return TRUE unless you set the focus to a control
  52. // EXCEPTION: OCX Property Pages should return FALSE
  53. }
  54. LRESULT CMoveToGroupDlg::OnTreeSelect(WPARAM wParam, LPARAM lParam)
  55. {
  56. int nID = (int)wParam;
  57. if(nID != 0)
  58. {
  59. m_nSelectedGroup = nID;
  60. OnOK();
  61. }
  62. else
  63. {
  64. OnCancel();
  65. }
  66. return TRUE;
  67. }
  68. void CMoveToGroupDlg::OnOK()
  69. {
  70. m_nSelectedGroup = m_Tree.GetSelectedTree();
  71. CDialog::OnOK();
  72. }
  73. void CMoveToGroupDlg::OnSize(UINT nType, int cx, int cy)
  74. {
  75. CDialog::OnSize(nType, cx, cy);
  76. // TODO: Add your message handler code here
  77. }
  78. void CMoveToGroupDlg::OnButtonNewGroup()
  79. {
  80. CGroupName Name;
  81. if(Name.DoModal() != IDOK)
  82. return;
  83. CString csName = Name.m_csName;
  84. long lID = NewGroupID(m_Tree.GetSelectedTree(), csName);
  85. if(lID >= 0)
  86. {
  87. m_Tree.AddNode(csName, lID);
  88. }
  89. m_Tree.SetFocus();
  90. }