Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
4.3 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 1999
  6. //
  7. // File: simprop.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. /////////////////////////////////////////////////////////////////////
  11. // SimProp.cpp - Common code used by SIM property pages.
  12. //
  13. // HISTORY
  14. // 08-Jul-97 t-danm Creation.
  15. /////////////////////////////////////////////////////////////////////
  16. #include "stdafx.h"
  17. #include "common.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. IMPLEMENT_DYNCREATE(CSimPropPage, CPropertyPage)
  24. BEGIN_MESSAGE_MAP(CSimPropPage, CPropertyPageEx_Mine)
  25. //{{AFX_MSG_MAP(CSimPropPage)
  26. ON_NOTIFY(NM_CLICK, IDC_LISTVIEW, OnClickListview)
  27. ON_NOTIFY(NM_DBLCLK, IDC_LISTVIEW, OnDblclkListview)
  28. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LISTVIEW, OnItemchangedListview)
  29. ON_NOTIFY(LVN_KEYDOWN, IDC_LISTVIEW, OnKeydownListview)
  30. ON_BN_CLICKED(IDC_BUTTON_REMOVE, OnButtonRemove)
  31. ON_EN_SETFOCUS(IDC_EDIT_USER_ACCOUNT, OnSetfocusEditUserAccount)
  32. //}}AFX_MSG_MAP
  33. ON_MESSAGE(WM_HELP, OnHelp)
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. /////////////////////////////////////////////////////////////////////////////
  37. CSimPropPage::CSimPropPage(UINT nIDTemplate) : CPropertyPageEx_Mine(nIDTemplate)
  38. {
  39. //{{AFX_DATA_INIT(CSimPropPage)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. m_pData = NULL;
  43. m_prgzColumnHeader = NULL;
  44. }
  45. CSimPropPage::~CSimPropPage()
  46. {
  47. }
  48. void CSimPropPage::DoDataExchange(CDataExchange* pDX)
  49. {
  50. ASSERT(m_pData != NULL);
  51. CPropertyPageEx_Mine::DoDataExchange(pDX);
  52. //{{AFX_DATA_MAP(CSimPropPage)
  53. // NOTE: the ClassWizard will add DDX and DDV calls here
  54. //}}AFX_DATA_MAP
  55. if (!pDX->m_bSaveAndValidate)
  56. {
  57. CString strUser;
  58. m_pData->GetUserAccountName(OUT &strUser);
  59. SetDlgItemText(IDC_EDIT_USER_ACCOUNT, strUser);
  60. } // if
  61. } // DoDataExchange()
  62. BOOL CSimPropPage::OnInitDialog()
  63. {
  64. m_hwndListview = ::GetDlgItem(m_hWnd, IDC_LISTVIEW);
  65. if (m_prgzColumnHeader != NULL)
  66. {
  67. ListView_AddColumnHeaders(m_hwndListview, m_prgzColumnHeader);
  68. }
  69. CPropertyPageEx_Mine::OnInitDialog();
  70. UpdateUI();
  71. return TRUE;
  72. }
  73. void CSimPropPage::SetDirty()
  74. {
  75. ASSERT(m_pData != NULL);
  76. m_pData->m_fIsDirty = TRUE;
  77. SetModified();
  78. UpdateUI();
  79. }
  80. void CSimPropPage::UpdateUI()
  81. {
  82. int iItemSelected = ListView_GetSelectedItem(m_hwndListview);
  83. EnableDlgItem(IDC_BUTTON_REMOVE, iItemSelected >= 0);
  84. EnableDlgItem(IDC_BUTTON_EDIT, iItemSelected >= 0);
  85. }
  86. void CSimPropPage::OnClickListview(NMHDR*, LRESULT* pResult)
  87. {
  88. UpdateUI();
  89. *pResult = 0;
  90. }
  91. void CSimPropPage::OnDblclkListview(NMHDR*, LRESULT* pResult)
  92. {
  93. UpdateUI();
  94. SendMessage(WM_COMMAND, IDC_BUTTON_EDIT);
  95. *pResult = 0;
  96. }
  97. void CSimPropPage::OnItemchangedListview(NMHDR*, LRESULT* pResult)
  98. {
  99. UpdateUI();
  100. *pResult = 0;
  101. }
  102. void CSimPropPage::OnButtonRemove()
  103. {
  104. int iItem = 0;
  105. CSimEntry * pSimEntry = (CSimEntry *)ListView_GetItemLParam(m_hwndListview, -1, OUT &iItem);
  106. if (pSimEntry == NULL || iItem < 0)
  107. {
  108. Report(FALSE && "No item selected");
  109. return;
  110. }
  111. m_pData->DeleteSimEntry(pSimEntry);
  112. UpdateData(FALSE);
  113. SetDirty();
  114. GetDlgItem (IDC_BUTTON_ADD)->SetFocus ();
  115. }
  116. void CSimPropPage::OnSetfocusEditUserAccount()
  117. {
  118. // Clear the selection and rewind caret to beginning
  119. SendDlgItemMessage(IDC_EDIT_USER_ACCOUNT, EM_SETSEL, 0, 0);
  120. }
  121. void CSimPropPage::OnKeydownListview(NMHDR* pNMHDR, LRESULT* pResult)
  122. {
  123. LV_KEYDOWN * pLVKeyDow = (LV_KEYDOWN *)pNMHDR;
  124. switch (pLVKeyDow->wVKey)
  125. {
  126. case VK_INSERT:
  127. SendMessage(WM_COMMAND, IDC_BUTTON_ADD);
  128. break;
  129. case VK_DELETE:
  130. SendMessage(WM_COMMAND, IDC_BUTTON_REMOVE);
  131. break;
  132. } // switch
  133. *pResult = 0;
  134. }
  135. BOOL CSimPropPage::OnHelp(WPARAM, LPARAM lParam)
  136. {
  137. TRACE0 ("Entering CSimPropPage::OnHelp\n");
  138. const LPHELPINFO pHelpInfo = (LPHELPINFO)lParam;
  139. if (pHelpInfo && pHelpInfo->iContextType == HELPINFO_WINDOW)
  140. {
  141. DoContextHelp ((HWND) pHelpInfo->hItemHandle);
  142. }
  143. TRACE0 ("Leaving CSimPropPage::OnHelp\n");
  144. return TRUE;
  145. }