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.

624 lines
15 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. edituser.h
  7. Edit user dialog implementation file
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "SrchFltr.h"
  12. #include "spdutil.h"
  13. #include "ncglobal.h" // network console global defines
  14. const DWORD c_dwOtherProtocol = 0xFFFFFFFF;
  15. const DWORD c_dwMaxProtocolID = 0xFF;
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CSearchFilters dialog
  23. CSearchFilters::CSearchFilters(ISpdInfo * pSpdInfo)
  24. : CModelessDlg()
  25. {
  26. //{{AFX_DATA_INIT(CSearchFilters)
  27. // NOTE: the ClassWizard will add member initialization here
  28. //}}AFX_DATA_INIT
  29. m_spSpdInfo.Set(pSpdInfo);
  30. }
  31. void CSearchFilters::DoDataExchange(CDataExchange* pDX)
  32. {
  33. CBaseDialog::DoDataExchange(pDX);
  34. //{{AFX_DATA_MAP(CSearchFilters)
  35. DDX_Control(pDX, IDC_SRCH_LIST, m_listResult);
  36. DDX_Control(pDX, IDC_SRCH_PROTO, m_cmbProtocol);
  37. DDX_Control(pDX, IDC_SRCH_PROTO_NUMBER, m_editProtID);
  38. DDX_Control(pDX, IDC_SRCH_PROTO_SPIN, m_spinProtID);
  39. //}}AFX_DATA_MAP
  40. }
  41. BEGIN_MESSAGE_MAP(CSearchFilters, CBaseDialog)
  42. //{{AFX_MSG_MAP(CSearchFilters)
  43. ON_BN_CLICKED(IDC_SEARCH, OnButtonSearch)
  44. ON_BN_CLICKED(IDC_SRCH_SRC_ANY, OnSrcOptionClicked)
  45. ON_BN_CLICKED(IDC_SRCH_SRC_SPEC, OnSrcOptionClicked)
  46. ON_BN_CLICKED(IDC_SRCH_DEST_ANY, OnDestOptionClicked)
  47. ON_BN_CLICKED(IDC_SRCH_DEST_SPEC, OnDestOptionClicked)
  48. ON_BN_CLICKED(IDC_SRCH_SRC_ANYPORT, OnSrcPortClicked)
  49. ON_BN_CLICKED(IDC_SRCH_SRC_SPPORT, OnSrcPortClicked)
  50. ON_BN_CLICKED(IDC_SRCH_DEST_ANYPORT, OnDestPortClicked)
  51. ON_BN_CLICKED(IDC_SRCH_DEST_SPPORT, OnDestPortClicked)
  52. ON_CBN_SELENDOK(IDC_SRCH_PROTO, OnSelEndOkCbprotocoltype)
  53. ON_EN_CHANGE(IDC_SRCH_PROTO_NUMBER, OnEnChangeProtocolID)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. //To manually create the IP control and disable mirroring if the parent dialog is mirrored
  57. //
  58. //Arguments:
  59. // uID [IN] the control that the new IP control should overwrite
  60. // uIDIpCtr [IN] the ID of the IP control to create
  61. //
  62. //Note: $REVIEW (nsun) this should be removed after the snapin is themed since IP controls
  63. // in comctl v6 will handle the mirroring by itself
  64. //
  65. HWND CSearchFilters::CreateIPControl(UINT uID, UINT uIDIpCtl)
  66. {
  67. HWND hwndIPControl = NULL;
  68. RECT rcClient; // client area of parent window
  69. CWnd* pWnd = GetDlgItem(uID);
  70. if (pWnd)
  71. {
  72. // get pos info from our template static and then make sure it is hidden
  73. pWnd->GetWindowRect(&rcClient);
  74. pWnd->ShowWindow (SW_HIDE);
  75. ScreenToClient (&rcClient);
  76. //$REVIEW WS_EX_NOINHERITLAYOUT is to fix the mirroring problem of IP control
  77. //See WinXP bug 261926. We should remove that we switch the comctl32 v6
  78. LONG lExStyles = 0;
  79. LONG lExStyles0 = 0;
  80. if (m_hWnd)
  81. {
  82. lExStyles0 = lExStyles = GetWindowLong(m_hWnd, GWL_EXSTYLE);
  83. if (lExStyles & WS_EX_LAYOUTRTL)
  84. {
  85. lExStyles |= WS_EX_NOINHERITLAYOUT;
  86. SetWindowLong(m_hWnd, GWL_EXSTYLE, lExStyles);
  87. }
  88. }
  89. // create the new edit control
  90. hwndIPControl = ::CreateWindowEx(WS_EX_NOINHERITLAYOUT, WC_IPADDRESS, NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
  91. rcClient.left,
  92. rcClient.top,
  93. rcClient.right - rcClient.left,
  94. rcClient.bottom - rcClient.top,
  95. GetSafeHwnd(),
  96. (HMENU) IntToPtr(uIDIpCtl),
  97. AfxGetInstanceHandle (), //g_hinst,
  98. NULL);
  99. if (lExStyles0 != lExStyles && m_hWnd)
  100. {
  101. SetWindowLong(m_hWnd, GWL_EXSTYLE, lExStyles0);
  102. }
  103. // move the control directly behind the pWnd in the Z order
  104. if (hwndIPControl)
  105. {
  106. ::SetWindowPos (hwndIPControl, pWnd->GetSafeHwnd(), 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  107. }
  108. }
  109. return hwndIPControl;
  110. }
  111. /////////////////////////////////////////////////////////////////////////////
  112. // CSearchFilters message handlers
  113. BOOL CSearchFilters::OnInitDialog()
  114. {
  115. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  116. HWND hwndIPControl = CreateIPControl(IDC_SRCH_SRC_IP_TEXT, IDC_SRCH_SRC_IP);
  117. m_ipSrc.Create(hwndIPControl);
  118. hwndIPControl = CreateIPControl(IDC_SRCH_DEST_IP_TEXT, IDC_SRCH_DEST_IP);
  119. m_ipDest.Create(hwndIPControl);
  120. m_ipSrc.SetFieldRange(0, 1, 223);
  121. m_ipDest.SetFieldRange(0, 1, 223);
  122. CBaseDialog::OnInitDialog();
  123. CString st;
  124. CheckDlgButton(IDC_SRCH_SRC_ANY, BST_CHECKED);
  125. OnSrcOptionClicked();
  126. CheckDlgButton(IDC_SRCH_DEST_ANY, BST_CHECKED);
  127. OnDestOptionClicked();
  128. int nIndex;
  129. for (int i = 0; i < c_nProtocols; i++)
  130. {
  131. st.LoadString(c_ProtocolStringMap[i].nStringID);
  132. nIndex = m_cmbProtocol.AddString(st);
  133. Assert(CB_ERR != nIndex);
  134. if (CB_ERR != nIndex)
  135. m_cmbProtocol.SetItemData(nIndex, c_ProtocolStringMap[i].dwProtocol);
  136. }
  137. //Add the other protocol selection
  138. st.LoadString(IDS_OTHER);
  139. nIndex = m_cmbProtocol.AddString(st);
  140. m_cmbProtocol.SetItemData(nIndex, c_dwOtherProtocol);
  141. m_cmbProtocol.SetCurSel(0);
  142. CheckDlgButton(IDC_SRCH_INBOUND, BST_CHECKED);
  143. CheckDlgButton(IDC_SRCH_OUTBOUND, BST_CHECKED);
  144. CheckDlgButton(IDC_SRCH_RADIO_BEST, BST_CHECKED);
  145. int nWidth;
  146. nWidth = m_listResult.GetStringWidth(_T("555.555.555.555 - "));
  147. st.LoadString(IDS_COL_FLTR_SRC);
  148. m_listResult.InsertColumn(0, st, LVCFMT_LEFT, nWidth);
  149. nWidth = m_listResult.GetStringWidth(_T("555.555.555.555 - "));
  150. st.LoadString(IDS_COL_FLTR_DEST);
  151. m_listResult.InsertColumn(1, st, LVCFMT_LEFT, nWidth);
  152. st.LoadString(IDS_COL_FLTR_SRC_PORT);
  153. nWidth = m_listResult.GetStringWidth((LPCTSTR)st) + 15;
  154. m_listResult.InsertColumn(2, st, LVCFMT_LEFT, nWidth);
  155. st.LoadString(IDS_COL_FLTR_DEST_PORT);
  156. nWidth = m_listResult.GetStringWidth((LPCTSTR)st) + 15;
  157. m_listResult.InsertColumn(3, st, LVCFMT_LEFT, nWidth);
  158. st.LoadString(IDS_COL_FLTR_PROT);
  159. nWidth = m_listResult.GetStringWidth((LPCTSTR)st) + 15;
  160. m_listResult.InsertColumn(4, st, LVCFMT_LEFT, nWidth);
  161. st.LoadString(IDS_FLTR_DIR_OUT);
  162. nWidth = m_listResult.GetStringWidth((LPCTSTR)st) + 20;
  163. st.LoadString(IDS_FILTER_PP_COL_DIRECTION);
  164. m_listResult.InsertColumn(5, st, LVCFMT_LEFT, nWidth);
  165. st.LoadString(IDS_FILTER_PP_COL_FLAG);
  166. nWidth = m_listResult.GetStringWidth(st) + 40;
  167. st.LoadString(IDS_FILTER_PP_COL_FLAG);
  168. m_listResult.InsertColumn(6, st, LVCFMT_LEFT, nWidth);
  169. st.LoadString(IDS_FILTER_PP_COL_WEIGHT);
  170. nWidth = m_listResult.GetStringWidth((LPCTSTR)st) + 20;
  171. m_listResult.InsertColumn(7, st, LVCFMT_LEFT, nWidth);
  172. st.LoadString(IDS_FILTER_PP_COL_POLICY);
  173. nWidth = m_listResult.GetStringWidth((LPCTSTR)st) + 20;
  174. m_listResult.InsertColumn(8, st, LVCFMT_LEFT, nWidth);
  175. st.Format(_T("%u"), c_dwMaxProtocolID);
  176. m_editProtID.SetLimitText(st.GetLength());
  177. m_spinProtID.SetRange(0, c_dwMaxProtocolID);
  178. EnableControls();
  179. return TRUE; // return TRUE unless you set the focus to a control
  180. // EXCEPTION: OCX Property Pages should return FALSE
  181. }
  182. void CSearchFilters::EnableControls()
  183. {
  184. CWnd * pWndSrcPort = NULL;
  185. CWnd * pWndDestPort = NULL;
  186. CWnd * pWnd = NULL;
  187. int nIndex;
  188. DWORD dwData;
  189. nIndex = m_cmbProtocol.GetCurSel();
  190. dwData = (DWORD)m_cmbProtocol.GetItemData(nIndex);
  191. pWnd = GetDlgItem(IDC_SRCH_PROTO_NUMBER);
  192. if (pWnd)
  193. pWnd->EnableWindow(c_dwOtherProtocol == dwData);
  194. if (c_dwOtherProtocol == dwData)
  195. {
  196. dwData = GetDlgItemInt(IDC_SRCH_PROTO_NUMBER);
  197. }
  198. else
  199. {
  200. CString st;
  201. st.Format(_T("%u"), dwData);
  202. m_editProtID.SetWindowText(st);
  203. }
  204. //Enable the port selection only when the protocol is TCP or UDP
  205. BOOL fEnable = IPSM_PROTOCOL_TCP == dwData || IPSM_PROTOCOL_UDP == dwData;
  206. pWndSrcPort = GetDlgItem(IDC_SRCH_SRC_PORT);
  207. pWndDestPort = GetDlgItem(IDC_SRCH_DEST_PORT);
  208. SafeEnableWindow(IDC_SRCH_SRC_ANYPORT, fEnable);
  209. SafeEnableWindow(IDC_SRCH_SRC_SPPORT, fEnable);
  210. SafeEnableWindow(IDC_SRCH_DEST_ANYPORT, fEnable);
  211. SafeEnableWindow(IDC_SRCH_DEST_SPPORT, fEnable);
  212. if (!fEnable)
  213. {
  214. //if port option doesn't apply to the seclect protocol, unselect all port
  215. //settings
  216. CheckDlgButton(IDC_SRCH_SRC_ANYPORT, 0);
  217. CheckDlgButton(IDC_SRCH_SRC_SPPORT, 0);
  218. CheckDlgButton(IDC_SRCH_DEST_ANYPORT, 0);
  219. CheckDlgButton(IDC_SRCH_DEST_SPPORT, 0);
  220. }
  221. else
  222. {
  223. //if neither any nor specific port is selected, select the "any ports"
  224. if (!IsDlgButtonChecked(IDC_SRCH_SRC_ANYPORT) &&
  225. !IsDlgButtonChecked(IDC_SRCH_SRC_SPPORT))
  226. {
  227. CheckDlgButton(IDC_SRCH_SRC_ANYPORT, 1);
  228. }
  229. if (!IsDlgButtonChecked(IDC_SRCH_DEST_ANYPORT) &&
  230. !IsDlgButtonChecked(IDC_SRCH_DEST_SPPORT))
  231. {
  232. CheckDlgButton(IDC_SRCH_DEST_ANYPORT, 1);
  233. }
  234. }
  235. BOOL fSpSrcPort = fEnable && IsDlgButtonChecked(IDC_SRCH_SRC_SPPORT);
  236. BOOL fSpDestPort = fEnable && IsDlgButtonChecked(IDC_SRCH_DEST_SPPORT);
  237. if (pWndSrcPort)
  238. {
  239. pWndSrcPort->EnableWindow(fSpSrcPort);
  240. if (!fSpSrcPort)
  241. pWndSrcPort->SetWindowText(_T(""));
  242. }
  243. if (pWndDestPort)
  244. {
  245. pWndDestPort->EnableWindow(fSpDestPort);
  246. if (!fSpDestPort)
  247. pWndDestPort->SetWindowText(_T(""));
  248. }
  249. }
  250. void CSearchFilters::SafeEnableWindow(int nId, BOOL fEnable)
  251. {
  252. CWnd * pWnd = GetDlgItem(nId);
  253. if (pWnd)
  254. {
  255. pWnd->EnableWindow(fEnable);
  256. }
  257. }
  258. void CSearchFilters::OnButtonSearch()
  259. {
  260. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  261. CFilterInfo fltr;
  262. CFilterInfoArray arrMatchFltrs;
  263. if (!LoadConditionInfoFromControls(&fltr))
  264. {
  265. return;
  266. }
  267. DWORD dwNum = 1000; //TODO, should change to 0 to mean search all matches
  268. if(IsDlgButtonChecked(IDC_SRCH_RADIO_BEST))
  269. {
  270. dwNum = 1;
  271. }
  272. m_spSpdInfo->GetMatchFilters(&fltr, dwNum, &arrMatchFltrs);
  273. PopulateFilterListToControl(&arrMatchFltrs);
  274. FreeItemsAndEmptyArray(arrMatchFltrs);
  275. }
  276. BOOL CSearchFilters::LoadConditionInfoFromControls(CFilterInfo * pFltr)
  277. {
  278. CString st;
  279. if (IsDlgButtonChecked(IDC_SRCH_SRC_ANY))
  280. {
  281. pFltr->m_SrcAddr.AddrType = IP_ADDR_SUBNET;
  282. pFltr->m_SrcAddr.uIpAddr = 0;
  283. pFltr->m_SrcAddr.uSubNetMask = 0;
  284. }
  285. else
  286. {
  287. USES_CONVERSION;
  288. pFltr->m_SrcAddr.AddrType = IP_ADDR_UNIQUE;
  289. m_ipSrc.GetAddress(st);
  290. pFltr->m_SrcAddr.uIpAddr = inet_addr(T2A((LPCTSTR)st));
  291. pFltr->m_SrcAddr.uSubNetMask = 0xFFFFFFFF;
  292. }
  293. if (IsDlgButtonChecked(IDC_SRCH_DEST_ANY))
  294. {
  295. pFltr->m_DesAddr.AddrType = IP_ADDR_SUBNET;
  296. pFltr->m_DesAddr.uIpAddr = 0;
  297. pFltr->m_DesAddr.uSubNetMask = 0;
  298. }
  299. else
  300. {
  301. USES_CONVERSION;
  302. pFltr->m_DesAddr.AddrType = IP_ADDR_UNIQUE;
  303. m_ipDest.GetAddress(st);
  304. pFltr->m_DesAddr.uIpAddr = inet_addr(T2A((LPCTSTR)st));
  305. pFltr->m_DesAddr.uSubNetMask = 0xFFFFFFFF;
  306. }
  307. //Protocol and Port conditions
  308. int nIndex = m_cmbProtocol.GetCurSel();
  309. DWORD dwData = (DWORD)m_cmbProtocol.GetItemData(nIndex);
  310. if (c_dwOtherProtocol == dwData)
  311. {
  312. dwData = GetDlgItemInt(IDC_SRCH_PROTO_NUMBER);
  313. }
  314. if (dwData > c_dwMaxProtocolID)
  315. {
  316. st.Format(IDS_ERR_INVALID_PROTOCOLID, c_dwMaxProtocolID);
  317. ::AfxMessageBox(st);
  318. return FALSE;
  319. }
  320. pFltr->m_Protocol.ProtocolType = PROTOCOL_UNIQUE;
  321. pFltr->m_Protocol.dwProtocol = (DWORD)dwData;
  322. pFltr->m_SrcPort.PortType = PORT_UNIQUE;
  323. pFltr->m_DesPort.PortType = PORT_UNIQUE;
  324. pFltr->m_SrcPort.wPort = 0;
  325. pFltr->m_DesPort.wPort = 0;
  326. if (IPSM_PROTOCOL_TCP == dwData || IPSM_PROTOCOL_UDP == dwData)
  327. {
  328. BOOL fTrans = FALSE;
  329. if (IsDlgButtonChecked(IDC_SRCH_SRC_ANYPORT))
  330. {
  331. pFltr->m_SrcPort.wPort = 0;
  332. }
  333. else
  334. {
  335. pFltr->m_SrcPort.wPort = (WORD)GetDlgItemInt(IDC_SRCH_SRC_PORT, &fTrans, FALSE);
  336. if (!fTrans || 0 == pFltr->m_SrcPort.wPort)
  337. {
  338. ::AfxMessageBox(IDS_ERR_INVALID_SRC_PORT);
  339. return FALSE;
  340. }
  341. }
  342. if (IsDlgButtonChecked(IDC_SRCH_DEST_ANYPORT))
  343. {
  344. pFltr->m_DesPort.wPort = 0;
  345. }
  346. else
  347. {
  348. pFltr->m_DesPort.wPort = (WORD)GetDlgItemInt(IDC_SRCH_DEST_PORT, &fTrans, FALSE);
  349. if (!fTrans || 0 == pFltr->m_DesPort.wPort)
  350. {
  351. ::AfxMessageBox(IDS_ERR_INVALID_DEST_PORT);
  352. return FALSE;
  353. }
  354. }
  355. }
  356. if (IsDlgButtonChecked(IDC_SRCH_INBOUND))
  357. {
  358. //if both inbound and outbound are chosen, then
  359. //set the driection valude as 0
  360. if (IsDlgButtonChecked(IDC_SRCH_OUTBOUND))
  361. {
  362. pFltr->m_dwDirection = 0;
  363. }
  364. else
  365. {
  366. pFltr->m_dwDirection = FILTER_DIRECTION_INBOUND;
  367. }
  368. }
  369. else if (IsDlgButtonChecked(IDC_SRCH_OUTBOUND))
  370. {
  371. pFltr->m_dwDirection = FILTER_DIRECTION_OUTBOUND;
  372. }
  373. else
  374. {
  375. ::AfxMessageBox(IDS_ERR_NO_DIRECTION);
  376. return FALSE;
  377. }
  378. return TRUE;
  379. }
  380. void CSearchFilters::PopulateFilterListToControl(CFilterInfoArray * parrFltrs)
  381. {
  382. CString st;
  383. m_listResult.DeleteAllItems();
  384. int nRows = -1;
  385. int nCol = 0;
  386. for (int i = 0; i < parrFltrs->GetSize(); i++)
  387. {
  388. nRows++;
  389. nRows = m_listResult.InsertItem(nRows, _T(""));
  390. if (-1 != nRows)
  391. {
  392. AddressToString((*parrFltrs)[i]->m_SrcAddr, &st);
  393. m_listResult.SetItemText(nRows, 0, st);
  394. AddressToString((*parrFltrs)[i]->m_DesAddr, &st);
  395. m_listResult.SetItemText(nRows, 1, st);
  396. PortToString((*parrFltrs)[i]->m_SrcPort, &st);
  397. m_listResult.SetItemText(nRows, 2, st);
  398. PortToString((*parrFltrs)[i]->m_DesPort, &st);
  399. m_listResult.SetItemText(nRows, 3, st);
  400. ProtocolToString((*parrFltrs)[i]->m_Protocol, &st);
  401. m_listResult.SetItemText(nRows, 4, st);
  402. DirectionToString((*parrFltrs)[i]->m_dwDirection, &st);
  403. m_listResult.SetItemText(nRows, 5, st);
  404. FilterFlagToString((FILTER_DIRECTION_INBOUND == (*parrFltrs)[i]->m_dwDirection) ?
  405. (*parrFltrs)[i]->m_InboundFilterFlag :
  406. (*parrFltrs)[i]->m_OutboundFilterFlag,
  407. &st
  408. );
  409. m_listResult.SetItemText(nRows, 6, st);
  410. st.Format(_T("%d"), (*parrFltrs)[i]->m_dwWeight);
  411. m_listResult.SetItemText(nRows, 7, st);
  412. st = (*parrFltrs)[i]->m_stPolicyName;
  413. m_listResult.SetItemText(nRows, 8, st);
  414. m_listResult.SetItemData(nRows, i);
  415. }
  416. }
  417. }
  418. void CSearchFilters::OnSrcOptionClicked()
  419. {
  420. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  421. BOOL fAny = IsDlgButtonChecked(IDC_SRCH_SRC_ANY);
  422. if (fAny)
  423. {
  424. m_ipSrc.ClearAddress();
  425. }
  426. if (m_ipSrc.m_hIPaddr)
  427. {
  428. ::EnableWindow(m_ipSrc.m_hIPaddr, !fAny);
  429. }
  430. }
  431. void CSearchFilters::OnDestOptionClicked()
  432. {
  433. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  434. BOOL fAny = IsDlgButtonChecked(IDC_SRCH_DEST_ANY);
  435. if (fAny)
  436. {
  437. m_ipDest.ClearAddress();
  438. }
  439. if (m_ipDest.m_hIPaddr)
  440. {
  441. ::EnableWindow(m_ipDest.m_hIPaddr, !fAny);
  442. }
  443. }
  444. void CSearchFilters::OnSrcPortClicked()
  445. {
  446. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  447. BOOL fSpecifc = IsDlgButtonChecked(IDC_SRCH_SRC_SPPORT);
  448. SafeEnableWindow(IDC_SRCH_SRC_PORT, fSpecifc);
  449. if (!fSpecifc)
  450. {
  451. CWnd * pWnd = GetDlgItem(IDC_SRCH_SRC_PORT);
  452. if (pWnd)
  453. pWnd->SetWindowText(_T(""));
  454. }
  455. }
  456. void CSearchFilters::OnDestPortClicked()
  457. {
  458. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  459. BOOL fSpecifc = IsDlgButtonChecked(IDC_SRCH_DEST_SPPORT);
  460. SafeEnableWindow(IDC_SRCH_DEST_PORT, fSpecifc);
  461. if (!fSpecifc)
  462. {
  463. CWnd * pWnd = GetDlgItem(IDC_SRCH_DEST_PORT);
  464. if (pWnd)
  465. pWnd->SetWindowText(_T(""));
  466. }
  467. }
  468. void CSearchFilters::OnOK()
  469. {
  470. }
  471. void CSearchFilters::OnCancel()
  472. {
  473. DestroyWindow();
  474. // Explicitly kill this thread.
  475. AfxPostQuitMessage(0);
  476. }
  477. void CSearchFilters::OnSelEndOkCbprotocoltype()
  478. {
  479. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  480. EnableControls();
  481. }
  482. void CSearchFilters::OnEnChangeProtocolID()
  483. {
  484. CWnd * pWnd = NULL;
  485. pWnd = GetDlgItem(IDC_SRCH_PROTO_NUMBER);
  486. //only update control state when the edit box is enabled
  487. //otherwise, there will be a infinite recursive call to OnEnChangeProtocolID()
  488. //because EnableControls will update the text of the edit box if the protocol
  489. //is not "Other" (at that time, the edit box is disabled
  490. if (pWnd && pWnd->IsWindowEnabled())
  491. {
  492. EnableControls();
  493. }
  494. }