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.

1440 lines
36 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. loadrecs.cpp
  7. dialog to load records from the datbase, includes by owner
  8. and by record type.
  9. FILE HISTORY:
  10. */
  11. #include "stdafx.h"
  12. #include "winssnap.h"
  13. #include "loadrecs.h"
  14. #include "server.h"
  15. #ifdef _DEBUG
  16. #define new DEBUG_NEW
  17. #undef THIS_FILE
  18. static char THIS_FILE[] = __FILE__;
  19. #endif
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CLoadRecords
  22. IMPLEMENT_DYNAMIC(CLoadRecords, CPropertySheet)
  23. CLoadRecords::CLoadRecords(UINT nIDCaption)
  24. :CPropertySheet(nIDCaption)
  25. {
  26. AddPage(&m_pageIpAddress);
  27. AddPage(&m_pageOwners);
  28. AddPage(&m_pageTypes);
  29. m_psh.dwFlags |= PSH_NOAPPLYNOW;
  30. m_nActivePage = 0;
  31. m_bEnableCache = FALSE;
  32. m_bCaching = FALSE;
  33. }
  34. CLoadRecords::~CLoadRecords()
  35. {
  36. }
  37. VOID CLoadRecords::ResetFiltering()
  38. {
  39. m_pageOwners.m_dwaOwnerFilter.RemoveAll();
  40. m_pageIpAddress.m_dwaIPAddrs.RemoveAll();
  41. m_pageIpAddress.m_dwaIPMasks.RemoveAll();
  42. m_pageIpAddress.m_bFilterIpAddr = FALSE;
  43. m_pageIpAddress.m_bFilterIpMask = FALSE;
  44. m_pageIpAddress.m_bFilterName = FALSE;
  45. m_pageIpAddress.m_bMatchCase = FALSE;
  46. }
  47. BEGIN_MESSAGE_MAP(CLoadRecords, CPropertySheet)
  48. //{{AFX_MSG_MAP(CLoadRecords)
  49. ON_WM_HELPINFO()
  50. //}}AFX_MSG_MAP
  51. END_MESSAGE_MAP()
  52. BOOL CLoadRecords::OnInitDialog()
  53. {
  54. CPropertySheet::OnInitDialog();
  55. m_bCaching = m_bEnableCache;
  56. SetActivePage(m_nActivePage);
  57. return TRUE;
  58. }
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CLoadRecords message handlers
  61. //
  62. extern const DWORD g_aHelpIDs_DisplayRecords_PpSheet[];
  63. BOOL CLoadRecords::OnHelpInfo(HELPINFO* pHelpInfo)
  64. {
  65. int i;
  66. DWORD dwCtrlId;
  67. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  68. {
  69. DWORD * pdwHelp = (LPDWORD)g_aHelpIDs_DisplayRecords_PpSheet;
  70. if (pdwHelp)
  71. {
  72. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  73. AfxGetApp()->m_pszHelpFilePath,
  74. HELP_WM_HELP,
  75. (ULONG_PTR)pdwHelp);
  76. }
  77. }
  78. return TRUE;
  79. }
  80. /////////////////////////////////////////////////////////////////////////////
  81. // COwnerPage dialog
  82. int CALLBACK OwnerPageCompareFunc
  83. (
  84. LPARAM lParam1,
  85. LPARAM lParam2,
  86. LPARAM lParamSort
  87. )
  88. {
  89. return ((COwnerPage *) lParamSort)->HandleSort(lParam1, lParam2);
  90. }
  91. COwnerPage::COwnerPage()
  92. : CPropertyPage(COwnerPage::IDD)
  93. {
  94. m_nSortColumn = -1;
  95. for (int i = 0; i < COLUMN_MAX; i++)
  96. {
  97. m_aSortOrder[i] = TRUE; // ascending
  98. }
  99. m_pbaDirtyFlags = NULL;
  100. m_bDirtyOwners = FALSE;
  101. //{{AFX_DATA_INIT(COwnerPage)
  102. //}}AFX_DATA_INIT
  103. }
  104. COwnerPage::~COwnerPage()
  105. {
  106. if (m_pbaDirtyFlags != NULL)
  107. delete m_pbaDirtyFlags;
  108. }
  109. DWORD COwnerPage::GetOwnerForApi()
  110. {
  111. return m_dwaOwnerFilter.GetSize() == 1 ? m_dwaOwnerFilter[0] : (DWORD)-1;
  112. }
  113. void COwnerPage::DoDataExchange(CDataExchange* pDX)
  114. {
  115. CPropertyPage::DoDataExchange(pDX);
  116. //{{AFX_DATA_MAP(COwnerPage)
  117. DDX_Control(pDX, IDC_ENABLE_CACHING, m_btnEnableCache);
  118. DDX_Control(pDX, IDC_LIST_OWNER, m_listOwner);
  119. //}}AFX_DATA_MAP
  120. }
  121. BEGIN_MESSAGE_MAP(COwnerPage, CPropertyPage)
  122. //{{AFX_MSG_MAP(COwnerPage)
  123. ON_NOTIFY(LVN_COLUMNCLICK, IDC_LIST_OWNER, OnColumnclickListOwner)
  124. ON_WM_HELPINFO()
  125. ON_BN_CLICKED(IDC_BUTTON_SELECT_ALL, OnButtonSelectAll)
  126. ON_BN_CLICKED(IDC_BUTTON_UNSELECT_ALL, OnButtonUnselectAll)
  127. ON_BN_CLICKED(IDC_BUTTON_LOCAL, OnButtonLocal)
  128. ON_BN_CLICKED(IDC_ENABLE_CACHING, OnEnableCaching)
  129. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST_OWNER, OnItemchangedListOwner)
  130. //}}AFX_MSG_MAP
  131. END_MESSAGE_MAP()
  132. /////////////////////////////////////////////////////////////////////////////
  133. // COwnerPage message handlers
  134. BOOL COwnerPage::OnInitDialog()
  135. {
  136. CPropertyPage::OnInitDialog();
  137. BOOL ftest = m_ImageList.Create(IDB_LIST_STATE, 16, 1, RGB(255, 0, 0));
  138. // set the list item images
  139. m_listOwner.SetImageList(NULL, LVSIL_NORMAL);
  140. m_listOwner.SetImageList(NULL, LVSIL_SMALL);
  141. m_listOwner.SetImageList(&m_ImageList, LVSIL_STATE);
  142. // fill the header informnation for the list control
  143. CString strOwner;
  144. strOwner.LoadString(IDS_OWNER);
  145. m_listOwner.InsertColumn(COLUMN_IP, strOwner, LVCFMT_LEFT, 100, 1);
  146. CString strName;
  147. strName.LoadString(IDS_NAME);
  148. m_listOwner.InsertColumn(COLUMN_NAME, strName, LVCFMT_LEFT, 95, -1);
  149. CString strID;
  150. strID.LoadString(IDS_HIGHESTID);
  151. m_listOwner.InsertColumn(COLUMN_VERSION, strID, LVCFMT_LEFT, 75, -1);
  152. m_listOwner.SetFullRowSel(TRUE);
  153. // update the UI
  154. FillOwnerInfo();
  155. return TRUE;
  156. }
  157. void
  158. COwnerPage::FillOwnerInfo()
  159. {
  160. int i;
  161. m_nChecked = 0;
  162. if (m_ServerInfoArray.GetSize() > 0)
  163. {
  164. int nDirtySize = (int)m_ServerInfoArray.GetSize();
  165. if (m_pbaDirtyFlags != NULL)
  166. delete m_pbaDirtyFlags;
  167. m_pbaDirtyFlags = new BYTE[nDirtySize];
  168. if (m_pbaDirtyFlags != NULL)
  169. RtlZeroMemory(m_pbaDirtyFlags, nDirtySize);
  170. }
  171. for (i = 0; i < m_ServerInfoArray.GetSize(); i++)
  172. {
  173. //
  174. // if this owner is deleted or doesn't have any records to show
  175. // then don't add it to the list. Owners can have an ID of 0 if they don't
  176. // have any records but were found owning an address in a 1c record in the database
  177. //
  178. if ( (m_ServerInfoArray[i].m_liVersion.QuadPart == OWNER_DELETED) ||
  179. (m_ServerInfoArray[i].m_liVersion.QuadPart == 0) )
  180. {
  181. // skip this one
  182. continue;
  183. }
  184. CString strIPAdd;
  185. ::MakeIPAddress(m_ServerInfoArray[i].m_dwIp, strIPAdd);
  186. CString strVers = GetVersionInfo(m_ServerInfoArray[i].m_liVersion.LowPart,
  187. m_ServerInfoArray[i].m_liVersion.HighPart);
  188. int nItem = m_listOwner.InsertItem(i, strIPAdd, 0);
  189. m_listOwner.SetItemText(nItem, 1, m_ServerInfoArray[i].m_strName);
  190. m_listOwner.SetItemText(nItem, 2, strVers);
  191. m_listOwner.SetItemData(nItem, i);
  192. // empty filter array means all owners should be selected
  193. if (m_dwaOwnerFilter.GetSize() == 0)
  194. {
  195. m_listOwner.SetCheck(nItem, TRUE);
  196. m_pbaDirtyFlags[i] |= 2;
  197. }
  198. else
  199. {
  200. // filter array is not empty, we check the item if it is found in the filter
  201. for (int j = (int)m_dwaOwnerFilter.GetSize()-1; j >= 0; j--)
  202. {
  203. if (m_ServerInfoArray[i].m_dwIp == m_dwaOwnerFilter[j])
  204. {
  205. m_listOwner.SetCheck(nItem, TRUE);
  206. m_pbaDirtyFlags[i] |= 2;
  207. break;
  208. }
  209. }
  210. if (j < 0)
  211. {
  212. // m_nChecked keeps a count of how many items are checked in the list.
  213. // each SetCheck() balances the counter -> ++ if an item is checked
  214. // -- if an item in unchecked. However, initially, we need to set the items
  215. // that are unchecked explicitly otherwise the checkbox doesn't show up.
  216. // this could unballance the counter if we don't correct it by incrementing
  217. // it first. Whatever we add here is decremented immediately after because
  218. // of the SetCheck(..FALSE) below.
  219. m_nChecked++;
  220. m_listOwner.SetCheck(nItem, FALSE);
  221. }
  222. }
  223. }
  224. Sort(COLUMN_IP);
  225. for (i = m_listOwner.GetItemCount()-1; i >=0; i--)
  226. {
  227. if (m_listOwner.GetCheck(i))
  228. {
  229. m_listOwner.EnsureVisible(i,FALSE);
  230. break;
  231. }
  232. }
  233. m_listOwner.SetFocus();
  234. }
  235. CString
  236. COwnerPage::GetVersionInfo(LONG lLowWord, LONG lHighWord)
  237. {
  238. CString strVersionCount;
  239. TCHAR sz[20];
  240. TCHAR *pch = sz;
  241. ::wsprintf(sz, _T("%08lX%08lX"), lHighWord, lLowWord);
  242. // Kill leading zero's
  243. while (*pch == '0')
  244. {
  245. ++pch;
  246. }
  247. // At least one digit...
  248. if (*pch == '\0')
  249. {
  250. --pch;
  251. }
  252. strVersionCount = pch;
  253. return strVersionCount;
  254. }
  255. void COwnerPage::OnOK()
  256. {
  257. int i;
  258. BOOL bAllSelected;
  259. UpdateData();
  260. // clear any previous owners in the array since
  261. // GetSelectedOwner() is copying over the new
  262. // selected owners
  263. m_dwaOwnerFilter.RemoveAll();
  264. for (i = (int)m_ServerInfoArray.GetSize()-1; i>=0; i--)
  265. {
  266. if ( (m_ServerInfoArray[i].m_liVersion.QuadPart != OWNER_DELETED) &&
  267. (m_ServerInfoArray[i].m_liVersion.QuadPart != 0) &&
  268. !(m_pbaDirtyFlags[i] & 1) )
  269. {
  270. bAllSelected = FALSE;
  271. break;
  272. }
  273. }
  274. // mark owners as dirty only if some new owners are added - removing an owner shouldn't
  275. // force the database to be reloaded in any way since the records are already there.
  276. m_bDirtyOwners = FALSE;
  277. for (i = (int)m_ServerInfoArray.GetSize()-1; i >=0; i--)
  278. {
  279. // 0 - owner was not in the list and it is not now
  280. // 1 - owner was not in the list but it is now
  281. // 2 - owner was in the list and it is not now
  282. // 3 - owner was in the list and it is now
  283. if (!m_bDirtyOwners && m_pbaDirtyFlags[i] == 1)
  284. {
  285. m_bDirtyOwners = TRUE;
  286. }
  287. if (!bAllSelected && (m_pbaDirtyFlags[i] & 1))
  288. {
  289. m_dwaOwnerFilter.Add(m_ServerInfoArray[i].m_dwIp);
  290. }
  291. }
  292. CPropertyPage::OnOK();
  293. }
  294. void COwnerPage::Sort(int nCol)
  295. {
  296. if (m_nSortColumn == nCol)
  297. {
  298. // if the user is clicking the same column again, reverse the sort order
  299. m_aSortOrder[nCol] = m_aSortOrder[nCol] ? FALSE : TRUE;
  300. }
  301. else
  302. {
  303. m_nSortColumn = nCol;
  304. }
  305. m_listOwner.SortItems(OwnerPageCompareFunc, (LPARAM) this);
  306. }
  307. int COwnerPage::HandleSort(LPARAM lParam1, LPARAM lParam2)
  308. {
  309. int nCompare = 0;
  310. switch (m_nSortColumn)
  311. {
  312. case COLUMN_IP:
  313. {
  314. DWORD dwIp1 = m_ServerInfoArray.GetAt((int) lParam1).m_dwIp;
  315. DWORD dwIp2 = m_ServerInfoArray.GetAt((int) lParam2).m_dwIp;
  316. if (dwIp1 > dwIp2)
  317. nCompare = 1;
  318. else
  319. if (dwIp1 < dwIp2)
  320. nCompare = -1;
  321. }
  322. break;
  323. case COLUMN_NAME:
  324. {
  325. CString strName1 = m_ServerInfoArray[(int) lParam1].m_strName;
  326. CString strName2 = m_ServerInfoArray[(int) lParam2].m_strName;
  327. nCompare = strName1.CompareNoCase(strName2);
  328. }
  329. break;
  330. case COLUMN_VERSION:
  331. {
  332. LARGE_INTEGER li1, li2;
  333. li1.QuadPart = m_ServerInfoArray.GetAt((int) lParam1).m_liVersion.QuadPart;
  334. li2.QuadPart = m_ServerInfoArray.GetAt((int) lParam2).m_liVersion.QuadPart;
  335. if (li1.QuadPart > li2.QuadPart)
  336. nCompare = 1;
  337. else
  338. if (li1.QuadPart < li2.QuadPart)
  339. nCompare = -1;
  340. }
  341. break;
  342. }
  343. if (m_aSortOrder[m_nSortColumn] == FALSE)
  344. {
  345. // descending
  346. return -nCompare;
  347. }
  348. else
  349. {
  350. // ascending
  351. return nCompare;
  352. }
  353. }
  354. void COwnerPage::OnColumnclickListOwner(NMHDR* pNMHDR, LRESULT* pResult)
  355. {
  356. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  357. // sort depending on what column was clicked;
  358. Sort(pNMListView->iSubItem);
  359. *pResult = 0;
  360. }
  361. BOOL COwnerPage::OnHelpInfo(HELPINFO* pHelpInfo)
  362. {
  363. int i;
  364. DWORD dwCtrlId;
  365. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  366. {
  367. DWORD * pdwHelp = GetHelpMap();
  368. if (pdwHelp)
  369. {
  370. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  371. AfxGetApp()->m_pszHelpFilePath,
  372. HELP_WM_HELP,
  373. (ULONG_PTR)pdwHelp);
  374. }
  375. }
  376. return TRUE;
  377. }
  378. void COwnerPage::OnButtonLocal()
  379. {
  380. int iLocal = 0;
  381. for (int i = 0; i < m_listOwner.GetItemCount(); i++)
  382. {
  383. // item data has the owner id and the local server always
  384. // has the owner id = 0
  385. if ((DWORD)m_listOwner.GetItemData(i) == 0)
  386. iLocal = i;
  387. m_listOwner.SetCheck(i, (DWORD)m_listOwner.GetItemData(i) == 0);
  388. }
  389. m_listOwner.EnsureVisible(iLocal, FALSE);
  390. }
  391. void COwnerPage::OnButtonSelectAll()
  392. {
  393. for (int i = 0; i < m_listOwner.GetItemCount(); i++)
  394. {
  395. m_listOwner.SetCheck(i, TRUE);
  396. }
  397. }
  398. void COwnerPage::OnButtonUnselectAll()
  399. {
  400. for (int i = 0; i < m_listOwner.GetItemCount(); i++)
  401. {
  402. m_listOwner.SetCheck(i, FALSE);
  403. }
  404. }
  405. BOOL COwnerPage::OnKillActive()
  406. {
  407. int i;
  408. for (i = m_listOwner.GetItemCount()-1; i >=0 ; i--)
  409. {
  410. if (m_listOwner.GetCheck(i) == TRUE)
  411. break;
  412. }
  413. if (i<0)
  414. {
  415. // tell the user to select at least one name type to display
  416. WinsMessageBox(IDS_ERR_NO_OWNER_SPECIFIED);
  417. PropSheet_SetCurSel(GetSafeHwnd(), NULL, 0);
  418. m_listOwner.SetFocus();
  419. return FALSE;
  420. }
  421. return CPropertyPage::OnKillActive();
  422. }
  423. BOOL COwnerPage::OnSetActive()
  424. {
  425. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  426. m_btnEnableCache.SetCheck(pParent->m_bCaching);
  427. return CPropertyPage::OnSetActive();
  428. }
  429. void COwnerPage::OnEnableCaching()
  430. {
  431. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  432. pParent->m_bCaching = (m_btnEnableCache.GetCheck() == 1);
  433. }
  434. void COwnerPage::OnItemchangedListOwner(NMHDR* pNMHDR, LRESULT* pResult)
  435. {
  436. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  437. BOOL bInc;
  438. // if the checkbox isn't changed we don't care
  439. if ( pNMListView->uChanged & LVIF_STATE &&
  440. (pNMListView->uOldState & LVIS_STATEIMAGEMASK) != (pNMListView->uNewState & LVIS_STATEIMAGEMASK))
  441. {
  442. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  443. if ((pNMListView->uNewState & INDEXTOSTATEIMAGEMASK(2)) != 0)
  444. {
  445. m_pbaDirtyFlags[pNMListView->lParam] |= 1;
  446. m_nChecked++;
  447. bInc = TRUE;
  448. }
  449. else
  450. {
  451. m_pbaDirtyFlags[pNMListView->lParam] &= ~1;
  452. m_nChecked--;
  453. bInc = FALSE;
  454. }
  455. }
  456. *pResult = 0;
  457. }
  458. /////////////////////////////////////////////////////////////////////////////
  459. // CFilterPage dialog
  460. int CALLBACK FilterPageCompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
  461. {
  462. if (lParam1 < lParam2)
  463. return -1;
  464. else
  465. if (lParam1 > lParam2)
  466. return 1;
  467. else
  468. return 0;
  469. }
  470. CFilterPage::CFilterPage()
  471. : CPropertyPage(CFilterPage::IDD)
  472. {
  473. //{{AFX_DATA_INIT(CFilterPage)
  474. //}}AFX_DATA_INIT
  475. m_bDirtyTypes = FALSE;
  476. m_pbaDirtyFlags = NULL;
  477. m_nDirtyFlags = 0;
  478. }
  479. CFilterPage::~CFilterPage()
  480. {
  481. if (m_pbaDirtyFlags != NULL)
  482. delete m_pbaDirtyFlags;
  483. }
  484. void CFilterPage::DoDataExchange(CDataExchange* pDX)
  485. {
  486. CPropertyPage::DoDataExchange(pDX);
  487. //{{AFX_DATA_MAP(CFilterPage)
  488. DDX_Control(pDX, IDC_ENABLE_CACHING, m_btnEnableCache);
  489. DDX_Control(pDX, IDC_BUTTON_DELETE_TYPE, m_buttonDelete);
  490. DDX_Control(pDX, IDC_BUTTON_MODIFY_TYPE, m_buttonModify);
  491. DDX_Control(pDX, IDC_LIST1, m_listType);
  492. //}}AFX_DATA_MAP
  493. }
  494. BEGIN_MESSAGE_MAP(CFilterPage, CPropertyPage)
  495. //{{AFX_MSG_MAP(CFilterPage)
  496. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, OnItemchangedList1)
  497. ON_BN_CLICKED(IDC_BUTTON_ADD_TYPE, OnButtonAddType)
  498. ON_BN_CLICKED(IDC_BUTTON_MODIFY_TYPE, OnButtonModifyType)
  499. ON_BN_CLICKED(IDC_BUTTON_DELETE_TYPE, OnButtonDelete)
  500. ON_WM_HELPINFO()
  501. ON_BN_CLICKED(IDC_BUTTON_SELECT_ALL, OnButtonSelectAll)
  502. ON_BN_CLICKED(IDC_BUTTON_UNSELECT_ALL, OnButtonUnselectAll)
  503. ON_BN_CLICKED(IDC_ENABLE_CACHING, OnEnableCaching)
  504. //}}AFX_MSG_MAP
  505. END_MESSAGE_MAP()
  506. /////////////////////////////////////////////////////////////////////////////
  507. // CFilterPage message handlers
  508. BOOL CFilterPage::OnInitDialog()
  509. {
  510. CPropertyPage::OnInitDialog();
  511. BOOL ftest = m_ImageList.Create(IDB_LIST_STATE, 16, 1, RGB(255, 0, 0));
  512. m_listType.SetImageList(NULL, LVSIL_NORMAL);
  513. m_listType.SetImageList(NULL, LVSIL_SMALL);
  514. m_listType.SetImageList(&m_ImageList, LVSIL_STATE);
  515. m_listType.InsertColumn(0, _T("Test"), LVCFMT_LEFT, 250);
  516. m_buttonModify.EnableWindow(FALSE);
  517. m_buttonDelete.EnableWindow(FALSE);
  518. FillTypeInfo();
  519. m_nDirtyFlags = (UINT)m_arrayTypeFilter.GetSize();
  520. if (m_pbaDirtyFlags != NULL)
  521. delete m_pbaDirtyFlags;
  522. m_pbaDirtyFlags = new tDirtyFlags[m_nDirtyFlags];
  523. if ( m_pbaDirtyFlags != NULL)
  524. {
  525. RtlZeroMemory(m_pbaDirtyFlags, m_nDirtyFlags*sizeof(tDirtyFlags));
  526. for (UINT i = 0; i<m_nDirtyFlags; i++)
  527. {
  528. m_pbaDirtyFlags[i].dwType = m_arrayTypeFilter[i].dwType;
  529. if (m_arrayTypeFilter[i].fShow)
  530. {
  531. m_pbaDirtyFlags[i].bFlags = 2;
  532. }
  533. }
  534. }
  535. else
  536. {
  537. m_nDirtyFlags = 0;
  538. }
  539. return TRUE;
  540. }
  541. void CFilterPage::OnOK()
  542. {
  543. if (m_pbaDirtyFlags == NULL)
  544. {
  545. m_bDirtyTypes = TRUE;
  546. }
  547. else
  548. {
  549. int i,j;
  550. m_bDirtyTypes = FALSE;
  551. for (i = (int)m_arrayTypeFilter.GetSize()-1; i>=0; i--)
  552. {
  553. for (j = m_nDirtyFlags-1; j>=0; j--)
  554. {
  555. if (m_arrayTypeFilter[i].dwType == m_pbaDirtyFlags[j].dwType)
  556. {
  557. if (m_arrayTypeFilter[i].fShow)
  558. m_pbaDirtyFlags[j].bFlags |= 1;
  559. break;
  560. }
  561. }
  562. if (j<0 && m_arrayTypeFilter[i].fShow)
  563. {
  564. m_bDirtyTypes = TRUE;
  565. break;
  566. }
  567. }
  568. for (j = m_nDirtyFlags-1; j>=0; j--)
  569. {
  570. if (m_pbaDirtyFlags[j].bFlags == 1)
  571. {
  572. m_bDirtyTypes = TRUE;
  573. break;
  574. }
  575. }
  576. }
  577. CPropertyPage::OnOK();
  578. }
  579. BOOL CFilterPage::OnKillActive()
  580. {
  581. BOOL fShowOneType = FALSE;
  582. for (int i = 0; i < m_arrayTypeFilter.GetSize(); i++)
  583. {
  584. if (m_arrayTypeFilter[i].fShow == TRUE)
  585. {
  586. fShowOneType = TRUE;
  587. break;
  588. }
  589. }
  590. if (!fShowOneType)
  591. {
  592. // tell the user to select at least one name type to display
  593. WinsMessageBox(IDS_ERR_NO_NAME_TYPE_SPECIFIED);
  594. PropSheet_SetCurSel(GetSafeHwnd(), NULL, 0);
  595. m_listType.SetFocus();
  596. return FALSE;
  597. }
  598. return CPropertyPage::OnKillActive();
  599. }
  600. BOOL CFilterPage::OnSetActive()
  601. {
  602. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  603. m_btnEnableCache.SetCheck(pParent->m_bCaching);
  604. return CPropertyPage::OnSetActive();
  605. }
  606. void CFilterPage::OnEnableCaching()
  607. {
  608. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  609. pParent->m_bCaching = (m_btnEnableCache.GetCheck() == 1);
  610. }
  611. void CFilterPage::OnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult)
  612. {
  613. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  614. // check to see if this item is checked
  615. BOOL bChecked = m_listType.GetCheck(pNMListView->iItem);
  616. int nIndex = pNMListView->iItem;
  617. DWORD dwType = (DWORD) m_listType.GetItemData(nIndex);
  618. // if the state isn't changing, then we don't care
  619. if ( !(pNMListView->uChanged & LVIF_STATE) )
  620. return;
  621. for (int i = 0; i < m_arrayTypeFilter.GetSize(); i++)
  622. {
  623. if (m_arrayTypeFilter[i].dwType == dwType)
  624. {
  625. m_arrayTypeFilter[i].fShow = bChecked;
  626. }
  627. }
  628. if (m_listType.IsSelected(nIndex) &&
  629. !IsDefaultType(dwType) )
  630. {
  631. m_buttonModify.EnableWindow(TRUE);
  632. m_buttonDelete.EnableWindow(TRUE);
  633. }
  634. else
  635. {
  636. m_buttonModify.EnableWindow(FALSE);
  637. m_buttonDelete.EnableWindow(FALSE);
  638. }
  639. *pResult = 0;
  640. }
  641. void CFilterPage::OnButtonAddType()
  642. {
  643. CNameTypeDlg dlgNameType;
  644. dlgNameType.m_pNameTypeMap = m_pNameTypeMap;
  645. if (dlgNameType.DoModal() == IDOK)
  646. {
  647. // add new type here
  648. HRESULT hr = m_pNameTypeMap->AddEntry(dlgNameType.m_dwId, dlgNameType.m_strDescription);
  649. if (FAILED(hr))
  650. {
  651. WinsMessageBox(WIN32_FROM_HRESULT(hr));
  652. return;
  653. }
  654. // update our array that keeps track of check state
  655. CTypeFilterInfo typeFilterInfo;
  656. typeFilterInfo.dwType = dlgNameType.m_dwId;
  657. typeFilterInfo.fShow = TRUE;
  658. m_arrayTypeFilter.Add(typeFilterInfo);
  659. // update the listbox
  660. m_listType.DeleteAllItems();
  661. FillTypeInfo();
  662. }
  663. }
  664. void CFilterPage::OnButtonModifyType()
  665. {
  666. CNameTypeDlg dlgNameType;
  667. int nSelected;
  668. dlgNameType.m_pNameTypeMap = m_pNameTypeMap;
  669. nSelected = m_listType.GetNextItem(-1, LVNI_SELECTED);
  670. dlgNameType.m_fCreate = FALSE;
  671. dlgNameType.m_dwId = (DWORD) m_listType.GetItemData(nSelected);
  672. m_pNameTypeMap->TypeToCString(dlgNameType.m_dwId, -1, dlgNameType.m_strDescription);
  673. if (dlgNameType.DoModal() == IDOK)
  674. {
  675. // modify type here
  676. HRESULT hr = m_pNameTypeMap->ModifyEntry(dlgNameType.m_dwId, dlgNameType.m_strDescription);
  677. if (FAILED(hr))
  678. {
  679. WinsMessageBox(WIN32_FROM_HRESULT(hr));
  680. return;
  681. }
  682. // move the focus
  683. m_listType.SetFocus();
  684. SetDefID(IDOK);
  685. // update the listbox
  686. m_listType.DeleteAllItems();
  687. FillTypeInfo();
  688. }
  689. }
  690. void CFilterPage::OnButtonDelete()
  691. {
  692. HRESULT hr = hrOK;
  693. int nSelected;
  694. DWORD dwNameType;
  695. nSelected = m_listType.GetNextItem(-1, LVNI_SELECTED);
  696. dwNameType = (DWORD) m_listType.GetItemData(nSelected);
  697. // are you sure?
  698. if (AfxMessageBox(IDS_WARN_DELETE_NAME_TYPE, MB_YESNO) == IDYES)
  699. {
  700. hr = m_pNameTypeMap->RemoveEntry(dwNameType);
  701. if (SUCCEEDED(hr))
  702. {
  703. // remove from the list box
  704. m_listType.DeleteItem(nSelected);
  705. // remove from the active filters if it is in the list
  706. for (int i = 0; i < m_arrayTypeFilter.GetSize(); i++)
  707. {
  708. if (dwNameType == m_arrayTypeFilter[i].dwType)
  709. {
  710. m_arrayTypeFilter.RemoveAt(i);
  711. break;
  712. }
  713. }
  714. }
  715. else
  716. {
  717. WinsMessageBox(WIN32_FROM_HRESULT(hr));
  718. }
  719. // move the focus
  720. m_listType.SetFocus();
  721. SetDefID(IDOK);
  722. }
  723. }
  724. void
  725. CFilterPage::FillTypeInfo()
  726. {
  727. m_listType.DeleteAllItems();
  728. SPITFSNode spNode;
  729. CString strDisplay;
  730. CStringMapEntry mapEntry;
  731. int nColWidth, nColWidthTemp = 0;
  732. nColWidth = m_listType.GetColumnWidth(0);
  733. for (int i = 0; i < m_pNameTypeMap->GetSize(); i++)
  734. {
  735. mapEntry = m_pNameTypeMap->GetAt(i);
  736. // only display the default name type mapping strings, not the special
  737. // ones based on the wins type of record
  738. if (mapEntry.dwWinsType == -1)
  739. {
  740. if (mapEntry.dwNameType == NAME_TYPE_OTHER)
  741. {
  742. strDisplay.Format(_T("%s"), mapEntry.st);
  743. }
  744. else
  745. {
  746. strDisplay.Format(_T("[%02Xh] %s"), mapEntry.dwNameType, mapEntry.st);
  747. }
  748. if (m_listType.GetStringWidth(strDisplay) > nColWidthTemp)
  749. {
  750. nColWidthTemp = m_listType.GetStringWidth(strDisplay);
  751. }
  752. int nIndex = m_listType.AddItem(strDisplay, i);
  753. m_listType.SetItemData(nIndex, mapEntry.dwNameType);
  754. }
  755. }
  756. // if the strings are too long, update the column width
  757. if (nColWidthTemp > nColWidth)
  758. {
  759. m_listType.SetColumnWidth(0, nColWidthTemp + 50);
  760. }
  761. CheckItems();
  762. m_listType.SortItems(FilterPageCompareFunc, 0);
  763. }
  764. void
  765. CFilterPage::CheckItems()
  766. {
  767. int nCount = (int)m_arrayTypeFilter.GetSize();
  768. for (int i = 0; i < nCount; i++)
  769. {
  770. if (m_arrayTypeFilter[i].fShow)
  771. {
  772. DWORD dwFound = m_arrayTypeFilter[i].dwType;
  773. m_listType.CheckItem(GetIndex(dwFound));
  774. }
  775. }
  776. }
  777. void CFilterPage::OnButtonSelectAll()
  778. {
  779. for (int i = 0; i < m_listType.GetItemCount(); i++)
  780. {
  781. m_listType.SetCheck(i, TRUE);
  782. }
  783. }
  784. void CFilterPage::OnButtonUnselectAll()
  785. {
  786. for (int i = 0; i < m_listType.GetItemCount(); i++)
  787. {
  788. m_listType.SetCheck(i, FALSE);
  789. }
  790. }
  791. int
  792. CFilterPage::GetIndex(DWORD dwIndex)
  793. {
  794. int nResult = -1;
  795. int nCount = m_listType.GetItemCount();
  796. for (int i = 0; i < nCount; i++)
  797. {
  798. if (m_listType.GetItemData(i) == dwIndex)
  799. return i;
  800. }
  801. return nResult;
  802. }
  803. BOOL
  804. CFilterPage::IsDefaultType(DWORD dwType)
  805. {
  806. BOOL bDefault = FALSE;
  807. for (int i = 0; i < DimensionOf(s_NameTypeMappingDefault); i++)
  808. {
  809. if (s_NameTypeMappingDefault[i][0] == dwType)
  810. {
  811. bDefault = TRUE;
  812. break;
  813. }
  814. }
  815. return bDefault;
  816. }
  817. BOOL CFilterPage::OnHelpInfo(HELPINFO* pHelpInfo)
  818. {
  819. int i;
  820. DWORD dwCtrlId;
  821. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  822. {
  823. DWORD * pdwHelp = GetHelpMap();
  824. if (pdwHelp)
  825. {
  826. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  827. AfxGetApp()->m_pszHelpFilePath,
  828. HELP_WM_HELP,
  829. (ULONG_PTR)pdwHelp);
  830. }
  831. }
  832. return TRUE;
  833. }
  834. /////////////////////////////////////////////////////////////////////////////
  835. // CNameTypeDlg dialog
  836. CNameTypeDlg::CNameTypeDlg(CWnd* pParent /*=NULL*/)
  837. : CBaseDialog(CNameTypeDlg::IDD, pParent)
  838. {
  839. //{{AFX_DATA_INIT(CNameTypeDlg)
  840. m_strDescription = _T("");
  841. m_strId = _T("");
  842. //}}AFX_DATA_INIT
  843. m_fCreate = TRUE;
  844. m_dwId = 0;
  845. }
  846. void CNameTypeDlg::DoDataExchange(CDataExchange* pDX)
  847. {
  848. CBaseDialog::DoDataExchange(pDX);
  849. //{{AFX_DATA_MAP(CNameTypeDlg)
  850. DDX_Control(pDX, IDC_EDIT_NAME_TYPE_DESCRIPTION, m_editDescription);
  851. DDX_Control(pDX, IDC_EDIT_NAME_TYPE_ID, m_editId);
  852. DDX_Text(pDX, IDC_EDIT_NAME_TYPE_DESCRIPTION, m_strDescription);
  853. DDX_Text(pDX, IDC_EDIT_NAME_TYPE_ID, m_strId);
  854. //}}AFX_DATA_MAP
  855. }
  856. BEGIN_MESSAGE_MAP(CNameTypeDlg, CBaseDialog)
  857. //{{AFX_MSG_MAP(CNameTypeDlg)
  858. //}}AFX_MSG_MAP
  859. END_MESSAGE_MAP()
  860. /////////////////////////////////////////////////////////////////////////////
  861. // CNameTypeDlg message handlers
  862. BOOL CNameTypeDlg::OnInitDialog()
  863. {
  864. CBaseDialog::OnInitDialog();
  865. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  866. if (!m_fCreate)
  867. {
  868. CString strTitle;
  869. strTitle.LoadString(IDS_MODIFY_NAME_TYPE);
  870. SetWindowText(strTitle);
  871. m_editId.SetReadOnly(TRUE);
  872. CString strId;
  873. strId.Format(_T("%lx"), m_dwId);
  874. m_editId.SetWindowText(strId);
  875. }
  876. m_editId.LimitText(2);
  877. m_editDescription.LimitText(STRING_LENGTH_MAX);
  878. return TRUE; // return TRUE unless you set the focus to a control
  879. // EXCEPTION: OCX Property Pages should return FALSE
  880. }
  881. void CNameTypeDlg::OnOK()
  882. {
  883. UpdateData();
  884. TCHAR * pEnd;
  885. // convert the id
  886. m_dwId = _tcstol(m_strId, &pEnd, 16);
  887. if (*pEnd != NULL)
  888. {
  889. AfxMessageBox(IDS_ERR_INVALID_HEX_STRING);
  890. m_editId.SetSel(0, -1);
  891. m_editId.SetFocus();
  892. return;
  893. }
  894. if (m_fCreate && m_pNameTypeMap->EntryExists(m_dwId))
  895. {
  896. AfxMessageBox(IDS_ERROR_NAME_TYPE_EXISTS);
  897. m_editId.SetFocus();
  898. return;
  899. }
  900. CBaseDialog::OnOK();
  901. }
  902. /////////////////////////////////////////////////////////////////////////////
  903. // CIPAddrPage property page
  904. IMPLEMENT_DYNCREATE(CIPAddrPage, CPropertyPage)
  905. CIPAddrPage::CIPAddrPage() : CPropertyPage(CIPAddrPage::IDD)
  906. {
  907. //{{AFX_DATA_INIT(CIPAddrPage)
  908. //}}AFX_DATA_INIT
  909. }
  910. CIPAddrPage::~CIPAddrPage()
  911. {
  912. }
  913. LPCOLESTR CIPAddrPage::GetNameForApi()
  914. {
  915. return m_bFilterName == TRUE ? (LPCOLESTR)m_strName : NULL;
  916. }
  917. DWORD CIPAddrPage::GetIPMaskForFilter(UINT nMask)
  918. {
  919. return m_bFilterIpMask == TRUE ? m_dwaIPMasks[nMask] : INADDR_BROADCAST;
  920. }
  921. void CIPAddrPage::DoDataExchange(CDataExchange* pDX)
  922. {
  923. CPropertyPage::DoDataExchange(pDX);
  924. //{{AFX_DATA_MAP(CIPAddrPage)
  925. DDX_Control(pDX, IDC_CHECK_MATCHCASE, m_ckbMatchCase);
  926. DDX_Control(pDX, IDC_CHECK_IPMASK, m_ckbIPMask);
  927. DDX_Control(pDX, IDC_CHECK_NAME, m_ckbName);
  928. DDX_Control(pDX, IDC_CHECK_IPADDR, m_ckbIPAddr);
  929. DDX_Control(pDX, IDC_ENABLE_CACHING, m_btnEnableCache);
  930. DDX_Control(pDX, IDC_EDIT_NAME, m_editName);
  931. DDX_Control(pDX, IDC_IPADDRESS, m_ctrlIPAddress);
  932. DDX_Control(pDX, IDC_SUBNETMASK, m_ctrlIPMask);
  933. //}}AFX_DATA_MAP
  934. }
  935. BEGIN_MESSAGE_MAP(CIPAddrPage, CPropertyPage)
  936. //{{AFX_MSG_MAP(CIPAddrPage)
  937. ON_BN_CLICKED(IDC_CHECK_IPADDR, OnCheckIpaddr)
  938. ON_BN_CLICKED(IDC_CHECK_NAME, OnCheckName)
  939. ON_BN_CLICKED(IDC_ENABLE_CACHING, OnEnableCaching)
  940. ON_BN_CLICKED(IDC_CHECK_IPMASK, OnCheckIpmask)
  941. ON_WM_HELPINFO()
  942. //}}AFX_MSG_MAP
  943. END_MESSAGE_MAP()
  944. /////////////////////////////////////////////////////////////////////////////
  945. // CIPAddrPage message handlers
  946. void CIPAddrPage::OnOK()
  947. {
  948. DWORD dwAddress, dwMask;
  949. CString oldName;
  950. CLoadRecords *pSheet = (CLoadRecords *)GetParent();
  951. pSheet->m_nActivePage = pSheet->GetActiveIndex();
  952. pSheet->m_bEnableCache = pSheet->m_bCaching;
  953. //------------check the name field--------------
  954. m_bFilterName = (m_ckbName.GetCheck() == 1);
  955. m_bMatchCase = (m_ckbMatchCase.GetCheck() == 1);
  956. // get a hand on the original name
  957. oldName = m_strName;
  958. // get the current name
  959. m_editName.GetWindowText(m_strName);
  960. if (!m_bDirtyName && !m_bFilterName)
  961. // if we didn't filter by name before and we don't now, the name is clean
  962. m_bDirtyName = FALSE;
  963. else if (m_bDirtyName && !m_bFilterName)
  964. // if we did filter before and we don't now, the name is dirty
  965. m_bDirtyName = TRUE;
  966. else if (!m_bDirtyName && m_bFilterName)
  967. // if we didn't filter before and we do now, the name is clean
  968. m_bDirtyName = FALSE;
  969. else
  970. {
  971. // we did filter by name before, we do now
  972. // the filter might have changed
  973. LPCTSTR pOldName, pNewName;
  974. // we should mark the name "dirty" only if the old prefix is included in the new one
  975. // meaning all new names should already be loaded in the database view since
  976. // they match the old prefix
  977. for (pOldName = (LPCTSTR)oldName, pNewName = (LPCTSTR)m_strName;
  978. *pNewName != _T('\0') && *pNewName != _T('*') && *pNewName != _T('?');
  979. pOldName++, pNewName++)
  980. {
  981. if (*pOldName != *pNewName)
  982. break;
  983. }
  984. m_bDirtyName = (*pOldName != _T('\0') &&
  985. *pOldName != _T('*') &&
  986. *pOldName != _T('?'));
  987. }
  988. //------------check the IP address and mask fields--------------
  989. m_bFilterIpAddr = (m_ckbIPAddr.GetCheck() == 1);
  990. m_bFilterIpMask = (m_ckbIPMask.GetCheck() == 1);
  991. // get the current address and mask
  992. m_ctrlIPAddress.GetAddress(dwAddress);
  993. m_ctrlIPMask.GetAddress(dwMask);
  994. if (m_bDirtyAddr && m_bDirtyMask)
  995. {
  996. // we did have a mask before
  997. if (m_bFilterIpAddr && m_bFilterIpMask)
  998. {
  999. // we do have a mask now - if the new mask is less specific, => definitely dirty
  1000. m_bDirtyMask = ((dwMask|m_dwaIPMasks[0])^dwMask) != 0;
  1001. }
  1002. else
  1003. {
  1004. // we don't have a mask now => 255.255.255.255 (which is assumed) is as specific
  1005. // as possible => we do have the record we need already => definitely clean
  1006. m_bDirtyMask = FALSE;
  1007. }
  1008. }
  1009. else
  1010. {
  1011. // we didn't have a mask before => 255.255.255.255 was assumed = the most specific
  1012. if (m_bFilterIpAddr && m_bFilterIpMask)
  1013. {
  1014. // we do have a mask now
  1015. // the mask is dirty only if we actually did IP filtering before,
  1016. // otherwise, all the records are already there, regardless their IPs
  1017. m_bDirtyMask = m_bDirtyAddr && (dwMask != INADDR_BROADCAST);
  1018. }
  1019. else
  1020. {
  1021. // we don't have a mask now => nothing changed => definitely clean
  1022. m_bDirtyMask = FALSE;
  1023. }
  1024. }
  1025. if (m_bDirtyAddr)
  1026. {
  1027. // we did filter on IP address
  1028. if (m_bFilterIpAddr)
  1029. {
  1030. // we do filter on IP address now
  1031. // we need to see if the new Ip (or subnet address) has changed
  1032. //DWORD dwNewSubnet, dwOldSubnet;
  1033. //dwNewSubnet = m_bFilterIpMask ? dwAddress & dwMask : dwAddress;
  1034. //dwOldSubnet = m_bDirtyMask ? m_dwaIPAddrs[0] & m_dwaIPMasks[0] : m_dwaIPAddrs[0];
  1035. m_bDirtyAddr = (dwAddress != m_dwaIPAddrs[0]);
  1036. }
  1037. else
  1038. {
  1039. // we don't filter on IP address now => definitely dirty
  1040. m_bDirtyAddr = TRUE;
  1041. }
  1042. }
  1043. else
  1044. {
  1045. // we didn't filter on IP address originally => we have all records => definitely clean
  1046. m_bDirtyAddr = FALSE;
  1047. }
  1048. // save the current address but only if there is one! The ip ctrl could very well be empty and we
  1049. // risk to see this as 0.0.0.0 which would be wrong
  1050. m_dwaIPAddrs.RemoveAll();
  1051. if (!m_ctrlIPAddress.IsBlank())
  1052. m_dwaIPAddrs.Add(dwAddress);
  1053. // save the current mask but only if there is one! The ip ctrl could very well be empty and we
  1054. // risk to see this as 0.0.0.0 which would be wrong
  1055. m_dwaIPMasks.RemoveAll();
  1056. if (!m_ctrlIPMask.IsBlank())
  1057. m_dwaIPMasks.Add(dwMask);
  1058. CPropertyPage::OnOK();
  1059. }
  1060. BOOL CIPAddrPage::OnInitDialog()
  1061. {
  1062. CPropertyPage::OnInitDialog();
  1063. // turn on the ? in the title bar
  1064. CWnd * pWnd = GetParent();
  1065. if (pWnd)
  1066. {
  1067. CWnd * pButton = pWnd->GetDlgItem(IDOK);
  1068. if (pButton)
  1069. {
  1070. CString strText;
  1071. strText.LoadString(IDS_FIND_NOW);
  1072. pButton->SetWindowText(strText);
  1073. }
  1074. pWnd->ModifyStyleEx(0, WS_EX_CONTEXTHELP, 0);
  1075. }
  1076. SetModified();
  1077. // just save the previous "filter by name" bit
  1078. m_bDirtyName = m_bFilterName;
  1079. m_ckbName.SetCheck(m_bFilterName);
  1080. m_ckbMatchCase.SetCheck(m_bMatchCase);
  1081. m_ckbMatchCase.EnableWindow(m_bFilterName);
  1082. m_editName.SetWindowText(m_strName);
  1083. m_editName.EnableWindow(m_bFilterName);
  1084. // just save the previous "filter by ip" bit
  1085. m_bDirtyAddr = m_bFilterIpAddr;
  1086. m_ckbIPAddr.SetCheck(m_bFilterIpAddr);
  1087. if (m_dwaIPAddrs.GetSize() != 0)
  1088. m_ctrlIPAddress.SetAddress(m_dwaIPAddrs[0]);
  1089. m_ctrlIPAddress.EnableWindow(m_bFilterIpAddr);
  1090. m_ckbIPMask.EnableWindow(m_bFilterIpAddr);
  1091. // just save the previous "filter by subnet" bit
  1092. m_bDirtyMask = m_bFilterIpMask;
  1093. m_ckbIPMask.SetCheck(m_bFilterIpMask);
  1094. if (m_dwaIPMasks.GetSize() != 0)
  1095. m_ctrlIPMask.SetAddress(m_dwaIPMasks[0]);
  1096. m_ctrlIPMask.EnableWindow(m_bFilterIpAddr && m_bFilterIpMask);
  1097. return TRUE; // return TRUE unless you set the focus to a control
  1098. // EXCEPTION: OCX Property Pages should return FALSE
  1099. }
  1100. void CIPAddrPage::OnCheckIpaddr()
  1101. {
  1102. BOOL bFIpAddr = (m_ckbIPAddr.GetCheck() == 1);
  1103. BOOL bFIpMask = (m_ckbIPMask.GetCheck() == 1);
  1104. m_ctrlIPAddress.EnableWindow(bFIpAddr);
  1105. m_ckbIPMask.EnableWindow(bFIpAddr);
  1106. m_ctrlIPMask.EnableWindow(bFIpAddr && bFIpMask);
  1107. m_ctrlIPAddress.SetFieldFocus((WORD)-1);
  1108. }
  1109. void CIPAddrPage::OnCheckIpmask()
  1110. {
  1111. BOOL bFIpMask = (m_ckbIPMask.GetCheck() == 1);
  1112. m_ctrlIPMask.EnableWindow(bFIpMask);
  1113. m_ctrlIPMask.SetFieldFocus((WORD)-1);
  1114. }
  1115. void CIPAddrPage::OnCheckName()
  1116. {
  1117. TCHAR pName[3];
  1118. BOOL bFName = (m_ckbName.GetCheck() == 1);
  1119. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  1120. m_editName.EnableWindow(bFName);
  1121. m_ckbMatchCase.EnableWindow(bFName);
  1122. }
  1123. BOOL CIPAddrPage::OnKillActive()
  1124. {
  1125. BOOL bFName = (m_ckbName.GetCheck() == 1);
  1126. BOOL bFIpAddr = (m_ckbIPAddr.GetCheck() == 1);
  1127. BOOL bFIpMask = (m_ckbIPMask.GetCheck() == 1);
  1128. if (bFName && m_editName.GetWindowTextLength()==0)
  1129. {
  1130. WinsMessageBox(IDS_ERR_NO_NAME);
  1131. return FALSE;
  1132. }
  1133. if (bFIpAddr && m_ctrlIPAddress.IsBlank())
  1134. {
  1135. WinsMessageBox(IDS_ERR_NO_IPADDR);
  1136. return FALSE;
  1137. }
  1138. if (bFIpAddr && bFIpMask)
  1139. {
  1140. if (m_ctrlIPMask.IsBlank())
  1141. {
  1142. WinsMessageBox(IDS_ERR_NO_IPMASK);
  1143. return FALSE;
  1144. }
  1145. else
  1146. {
  1147. DWORD dwMask;
  1148. m_ctrlIPMask.GetAddress(dwMask);
  1149. if (dwMask != ~(((dwMask-1)|dwMask)^dwMask))
  1150. {
  1151. WinsMessageBox(IDS_ERR_INVALID_IPMASK);
  1152. return FALSE;
  1153. }
  1154. }
  1155. }
  1156. return CPropertyPage::OnKillActive();
  1157. }
  1158. BOOL CIPAddrPage::OnSetActive()
  1159. {
  1160. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  1161. m_btnEnableCache.SetCheck(pParent->m_bCaching);
  1162. return CPropertyPage::OnSetActive();
  1163. }
  1164. void CIPAddrPage::OnEnableCaching()
  1165. {
  1166. CLoadRecords *pParent = (CLoadRecords *)GetParent();
  1167. pParent->m_bCaching = (m_btnEnableCache.GetCheck() == 1);
  1168. }
  1169. BOOL CIPAddrPage::OnHelpInfo(HELPINFO* pHelpInfo)
  1170. {
  1171. int i;
  1172. DWORD dwCtrlId;
  1173. if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  1174. {
  1175. DWORD * pdwHelp = GetHelpMap();
  1176. if (pdwHelp)
  1177. {
  1178. ::WinHelp ((HWND)pHelpInfo->hItemHandle,
  1179. AfxGetApp()->m_pszHelpFilePath,
  1180. HELP_WM_HELP,
  1181. (ULONG_PTR)pdwHelp);
  1182. }
  1183. }
  1184. return TRUE;
  1185. }