Source code of Windows XP (NT5)
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.

215 lines
5.7 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 -99 **/
  4. /**********************************************************************/
  5. /*
  6. dynrecpp.cpp
  7. Comment goes here
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "winssnap.h"
  12. #include "DynRecpp.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CDynamicPropGen property page
  20. IMPLEMENT_DYNCREATE(CDynamicPropGen, CPropertyPageBase)
  21. CDynamicPropGen::CDynamicPropGen() : CPropertyPageBase(CDynamicPropGen::IDD)
  22. {
  23. //{{AFX_DATA_INIT(CDynamicPropGen)
  24. //}}AFX_DATA_INIT
  25. }
  26. CDynamicPropGen::~CDynamicPropGen()
  27. {
  28. }
  29. void CDynamicPropGen::DoDataExchange(CDataExchange* pDX)
  30. {
  31. CPropertyPageBase::DoDataExchange(pDX);
  32. //{{AFX_DATA_MAP(CDynamicPropGen)
  33. DDX_Control(pDX, IDC_EDIT_OWNER, m_editOwner);
  34. DDX_Control(pDX, IDC_LIST_ADDRESSES, m_listAddresses);
  35. DDX_Control(pDX, IDC_STATIC_IPADD, m_staticIPAdd);
  36. DDX_Control(pDX, IDC_EDIT_VERSION, m_editVersion);
  37. DDX_Control(pDX, IDC_EDIT_TYPE, m_editType);
  38. DDX_Control(pDX, IDC_EDIT_STATE, m_editState);
  39. DDX_Control(pDX, IDC_EDIT_NAME, m_editName);
  40. DDX_Control(pDX, IDC_EDIT_EXPIRATION, m_editExpiration);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CDynamicPropGen, CPropertyPageBase)
  44. //{{AFX_MSG_MAP(CDynamicPropGen)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CDynamicPropGen message handlers
  49. /////////////////////////////////////////////////////////////////////////////
  50. // CDynamicMappingProperties message handlers
  51. CDynamicMappingProperties::CDynamicMappingProperties
  52. (
  53. ITFSNode * pNode,
  54. IComponent * pComponent,
  55. LPCTSTR pszSheetName,
  56. WinsRecord* pwRecord
  57. ) : CPropertyPageHolderBase(pNode, pComponent, pszSheetName)
  58. {
  59. m_bAutoDeletePages = FALSE; // we have the pages as embedded members
  60. AddPageToList((CPropertyPageBase*) &m_pageGeneral);
  61. if(pwRecord)
  62. {
  63. ZeroMemory(&m_wsRecord, sizeof(m_wsRecord));
  64. strcpy(m_wsRecord.szRecordName , pwRecord->szRecordName);
  65. m_wsRecord.dwExpiration = pwRecord->dwExpiration;
  66. m_wsRecord.dwExpiration = pwRecord->dwExpiration;
  67. m_wsRecord.dwNoOfAddrs = pwRecord->dwNoOfAddrs;
  68. for(DWORD i = 0; i < pwRecord->dwNoOfAddrs; i++)
  69. {
  70. m_wsRecord.dwIpAdd[i] = pwRecord->dwIpAdd[i];
  71. }
  72. m_wsRecord.liVersion = pwRecord->liVersion;
  73. m_wsRecord.dwNameLen = pwRecord->dwNameLen;
  74. m_wsRecord.dwOwner = pwRecord->dwOwner;
  75. m_wsRecord.dwState = pwRecord->dwState;
  76. m_wsRecord.dwType = pwRecord->dwType;
  77. }
  78. }
  79. CDynamicMappingProperties::~CDynamicMappingProperties()
  80. {
  81. RemovePageFromList((CPropertyPageBase*) &m_pageGeneral, FALSE);
  82. }
  83. BOOL CDynamicPropGen::OnInitDialog()
  84. {
  85. CPropertyPageBase::OnInitDialog();
  86. // get the actreg node
  87. CActiveRegistrationsHandler *pActReg;
  88. SPITFSNode spNode;
  89. spNode = GetHolder()->GetNode();
  90. pActReg = GETHANDLER(CActiveRegistrationsHandler, spNode);
  91. WinsRecord ws = ((CDynamicMappingProperties*)GetHolder())->m_wsRecord;
  92. // build the name string
  93. CString strName;
  94. pActReg->CleanNetBIOSName(ws.szRecordName,
  95. strName,
  96. TRUE, // Expand
  97. TRUE, // Truncate
  98. pActReg->IsLanManCompatible(),
  99. TRUE, // name is OEM
  100. FALSE, // No double backslash
  101. ws.dwNameLen);
  102. m_editName.SetWindowText(strName);
  103. // setup the listbox
  104. CString strColumn;
  105. strColumn.LoadString(IDS_IP_ADDRESS);
  106. m_listAddresses.InsertColumn(0, strColumn, LVCFMT_LEFT, 90);
  107. ListView_SetExtendedListViewStyle(m_listAddresses.GetSafeHwnd(), LVS_EX_FULLROWSELECT);
  108. BOOL fMultiCol = !( (ws.dwState & WINSDB_REC_UNIQUE) ||
  109. (ws.dwState & WINSDB_REC_NORM_GROUP) );
  110. if (fMultiCol)
  111. {
  112. strColumn.LoadString(IDS_ACTREG_OWNER);
  113. m_listAddresses.InsertColumn(1, strColumn, LVCFMT_LEFT, 90);
  114. }
  115. CString strIP, strOwnerIP;
  116. int nIndex = 0;
  117. for (DWORD i = 0; i < ws.dwNoOfAddrs; i++)
  118. {
  119. if (fMultiCol)
  120. {
  121. ::MakeIPAddress(ws.dwIpAdd[i++], strOwnerIP);
  122. ::MakeIPAddress(ws.dwIpAdd[i], strIP);
  123. if (ws.dwIpAdd[i] != 0)
  124. {
  125. m_listAddresses.InsertItem(nIndex, strIP);
  126. m_listAddresses.SetItem(nIndex, 1, LVIF_TEXT, strOwnerIP, 0, 0, 0, 0);
  127. }
  128. }
  129. else
  130. {
  131. ::MakeIPAddress(ws.dwIpAdd[i], strIP);
  132. m_listAddresses.InsertItem(nIndex, strIP);
  133. }
  134. nIndex++;
  135. }
  136. // now the type
  137. CString strType;
  138. pActReg->m_NameTypeMap.TypeToCString((DWORD)ws.szRecordName[15], MAKELONG(HIWORD(ws.dwType), 0), strType);
  139. m_editType.SetWindowText(strType);
  140. // active status
  141. CString strActive;
  142. pActReg->GetStateString(ws.dwState, strActive);
  143. m_editState.SetWindowText(strActive);
  144. // expiration time
  145. CString strExpiration;
  146. CTime timeExpiration(ws.dwExpiration);
  147. FormatDateTime(strExpiration, timeExpiration);
  148. m_editExpiration.SetWindowText(strExpiration);
  149. // version
  150. CString strVersion;
  151. pActReg->GetVersionInfo(ws.liVersion.LowPart, ws.liVersion.HighPart, strVersion);
  152. m_editVersion.SetWindowText(strVersion);
  153. // owner
  154. if (ws.dwOwner != INVALID_OWNER_ID)
  155. {
  156. CString strOwner;
  157. MakeIPAddress(ws.dwOwner, strOwner);
  158. m_editOwner.SetWindowText(strOwner);
  159. }
  160. // load the correct icon
  161. for (i = 0; i < ICON_IDX_MAX; i++)
  162. {
  163. if (g_uIconMap[i][1] == m_uImage)
  164. {
  165. HICON hIcon = LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(g_uIconMap[i][0]));
  166. if (hIcon)
  167. ((CStatic *) GetDlgItem(IDC_STATIC_ICON))->SetIcon(hIcon);
  168. break;
  169. }
  170. }
  171. return TRUE;
  172. }