FriendPromptDlg.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. // FriendPromptDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CP_Main.h"
  5. #include "FriendPromptDlg.h"
  6. #include "afxdialogex.h"
  7. #include "Shared\Tokenizer.h"
  8. // CFriendPromptDlg dialog
  9. IMPLEMENT_DYNAMIC(CFriendPromptDlg, CDialogEx)
  10. CFriendPromptDlg::CFriendPromptDlg(CWnd* pParent /*=NULL*/)
  11. : CDialogEx(IDD_DIALOG_FREIND_PROMPT, pParent)
  12. {
  13. m_clearList = _T("Clear List");
  14. }
  15. CFriendPromptDlg::~CFriendPromptDlg()
  16. {
  17. }
  18. void CFriendPromptDlg::DoDataExchange(CDataExchange* pDX)
  19. {
  20. CDialogEx::DoDataExchange(pDX);
  21. DDX_Control(pDX, IDC_COMBO1, m_nameComboBox);
  22. }
  23. BEGIN_MESSAGE_MAP(CFriendPromptDlg, CDialogEx)
  24. ON_BN_CLICKED(IDOK, &CFriendPromptDlg::OnBnClickedOk)
  25. ON_WM_SIZE()
  26. ON_CBN_SELCHANGE(IDC_COMBO1, &CFriendPromptDlg::OnCbnSelchangeCombo1)
  27. ON_WM_CTLCOLOR()
  28. END_MESSAGE_MAP()
  29. // CFriendPromptDlg message handlers
  30. void CFriendPromptDlg::OnBnClickedOk()
  31. {
  32. m_nameComboBox.GetWindowTextW(m_name);
  33. CString values = m_name;
  34. int count = m_nameComboBox.GetCount();
  35. for (int i = 0; i < count; i++)
  36. {
  37. CString lineValue;
  38. m_nameComboBox.GetLBText(i, lineValue);
  39. if ((lineValue != m_name) &&
  40. (lineValue != m_clearList))
  41. {
  42. values += _T(",");
  43. values += lineValue;
  44. }
  45. }
  46. CGetSetOptions::SetCustomSendToList(values);
  47. CDialogEx::OnOK();
  48. }
  49. BOOL CFriendPromptDlg::OnInitDialog()
  50. {
  51. CDialogEx::OnInitDialog();
  52. ::SendMessage(this->m_hWnd, WM_SETICON, 0, NULL);
  53. m_brush.CreateSolidBrush(RGB(255, 255, 255)); // color white brush
  54. //remove the default icon in top left of window
  55. int extendedStyle = GetWindowLong(m_hWnd, GWL_EXSTYLE);
  56. SetWindowLong(m_hWnd, GWL_EXSTYLE, extendedStyle | WS_EX_DLGMODALFRAME);
  57. SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED);
  58. m_Resize.SetParent(m_hWnd);
  59. m_Resize.AddControl(IDC_COMBO1, DR_SizeWidth);
  60. m_Resize.AddControl(IDOK, DR_MoveTop | DR_MoveLeft);
  61. m_Resize.AddControl(IDCANCEL, DR_MoveTop | DR_MoveLeft);
  62. CString oldValues = CGetSetOptions::GetCustomSendToList();
  63. CTokenizer token(oldValues, _T(","));
  64. CString line;
  65. bool setSelected = false;
  66. while (token.Next(line))
  67. {
  68. if (line != "")
  69. {
  70. int row = m_nameComboBox.AddString(line);
  71. if (setSelected == false)
  72. {
  73. m_nameComboBox.SetCurSel(row);
  74. m_nameComboBox.SetEditSel(0, line.GetLength());
  75. setSelected = true;
  76. }
  77. }
  78. }
  79. m_nameComboBox.AddString(m_clearList);
  80. m_nameComboBox.SetFocus();
  81. return FALSE;
  82. }
  83. void CFriendPromptDlg::OnSize(UINT nType, int cx, int cy)
  84. {
  85. CDialogEx::OnSize(nType, cx, cy);
  86. m_Resize.MoveControls(CSize(cx, cy));
  87. }
  88. void CFriendPromptDlg::OnCbnSelchangeCombo1()
  89. {
  90. CString selection;
  91. int sel = m_nameComboBox.GetCurSel();
  92. m_nameComboBox.GetLBText(sel, selection);
  93. if (selection == m_clearList)
  94. {
  95. m_nameComboBox.ResetContent();
  96. m_nameComboBox.AddString(m_clearList);
  97. }
  98. }
  99. HBRUSH CFriendPromptDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  100. {
  101. HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
  102. // TODO: Change any attributes of the DC here
  103. // TODO: Return a different brush if the default is not desired
  104. return hbr;
  105. //return m_brush;
  106. }