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.

1218 lines
35 KiB

  1. //-----------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: A D V D L G . C P P
  7. //
  8. // Contents: PVC advanced property pages message handler implementation
  9. //
  10. // Notes:
  11. //
  12. // Author: tongl 1 Mar, 1998
  13. //
  14. //-----------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include "auniobj.h"
  18. #include "atmutil.h"
  19. #include "aunidlg.h"
  20. //#include "atmcommon.h"
  21. #include "ncatlui.h"
  22. #include "ncstl.h"
  23. #include "ncui.h"
  24. const int MAX_FIELD_LENGTH = 3;
  25. const DWORD c_dwUserSpecProtocol = 16;
  26. const WCHAR c_szUserSpecProtocol[] = L"16";
  27. const DWORD c_dwUserSpecHighLayer = 1;
  28. const WCHAR c_szUserSpecHighLayer[] = L"1";
  29. const DWORD c_dwFieldHigh = 255;
  30. const DWORD c_dwFieldLow = 0;
  31. enum Location
  32. {
  33. LOCAL,
  34. DEST
  35. };
  36. void InitBroadbandInfo(HWND hDlg);
  37. void SetBroadbandInfo(HWND hDlg, CPvcInfo * pPvcInfo, Location location);
  38. void SetProtocolInfo(HWND hDlg, int nIDDlgItemCombo, int nIDDlgItemEdit,
  39. DWORD dwProtocol, DWORD dwUserSpecValue);
  40. void SetHighLayerInfo(HWND hDlg, DWORD dwHighLayerInfoType,
  41. tstring & strHighLayerInfo);
  42. void GetBroadbandInfo(HWND hDlg, CPvcInfo * pPvcInfo, Location location);
  43. void GetProtocolInfo(HWND hDlg, int nIDDlgItemCombo, int nIDDlgItemEdit,
  44. DWORD * pdwProtocol, DWORD * pdwUserSpecValue);
  45. void GetHighLayerInfo(HWND hDlg, DWORD * pdwHighLayerInfoType,
  46. tstring * pstrHighLayerInfo);
  47. void OnLayer2EdtChange(HWND hDlg);
  48. void OnLayer2SelChange(HWND hDlg);
  49. void OnLayer3EdtChange(HWND hDlg);
  50. void OnLayer3SelChange(HWND hDlg);
  51. void OnHighLayerEdtChange(HWND hDlg);
  52. void OnHighLayerSelChange(HWND hDlg);
  53. void GetNumFromString(PWSTR pszBuf, DWORD * dwNum);
  54. BOOL InvalidBroadbandInfo(HWND hDlg);
  55. BOOL IsValidCmbSelection(HWND hDlg, int nIDDlgItemCombo);
  56. BOOL IsValidDwordField(HWND hDlg, int nIDDlgItemEdit);
  57. BOOL IsValidBinaryField(HWND hDlg, int nIDDlgItemEdit, int nMaxBytes);
  58. //
  59. // CPvcLocalPage
  60. //
  61. // Constructors/Destructors
  62. CPvcLocalPage::CPvcLocalPage(CPVCMainDialog * pParentDlg,
  63. CPvcInfo * pPvcInfo, const DWORD * adwHelpIDs)
  64. {
  65. Assert(pPvcInfo);
  66. Assert(pParentDlg);
  67. m_pParentDlg = pParentDlg;
  68. m_pPvcInfo = pPvcInfo;
  69. m_adwHelpIDs = adwHelpIDs;
  70. }
  71. CPvcLocalPage::~CPvcLocalPage()
  72. {
  73. }
  74. // Command handlers
  75. LRESULT CPvcLocalPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  76. {
  77. // Add strings to the combo boxes
  78. InitBroadbandInfo(m_hWnd);
  79. // Now set the value based on what's in our data structure
  80. SetBroadbandInfo(m_hWnd, m_pPvcInfo, LOCAL);
  81. return 0;
  82. }
  83. LRESULT CPvcLocalPage::OnContextMenu(UINT uMsg, WPARAM wParam,
  84. LPARAM lParam, BOOL& fHandled)
  85. {
  86. ShowContextHelp(m_hWnd, HELP_CONTEXTMENU, m_adwHelpIDs);
  87. return 0;
  88. }
  89. LRESULT CPvcLocalPage::OnHelp(UINT uMsg, WPARAM wParam,
  90. LPARAM lParam, BOOL& fHandled)
  91. {
  92. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  93. Assert(lphi);
  94. if (HELPINFO_WINDOW == lphi->iContextType)
  95. {
  96. ShowContextHelp(static_cast<HWND>(lphi->hItemHandle), HELP_WM_HELP,
  97. m_adwHelpIDs);
  98. }
  99. return 0;
  100. }
  101. // notify handlers for the property page
  102. LRESULT CPvcLocalPage::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  103. {
  104. m_pParentDlg->m_fPropShtOk = TRUE;
  105. GetBroadbandInfo(m_hWnd, m_pPvcInfo, LOCAL);
  106. // did any field change ?
  107. if ((m_pPvcInfo->m_dwLocalLayer2Protocol != m_pPvcInfo->m_dwOldLocalLayer2Protocol) ||
  108. (m_pPvcInfo->m_dwLocalUserSpecLayer2 != m_pPvcInfo->m_dwOldLocalUserSpecLayer2) ||
  109. (m_pPvcInfo->m_dwLocalLayer3Protocol != m_pPvcInfo->m_dwOldLocalLayer3Protocol) ||
  110. (m_pPvcInfo->m_dwLocalUserSpecLayer3 != m_pPvcInfo->m_dwOldLocalUserSpecLayer3) ||
  111. (m_pPvcInfo->m_dwLocalLayer3IPI != m_pPvcInfo->m_dwOldLocalLayer3IPI) ||
  112. (m_pPvcInfo->m_strLocalSnapId != m_pPvcInfo->m_strOldLocalSnapId) ||
  113. (m_pPvcInfo->m_dwLocalHighLayerInfoType != m_pPvcInfo->m_dwOldLocalHighLayerInfoType) ||
  114. (m_pPvcInfo->m_strLocalHighLayerInfo != m_pPvcInfo->m_strOldLocalHighLayerInfo)
  115. )
  116. {
  117. m_pParentDlg->m_fPropShtModified = TRUE;
  118. }
  119. return 0;
  120. }
  121. LRESULT CPvcLocalPage::OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  122. {
  123. // check that all values are valid
  124. BOOL err = InvalidBroadbandInfo(m_hWnd);
  125. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, err);
  126. return err;
  127. }
  128. LRESULT CPvcLocalPage::OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  129. {
  130. return 0;
  131. }
  132. LRESULT CPvcLocalPage::OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  133. {
  134. return 0;
  135. }
  136. LRESULT CPvcLocalPage::OnLayer2(WORD wNotifyCode, WORD wID,
  137. HWND hWndCtl, BOOL& fHandled)
  138. {
  139. switch(wNotifyCode)
  140. {
  141. case CBN_EDITCHANGE:
  142. OnLayer2EdtChange(m_hWnd);
  143. break;
  144. case CBN_SELCHANGE:
  145. OnLayer2SelChange(m_hWnd);
  146. break;
  147. default:
  148. break;
  149. }
  150. return 0;
  151. }
  152. LRESULT CPvcLocalPage::OnLayer3(WORD wNotifyCode, WORD wID,
  153. HWND hWndCtl, BOOL& fHandled)
  154. {
  155. switch(wNotifyCode)
  156. {
  157. case CBN_EDITCHANGE:
  158. OnLayer3EdtChange(m_hWnd);
  159. break;
  160. case CBN_SELCHANGE:
  161. OnLayer3SelChange(m_hWnd);
  162. break;
  163. default:
  164. break;
  165. }
  166. return 0;
  167. }
  168. LRESULT CPvcLocalPage::OnHighLayer(WORD wNotifyCode, WORD wID,
  169. HWND hWndCtl, BOOL& fHandled)
  170. {
  171. switch(wNotifyCode)
  172. {
  173. case CBN_EDITCHANGE:
  174. OnHighLayerEdtChange(m_hWnd);
  175. break;
  176. case CBN_SELCHANGE:
  177. OnHighLayerSelChange(m_hWnd);
  178. break;
  179. default:
  180. break;
  181. }
  182. return 0;
  183. }
  184. //
  185. // CPvcDestPage
  186. //
  187. // Constructors/Destructors
  188. CPvcDestPage::CPvcDestPage(CPVCMainDialog * pParentDlg,
  189. CPvcInfo * pPvcInfo, const DWORD * adwHelpIDs)
  190. {
  191. Assert(pPvcInfo);
  192. Assert(pParentDlg);
  193. m_pParentDlg = pParentDlg;
  194. m_pPvcInfo = pPvcInfo;
  195. m_adwHelpIDs = adwHelpIDs;
  196. }
  197. CPvcDestPage::~CPvcDestPage()
  198. {
  199. }
  200. // Command handlers
  201. LRESULT CPvcDestPage::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  202. {
  203. // Add strings to the combo boxes
  204. InitBroadbandInfo(m_hWnd);
  205. // Now set the value based on what's in our data structure
  206. SetBroadbandInfo(m_hWnd, m_pPvcInfo, DEST);
  207. return 0;
  208. }
  209. LRESULT CPvcDestPage::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled)
  210. {
  211. ShowContextHelp(m_hWnd, HELP_CONTEXTMENU, m_adwHelpIDs);
  212. return 0;
  213. }
  214. LRESULT CPvcDestPage::OnHelp(UINT uMsg, WPARAM wParam,
  215. LPARAM lParam, BOOL& fHandled)
  216. {
  217. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  218. Assert(lphi);
  219. if (HELPINFO_WINDOW == lphi->iContextType)
  220. {
  221. ShowContextHelp(static_cast<HWND>(lphi->hItemHandle), HELP_WM_HELP,
  222. m_adwHelpIDs);
  223. }
  224. return 0;
  225. }
  226. // notify handlers for the property page
  227. LRESULT CPvcDestPage::OnApply(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  228. {
  229. m_pParentDlg->m_fPropShtOk = TRUE;
  230. GetBroadbandInfo(m_hWnd, m_pPvcInfo, DEST);
  231. // did any field change ?
  232. if ((m_pPvcInfo->m_dwDestnLayer2Protocol != m_pPvcInfo->m_dwOldDestnLayer2Protocol) ||
  233. (m_pPvcInfo->m_dwDestnUserSpecLayer2 != m_pPvcInfo->m_dwOldDestnUserSpecLayer2) ||
  234. (m_pPvcInfo->m_dwDestnLayer3Protocol != m_pPvcInfo->m_dwOldDestnLayer3Protocol) ||
  235. (m_pPvcInfo->m_dwDestnUserSpecLayer3 != m_pPvcInfo->m_dwOldDestnUserSpecLayer3) ||
  236. (m_pPvcInfo->m_dwDestnLayer3IPI != m_pPvcInfo->m_dwOldDestnLayer3IPI) ||
  237. (m_pPvcInfo->m_strDestnSnapId != m_pPvcInfo->m_strOldDestnSnapId) ||
  238. (m_pPvcInfo->m_dwDestnHighLayerInfoType != m_pPvcInfo->m_dwOldDestnHighLayerInfoType) ||
  239. (m_pPvcInfo->m_strDestnHighLayerInfo != m_pPvcInfo->m_strOldDestnHighLayerInfo)
  240. )
  241. {
  242. m_pParentDlg->m_fPropShtModified = TRUE;
  243. }
  244. return 0;
  245. }
  246. LRESULT CPvcDestPage::OnKillActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  247. {
  248. // check that all values are valid
  249. BOOL err = InvalidBroadbandInfo(m_hWnd);
  250. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, err);
  251. return err;
  252. }
  253. LRESULT CPvcDestPage::OnActive(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  254. {
  255. return 0;
  256. }
  257. LRESULT CPvcDestPage::OnCancel(int idCtrl, LPNMHDR pnmh, BOOL& fHandled)
  258. {
  259. return 0;
  260. }
  261. // Control notification handlers
  262. LRESULT CPvcDestPage::OnLayer2(WORD wNotifyCode, WORD wID,
  263. HWND hWndCtl, BOOL& fHandled)
  264. {
  265. switch(wNotifyCode)
  266. {
  267. case CBN_EDITCHANGE:
  268. OnLayer2EdtChange(m_hWnd);
  269. break;
  270. case CBN_SELCHANGE:
  271. OnLayer2SelChange(m_hWnd);
  272. break;
  273. default:
  274. break;
  275. }
  276. return 0;
  277. }
  278. LRESULT CPvcDestPage::OnLayer3(WORD wNotifyCode, WORD wID,
  279. HWND hWndCtl, BOOL& fHandled)
  280. {
  281. switch(wNotifyCode)
  282. {
  283. case CBN_EDITCHANGE:
  284. OnLayer3EdtChange(m_hWnd);
  285. break;
  286. case CBN_SELCHANGE:
  287. OnLayer3SelChange(m_hWnd);
  288. break;
  289. default:
  290. break;
  291. }
  292. return 0;
  293. }
  294. LRESULT CPvcDestPage::OnHighLayer(WORD wNotifyCode, WORD wID,
  295. HWND hWndCtl, BOOL& fHandled)
  296. {
  297. switch(wNotifyCode)
  298. {
  299. case CBN_EDITCHANGE:
  300. OnHighLayerEdtChange(m_hWnd);
  301. break;
  302. case CBN_SELCHANGE:
  303. OnHighLayerSelChange(m_hWnd);
  304. break;
  305. default:
  306. break;
  307. }
  308. return 0;
  309. }
  310. //+---------------------------------------------------------------------------
  311. //
  312. // Member: AtmEditSubclassProc
  313. //
  314. // Purpose: Subclass proc for hex number edit controls. The
  315. // subclassing forces only correct input
  316. //
  317. // Author: [from scottbri 28-Apr-1997]
  318. //
  319. STDAPI AtmEditSubclassProc( HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
  320. {
  321. WNDPROC pAtmEditProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  322. if ((wMsg == WM_CHAR) &&
  323. !(((WCHAR)wParam >= L'0' && (WCHAR)wParam <= L'9') ||
  324. ((WCHAR)wParam >= L'a' && (WCHAR)wParam <= L'f') ||
  325. ((WCHAR)wParam >= L'A' && (WCHAR)wParam <= L'F') ||
  326. ((WCHAR)wParam == VK_BACK)))
  327. {
  328. MessageBeep(MB_ICONEXCLAMATION);
  329. return 0L;
  330. }
  331. return (HRESULT)CallWindowProc( pAtmEditProc, hwnd, wMsg, wParam, lParam );
  332. }
  333. //
  334. // Common utility functions shared by both local and destination dialogs
  335. //
  336. void InitBroadbandInfo(HWND hDlg)
  337. {
  338. HWND hwndTmp;
  339. // layer2 protocol: IDC_CMB_PVC_Layer2
  340. static const int nrgLayer2Ids[] = { IDS_PVC_Any,
  341. IDS_PVC_Absent,
  342. IDS_PVC_Layer2_1,
  343. IDS_PVC_Layer2_2,
  344. IDS_PVC_Layer2_6,
  345. IDS_PVC_Layer2_7,
  346. IDS_PVC_Layer2_8,
  347. IDS_PVC_Layer2_9,
  348. IDS_PVC_Layer2_10,
  349. IDS_PVC_Layer2_11,
  350. IDS_PVC_Layer2_12,
  351. IDS_PVC_Layer2_13,
  352. IDS_PVC_Layer2_14,
  353. IDS_PVC_Layer2_16,
  354. IDS_PVC_Layer2_17 };
  355. InitComboWithStringArray(hDlg, IDC_CMB_PVC_Layer2, celems(nrgLayer2Ids), nrgLayer2Ids);
  356. // layer3 protocol: IDC_CMB_PVC_Layer3
  357. static const int nrgLayer3Ids[] = { IDS_PVC_Any,
  358. IDS_PVC_Absent,
  359. IDS_PVC_Layer3_6,
  360. IDS_PVC_Layer3_7,
  361. IDS_PVC_Layer3_8,
  362. IDS_PVC_Layer3_9,
  363. IDS_PVC_Layer3_10,
  364. IDS_PVC_Layer3_11,
  365. IDS_PVC_Layer3_16 };
  366. InitComboWithStringArray(hDlg, IDC_CMB_PVC_Layer3, celems(nrgLayer3Ids), nrgLayer3Ids);
  367. // high layer type: IDC_CMB_PVC_High_Type
  368. static const int nrgHighLayerIds[] = { IDS_PVC_Any,
  369. IDS_PVC_Absent,
  370. IDS_PVC_HighLayer_0,
  371. IDS_PVC_HighLayer_1,
  372. IDS_PVC_HighLayer_3 };
  373. InitComboWithStringArray(hDlg, IDC_CMB_PVC_High_Type,
  374. celems(nrgHighLayerIds), nrgHighLayerIds);
  375. // set length limits for edit boxes
  376. ::SendDlgItemMessage(hDlg, IDC_EDT_PVC_User_Layer2, EM_SETLIMITTEXT, MAX_FIELD_LENGTH, 0);
  377. ::SendDlgItemMessage(hDlg, IDC_EDT_PVC_User_Layer3, EM_SETLIMITTEXT, MAX_FIELD_LENGTH, 0);
  378. ::SendDlgItemMessage(hDlg, IDC_EDT_PVC_Layer3_IPI, EM_SETLIMITTEXT, MAX_FIELD_LENGTH, 0);
  379. hwndTmp = GetDlgItem(hDlg, IDC_EDT_PVC_SNAP_ID);
  380. // Subclass the edit control to allow only hex digits
  381. ::SetWindowLongPtr(hwndTmp, GWLP_USERDATA, ::GetWindowLongPtr(hwndTmp, GWLP_WNDPROC));
  382. ::SetWindowLongPtr(hwndTmp, GWLP_WNDPROC, (LONG_PTR)AtmEditSubclassProc);
  383. ::SendDlgItemMessage(hDlg, IDC_EDT_PVC_SNAP_ID, EM_SETLIMITTEXT, c_nSnapIdMaxBytes*2, 0);
  384. ::SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Value, EM_SETLIMITTEXT, c_nHighLayerInfoMaxBytes*2, 0);
  385. }
  386. void SetBroadbandInfo(HWND hDlg, CPvcInfo * pPvcInfo, Location location)
  387. {
  388. // layer2 protocol and user specified value
  389. DWORD dwLayer2Protocol;
  390. DWORD dwUserSpecLayer2;
  391. if (location == LOCAL)
  392. {
  393. dwLayer2Protocol = pPvcInfo->m_dwLocalLayer2Protocol;
  394. dwUserSpecLayer2 = pPvcInfo->m_dwLocalUserSpecLayer2;
  395. }
  396. else
  397. {
  398. dwLayer2Protocol = pPvcInfo->m_dwDestnLayer2Protocol;
  399. dwUserSpecLayer2 = pPvcInfo->m_dwDestnUserSpecLayer2;
  400. }
  401. SetProtocolInfo(hDlg, IDC_CMB_PVC_Layer2, IDC_EDT_PVC_User_Layer2,
  402. dwLayer2Protocol, dwUserSpecLayer2);
  403. // layer3 protocol and user specified value
  404. DWORD dwLayer3Protocol;
  405. DWORD dwUserSpecLayer3;
  406. if (location == LOCAL)
  407. {
  408. dwLayer3Protocol = pPvcInfo->m_dwLocalLayer3Protocol;
  409. dwUserSpecLayer3 = pPvcInfo->m_dwLocalUserSpecLayer3;
  410. }
  411. else
  412. {
  413. dwLayer3Protocol = pPvcInfo->m_dwDestnLayer3Protocol;
  414. dwUserSpecLayer3 = pPvcInfo->m_dwDestnUserSpecLayer3;
  415. }
  416. SetProtocolInfo(hDlg, IDC_CMB_PVC_Layer3, IDC_EDT_PVC_User_Layer3,
  417. dwLayer3Protocol, dwUserSpecLayer3);
  418. // Layer3 IPI
  419. DWORD dwLayer3IPI;
  420. if (location == LOCAL)
  421. {
  422. dwLayer3IPI = pPvcInfo->m_dwLocalLayer3IPI;
  423. }
  424. else
  425. {
  426. dwLayer3IPI = pPvcInfo->m_dwDestnLayer3IPI;
  427. }
  428. SetDwordEdtField(hDlg, dwLayer3IPI, IDC_EDT_PVC_Layer3_IPI);
  429. // Snap ID
  430. if (location == LOCAL)
  431. {
  432. SetDlgItemText(hDlg,IDC_EDT_PVC_SNAP_ID, pPvcInfo->m_strLocalSnapId.c_str());
  433. }
  434. else
  435. {
  436. SetDlgItemText(hDlg,IDC_EDT_PVC_SNAP_ID, pPvcInfo->m_strDestnSnapId.c_str());
  437. }
  438. // High layer
  439. DWORD dwHighLayerInfoType;
  440. tstring strHighLayerInfo;
  441. if (location == LOCAL)
  442. {
  443. dwHighLayerInfoType = pPvcInfo->m_dwLocalHighLayerInfoType;
  444. strHighLayerInfo = pPvcInfo->m_strLocalHighLayerInfo;
  445. }
  446. else
  447. {
  448. dwHighLayerInfoType = pPvcInfo->m_dwDestnHighLayerInfoType;
  449. strHighLayerInfo = pPvcInfo->m_strDestnHighLayerInfo;
  450. }
  451. SetHighLayerInfo(hDlg, dwHighLayerInfoType, strHighLayerInfo);
  452. }
  453. void SetProtocolInfo(HWND hDlg, int nIDDlgItemCombo, int nIDDlgItemEdit,
  454. DWORD dwProtocol, DWORD dwUserSpecValue)
  455. {
  456. if ( FIELD_ANY == dwProtocol)
  457. {
  458. SendDlgItemMessage(hDlg, nIDDlgItemCombo, CB_SETCURSEL, (LPARAM)(0), 0);
  459. }
  460. else if ( FIELD_ABSENT == dwProtocol)
  461. {
  462. SendDlgItemMessage(hDlg, nIDDlgItemCombo, CB_SETCURSEL, (LPARAM)(1), 0);
  463. }
  464. else if (FIELD_UNSET != dwProtocol)
  465. {
  466. WCHAR szBuf[MAX_FIELD_LENGTH+1];
  467. wsprintfW(szBuf, c_szItoa, dwProtocol);
  468. tstring strBuf = szBuf;
  469. // attached the separator '-'
  470. strBuf+= c_chSeparator;
  471. // see if the value is one of the pre-defined protocol
  472. int nIdx = (int)SendDlgItemMessage(hDlg, nIDDlgItemCombo, CB_FINDSTRING, -1,
  473. (LPARAM)strBuf.c_str());
  474. if (CB_ERR == nIdx) // not one of the pre-defined protocols
  475. {
  476. SetDlgItemText(hDlg, nIDDlgItemCombo, szBuf);
  477. }
  478. else
  479. {
  480. SendDlgItemMessage(hDlg, nIDDlgItemCombo, CB_SETCURSEL, nIdx, 0L);
  481. }
  482. }
  483. if (dwProtocol == c_dwUserSpecProtocol)
  484. {
  485. SetDwordEdtField(hDlg, dwUserSpecValue, nIDDlgItemEdit);
  486. }
  487. else
  488. {
  489. ::EnableWindow(::GetDlgItem(hDlg,nIDDlgItemEdit), FALSE);
  490. }
  491. }
  492. void SetHighLayerInfo(HWND hDlg, DWORD dwHighLayerInfoType, tstring & strHighLayerInfo)
  493. {
  494. if ( FIELD_ANY == dwHighLayerInfoType)
  495. {
  496. SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_SETCURSEL, (LPARAM)(0), 0);
  497. }
  498. else if ( FIELD_ABSENT == dwHighLayerInfoType)
  499. {
  500. SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_SETCURSEL, (LPARAM)(1), 0);
  501. }
  502. else if ( FIELD_UNSET != dwHighLayerInfoType)
  503. {
  504. WCHAR szBuf[MAX_FIELD_LENGTH+1];
  505. wsprintfW(szBuf, c_szItoa, dwHighLayerInfoType);
  506. tstring strBuf = szBuf;
  507. // attached the separator '-'
  508. strBuf+= c_chSeparator;
  509. // see if the value is one of the pre-defined protocol
  510. int nIdx = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_FINDSTRING, -1,
  511. (LPARAM)strBuf.c_str());
  512. if (CB_ERR == nIdx) // not one of the pre-defined protocols
  513. {
  514. SetDlgItemText(hDlg, IDC_CMB_PVC_High_Type, szBuf);
  515. }
  516. else
  517. {
  518. SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_SETCURSEL, nIdx, 0L);
  519. }
  520. }
  521. if (dwHighLayerInfoType == c_dwUserSpecHighLayer)
  522. {
  523. HWND hwndTmp;
  524. hwndTmp = GetDlgItem(hDlg, IDC_CMB_PVC_High_Value);
  525. // Subclass the edit control to allow only hex digits
  526. ::SetWindowLongPtr(hwndTmp, GWLP_USERDATA, ::GetWindowLongPtr(hwndTmp,
  527. GWLP_WNDPROC));
  528. ::SetWindowLongPtr(hwndTmp, GWLP_WNDPROC, (LONG_PTR)AtmEditSubclassProc);
  529. SetDlgItemText(hDlg, IDC_CMB_PVC_High_Value, strHighLayerInfo.c_str());
  530. }
  531. else
  532. {
  533. ::EnableWindow(::GetDlgItem(hDlg,IDC_CMB_PVC_High_Value), FALSE);
  534. ::EnableWindow(::GetDlgItem(hDlg,IDC_TXT_PVC_Value), FALSE);
  535. }
  536. }
  537. void GetBroadbandInfo(HWND hDlg, CPvcInfo * pPvcInfo, Location location)
  538. {
  539. // layer2 protocol and user specified value
  540. DWORD * pdwLayer2Protocol;
  541. DWORD * pdwUserSpecLayer2;
  542. if (location == LOCAL)
  543. {
  544. pdwLayer2Protocol = &(pPvcInfo->m_dwLocalLayer2Protocol);
  545. pdwUserSpecLayer2 = &(pPvcInfo->m_dwLocalUserSpecLayer2);
  546. }
  547. else
  548. {
  549. pdwLayer2Protocol = &(pPvcInfo->m_dwDestnLayer2Protocol);
  550. pdwUserSpecLayer2 = &(pPvcInfo->m_dwDestnUserSpecLayer2);
  551. }
  552. GetProtocolInfo(hDlg, IDC_CMB_PVC_Layer2, IDC_EDT_PVC_User_Layer2,
  553. pdwLayer2Protocol, pdwUserSpecLayer2);
  554. // layer3 protocol and user specified value
  555. DWORD * pdwLayer3Protocol;
  556. DWORD * pdwUserSpecLayer3;
  557. if (location == LOCAL)
  558. {
  559. pdwLayer3Protocol = &(pPvcInfo->m_dwLocalLayer3Protocol);
  560. pdwUserSpecLayer3 = &(pPvcInfo->m_dwLocalUserSpecLayer3);
  561. }
  562. else
  563. {
  564. pdwLayer3Protocol = &(pPvcInfo->m_dwDestnLayer3Protocol);
  565. pdwUserSpecLayer3 = &(pPvcInfo->m_dwDestnUserSpecLayer3);
  566. }
  567. GetProtocolInfo(hDlg, IDC_CMB_PVC_Layer3, IDC_EDT_PVC_User_Layer3,
  568. pdwLayer3Protocol, pdwUserSpecLayer3);
  569. // Layer3 IPI
  570. DWORD * pdwLayer3IPI;
  571. if (location == LOCAL)
  572. {
  573. pdwLayer3IPI = &(pPvcInfo->m_dwLocalLayer3IPI);
  574. }
  575. else
  576. {
  577. pdwLayer3IPI = &(pPvcInfo->m_dwDestnLayer3IPI);
  578. }
  579. GetDwordEdtField(hDlg, pdwLayer3IPI, IDC_EDT_PVC_Layer3_IPI);
  580. // Snap ID
  581. WCHAR szSnapId[MAX_PATH];
  582. GetDlgItemText(hDlg, IDC_EDT_PVC_SNAP_ID, szSnapId, celems(szSnapId));
  583. if (location == LOCAL)
  584. {
  585. pPvcInfo->m_strLocalSnapId = szSnapId;
  586. }
  587. else
  588. {
  589. pPvcInfo->m_strDestnSnapId = szSnapId;
  590. }
  591. // High layer
  592. DWORD * pdwHighLayerInfoType;
  593. tstring * pstrHighLayerInfo;
  594. if (location == LOCAL)
  595. {
  596. pdwHighLayerInfoType = &(pPvcInfo->m_dwLocalHighLayerInfoType);
  597. pstrHighLayerInfo = &(pPvcInfo->m_strLocalHighLayerInfo);
  598. }
  599. else
  600. {
  601. pdwHighLayerInfoType = &(pPvcInfo->m_dwDestnHighLayerInfoType);
  602. pstrHighLayerInfo = &(pPvcInfo->m_strDestnHighLayerInfo);
  603. }
  604. GetHighLayerInfo(hDlg, pdwHighLayerInfoType, pstrHighLayerInfo);
  605. }
  606. void GetProtocolInfo(HWND hDlg, int nIDDlgItemCombo, int nIDDlgItemEdit,
  607. DWORD * pdwProtocol, DWORD * pdwUserSpecValue)
  608. {
  609. WCHAR szBuf[MAX_PATH];
  610. int nlen = GetDlgItemText(hDlg, nIDDlgItemCombo, szBuf, MAX_PATH);
  611. if (nlen==0)
  612. {
  613. // empty protocol2 field
  614. *pdwProtocol = FIELD_UNSET;
  615. *pdwUserSpecValue = FIELD_UNSET;
  616. }
  617. else
  618. {
  619. int nIdx = (int)SendDlgItemMessage(hDlg, nIDDlgItemCombo, CB_FINDSTRINGEXACT, -1,
  620. (LPARAM)(PCWSTR)szBuf);
  621. if (0 == nIdx)
  622. {
  623. *pdwProtocol = FIELD_ANY;
  624. *pdwUserSpecValue = 0;
  625. }
  626. else if (1 == nIdx)
  627. {
  628. *pdwProtocol = FIELD_ABSENT;
  629. *pdwUserSpecValue = 0;
  630. }
  631. else
  632. {
  633. GetNumFromString(szBuf, pdwProtocol);
  634. *pdwUserSpecValue = 0;
  635. if (*pdwProtocol == c_dwUserSpecProtocol)
  636. {
  637. GetDwordEdtField(hDlg, pdwUserSpecValue, nIDDlgItemEdit);
  638. }
  639. }
  640. }
  641. }
  642. void GetHighLayerInfo(HWND hDlg, DWORD * pdwHighLayerInfoType, tstring * pstrHighLayerInfo)
  643. {
  644. WCHAR szBuf[MAX_PATH];
  645. *pstrHighLayerInfo = c_szEmpty;
  646. int nlen = GetDlgItemText(hDlg, IDC_CMB_PVC_High_Type, szBuf, MAX_PATH);
  647. if (nlen==0)
  648. {
  649. // empty field
  650. *pdwHighLayerInfoType = FIELD_UNSET;
  651. }
  652. else
  653. {
  654. int nIdx = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_FINDSTRINGEXACT, -1,
  655. (LPARAM)(PCWSTR)szBuf);
  656. if (0 == nIdx)
  657. {
  658. *pdwHighLayerInfoType = FIELD_ANY;
  659. }
  660. else if (1 == nIdx)
  661. {
  662. *pdwHighLayerInfoType = FIELD_ABSENT;
  663. }
  664. else
  665. {
  666. GetNumFromString(szBuf, pdwHighLayerInfoType);
  667. if (*pdwHighLayerInfoType == c_dwUserSpecHighLayer)
  668. {
  669. WCHAR szHighLayerInfo[MAX_PATH];
  670. GetDlgItemText(hDlg, IDC_CMB_PVC_High_Value,
  671. szHighLayerInfo, celems(szHighLayerInfo));
  672. *pstrHighLayerInfo = szHighLayerInfo;
  673. }
  674. }
  675. }
  676. }
  677. void OnLayer2EdtChange(HWND hDlg)
  678. {
  679. // get the current value in the control,
  680. // and see if we should enable or disable the edit box for user specified value
  681. WCHAR szBuf[MAX_PATH];
  682. GetDlgItemText(hDlg, IDC_CMB_PVC_Layer2, szBuf, MAX_PATH);
  683. if (!(*szBuf))
  684. {
  685. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer2), FALSE);
  686. }
  687. else
  688. {
  689. // the string has to be equal to the specific number
  690. if (0 == wcscmp(szBuf, c_szUserSpecProtocol))
  691. {
  692. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer2), TRUE);
  693. }
  694. else
  695. {
  696. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer2), FALSE);
  697. }
  698. }
  699. }
  700. void OnLayer2SelChange(HWND hDlg)
  701. {
  702. // get the index of the new selection
  703. int idx = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_Layer2, CB_GETCURSEL, (LPARAM)(0), 0);
  704. if (idx != CB_ERR)
  705. {
  706. // get the string of the current selection
  707. WCHAR szBuf[MAX_PATH];
  708. int len = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_Layer2, CB_GETLBTEXT,
  709. (LPARAM)(idx), (WPARAM)(PCWSTR)szBuf);
  710. if ((len != CB_ERR) && (len>0))
  711. {
  712. DWORD dwNum;
  713. GetNumFromString(szBuf, &dwNum);
  714. if (dwNum == c_dwUserSpecProtocol)
  715. {
  716. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer2), TRUE);
  717. }
  718. else
  719. {
  720. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer2), FALSE);
  721. }
  722. }
  723. }
  724. }
  725. void OnLayer3EdtChange(HWND hDlg)
  726. {
  727. // get the current value in the control,
  728. // and see if we should enable or disable the edit box for user specified value
  729. WCHAR szBuf[MAX_PATH];
  730. GetDlgItemText(hDlg, IDC_CMB_PVC_Layer3, szBuf, MAX_PATH);
  731. if (!(*szBuf))
  732. {
  733. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3), FALSE);
  734. }
  735. else
  736. {
  737. // the string has to be equal to the specific number
  738. if (0 == wcscmp(szBuf, c_szUserSpecProtocol))
  739. {
  740. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3), TRUE);
  741. }
  742. else
  743. {
  744. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3), FALSE);
  745. }
  746. }
  747. }
  748. void OnLayer3SelChange(HWND hDlg)
  749. {
  750. // get the index of the new selection
  751. int idx = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_Layer3, CB_GETCURSEL, (LPARAM)(0), 0);
  752. if (idx != CB_ERR)
  753. {
  754. // get the string of the current selection
  755. WCHAR szBuf[MAX_PATH];
  756. int len = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_Layer3, CB_GETLBTEXT,
  757. (LPARAM)(idx), (WPARAM)(PCWSTR)szBuf);
  758. if ((len != CB_ERR) && (len>0))
  759. {
  760. DWORD dwNum;
  761. GetNumFromString(szBuf, &dwNum);
  762. if (dwNum == c_dwUserSpecProtocol)
  763. {
  764. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3), TRUE);
  765. }
  766. else
  767. {
  768. ::EnableWindow(::GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3), FALSE);
  769. }
  770. }
  771. }
  772. }
  773. void OnHighLayerEdtChange(HWND hDlg)
  774. {
  775. // get the current value in the control,
  776. // and see if we should enable or disable the edit box for user specified value
  777. WCHAR szBuf[MAX_PATH];
  778. GetDlgItemText(hDlg, IDC_CMB_PVC_High_Type, szBuf, MAX_PATH);
  779. if (!(*szBuf))
  780. {
  781. ::EnableWindow(::GetDlgItem(hDlg, IDC_CMB_PVC_High_Value), FALSE);
  782. ::EnableWindow(::GetDlgItem(hDlg, IDC_TXT_PVC_Value), FALSE);
  783. }
  784. else
  785. {
  786. // the string has to be equal to the specific number
  787. if (0 == wcscmp(szBuf, c_szUserSpecHighLayer))
  788. {
  789. ::EnableWindow(::GetDlgItem(hDlg,IDC_CMB_PVC_High_Value), TRUE);
  790. ::EnableWindow(::GetDlgItem(hDlg, IDC_TXT_PVC_Value), TRUE);
  791. }
  792. else
  793. {
  794. ::EnableWindow(::GetDlgItem(hDlg,IDC_CMB_PVC_High_Value), FALSE);
  795. ::EnableWindow(::GetDlgItem(hDlg, IDC_TXT_PVC_Value), FALSE);
  796. }
  797. }
  798. }
  799. void OnHighLayerSelChange(HWND hDlg)
  800. {
  801. // get the index of the new selection
  802. int idx = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_GETCURSEL, (LPARAM)(0), 0);
  803. if (idx != CB_ERR)
  804. {
  805. // get the string of the current selection
  806. WCHAR szBuf[MAX_PATH];
  807. int len = (int)SendDlgItemMessage(hDlg, IDC_CMB_PVC_High_Type, CB_GETLBTEXT,
  808. (LPARAM)(idx), (WPARAM)(PCWSTR)szBuf);
  809. if ((len != CB_ERR) && (len>0))
  810. {
  811. DWORD dwNum;
  812. GetNumFromString(szBuf, &dwNum);
  813. if (dwNum == c_dwUserSpecHighLayer)
  814. {
  815. HWND hwndTmp;
  816. hwndTmp = GetDlgItem(hDlg, IDC_CMB_PVC_High_Value);
  817. // Subclass the edit control to allow only hex digits
  818. ::SetWindowLongPtr(hwndTmp, GWLP_USERDATA, ::GetWindowLongPtr(hwndTmp,
  819. GWLP_WNDPROC));
  820. ::SetWindowLongPtr(hwndTmp, GWLP_WNDPROC, (LONG_PTR)AtmEditSubclassProc);
  821. ::EnableWindow(::GetDlgItem(hDlg,IDC_CMB_PVC_High_Value), TRUE);
  822. ::EnableWindow(::GetDlgItem(hDlg, IDC_TXT_PVC_Value), TRUE);
  823. }
  824. else
  825. {
  826. ::EnableWindow(::GetDlgItem(hDlg,IDC_CMB_PVC_High_Value), FALSE);
  827. ::EnableWindow(::GetDlgItem(hDlg, IDC_TXT_PVC_Value), FALSE);
  828. }
  829. }
  830. }
  831. }
  832. void GetNumFromString(PWSTR pszBuf, DWORD * pdwNum)
  833. {
  834. *pdwNum=0;
  835. WCHAR * pch;
  836. pch = pszBuf;
  837. while ((*pch >= L'0') && (*pch <= L'9'))
  838. {
  839. *pdwNum = (*pdwNum*10) + (*pch - L'0');
  840. pch++;
  841. }
  842. }
  843. BOOL InvalidBroadbandInfo(HWND hDlg)
  844. {
  845. BOOL err = FALSE;
  846. // layer2 protocol & value
  847. if (!IsValidCmbSelection(hDlg, IDC_CMB_PVC_Layer2))
  848. {
  849. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_Layer2_Protocol,
  850. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  851. SetFocus(GetDlgItem(hDlg, IDC_CMB_PVC_Layer2));
  852. err = TRUE;
  853. }
  854. else if ((!err) && (IsWindowEnabled(GetDlgItem(hDlg, IDC_EDT_PVC_User_Layer2))))
  855. {
  856. if (!IsValidDwordField(hDlg, IDC_EDT_PVC_User_Layer2))
  857. {
  858. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_Layer2_UserSpec,
  859. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  860. SetFocus(GetDlgItem(hDlg, IDC_EDT_PVC_User_Layer2));
  861. err = TRUE;
  862. }
  863. }
  864. // layer3 protocol & value
  865. if (!err)
  866. {
  867. if (!IsValidCmbSelection(hDlg, IDC_CMB_PVC_Layer3))
  868. {
  869. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_Layer3_Protocol,
  870. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  871. SetFocus(GetDlgItem(hDlg,IDC_CMB_PVC_Layer3));
  872. err = TRUE;
  873. }
  874. else if ((!err) && (IsWindowEnabled(GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3))))
  875. {
  876. if (!IsValidDwordField(hDlg, IDC_EDT_PVC_User_Layer2))
  877. {
  878. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_Layer3_UserSpec,
  879. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  880. SetFocus(GetDlgItem(hDlg,IDC_EDT_PVC_User_Layer3));
  881. err = TRUE;
  882. }
  883. }
  884. }
  885. //Layer3 IPI
  886. if (!err)
  887. {
  888. if (!IsValidDwordField(hDlg, IDC_EDT_PVC_Layer3_IPI))
  889. {
  890. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_Layer3_IPI,
  891. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  892. SetFocus(GetDlgItem(hDlg,IDC_EDT_PVC_Layer3_IPI));
  893. err = TRUE;
  894. }
  895. }
  896. // SnapId
  897. if (!IsValidBinaryField(hDlg, IDC_EDT_PVC_SNAP_ID, c_nSnapIdMaxBytes))
  898. {
  899. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_SnapId,
  900. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  901. SetFocus(GetDlgItem(hDlg, IDC_EDT_PVC_SNAP_ID));
  902. err = TRUE;
  903. }
  904. // High layer info
  905. if (!err)
  906. {
  907. if (!IsValidCmbSelection(hDlg, IDC_CMB_PVC_High_Type))
  908. {
  909. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_Highlayer_Type,
  910. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  911. SetFocus(GetDlgItem(hDlg,IDC_CMB_PVC_High_Type));
  912. err = TRUE;
  913. }
  914. else if ((!err) && (IsWindowEnabled(GetDlgItem(hDlg,IDC_CMB_PVC_High_Value))))
  915. {
  916. if (!IsValidBinaryField(hDlg, IDC_CMB_PVC_High_Value, c_nHighLayerInfoMaxBytes))
  917. {
  918. NcMsgBox(hDlg, IDS_MSFT_UNI_TEXT, IDS_INVALID_HighLayerValue,
  919. MB_APPLMODAL | MB_ICONEXCLAMATION | MB_OK);
  920. SetFocus(GetDlgItem(hDlg,IDC_CMB_PVC_High_Value));
  921. err = TRUE;
  922. }
  923. }
  924. }
  925. return err;
  926. }
  927. BOOL IsValidCmbSelection(HWND hDlg, int nIDDlgItemCombo)
  928. {
  929. BOOL ret = TRUE;
  930. WCHAR szBuf[MAX_PATH];
  931. int nlen = GetDlgItemText(hDlg, nIDDlgItemCombo, szBuf, MAX_PATH);
  932. if (nlen > 0) // empty string is ok
  933. {
  934. int nIdx = (int)SendDlgItemMessage(hDlg, nIDDlgItemCombo, CB_FINDSTRINGEXACT, -1,
  935. (LPARAM)(PCWSTR)szBuf);
  936. if (nIdx == CB_ERR) // any string in the selection is ok
  937. {
  938. DWORD dwProtocol;
  939. GetNumFromString(szBuf, &dwProtocol);
  940. #pragma warning(push)
  941. #pragma warning(disable:4296)
  942. if ((dwProtocol > c_dwFieldHigh) || (dwProtocol < c_dwFieldLow))
  943. {
  944. ret = FALSE;
  945. }
  946. #pragma warning(pop)
  947. }
  948. }
  949. return ret;
  950. }
  951. BOOL IsValidDwordField(HWND hDlg, int nIDDlgItemEdit)
  952. {
  953. BOOL ret = TRUE;
  954. DWORD dwValue;
  955. GetDwordEdtField(hDlg, &dwValue, nIDDlgItemEdit);
  956. if (FIELD_UNSET != dwValue) // empty field is ok
  957. {
  958. #pragma warning(push)
  959. #pragma warning(disable:4296)
  960. if ((dwValue > c_dwFieldHigh) || (dwValue < c_dwFieldLow))
  961. {
  962. ret = FALSE;
  963. }
  964. #pragma warning(pop)
  965. }
  966. return ret;
  967. }
  968. BOOL IsValidBinaryField(HWND hDlg, int nIDDlgItemEdit, int nMaxBytes)
  969. {
  970. BOOL ret = TRUE;
  971. WCHAR szBuff[MAX_PATH];
  972. GetDlgItemText(hDlg, nIDDlgItemEdit, szBuff, celems(szBuff));
  973. //length
  974. int nlen = wcslen(szBuff);
  975. if (nlen % 2) // must be even number of hex digits
  976. {
  977. ret = FALSE;
  978. }
  979. else
  980. {
  981. if ((szBuff[0] == L'0') &&
  982. ((szBuff[1] == L'x') || (szBuff[1] == L'X')))
  983. {
  984. nlen -= 2;
  985. }
  986. if (nlen > nMaxBytes*2)
  987. {
  988. ret = FALSE;
  989. }
  990. }
  991. if (ret)
  992. {
  993. int i=0;
  994. nlen = wcslen(szBuff);
  995. if ((szBuff[0] == L'0') &&
  996. ((szBuff[1] == L'x') || (szBuff[1] == L'X')))
  997. {
  998. i = 2;
  999. }
  1000. while (i<nlen)
  1001. {
  1002. if (((szBuff[i] >= L'0') && (szBuff[i] <= L'9')) ||
  1003. ((szBuff[i] >= L'a') && (szBuff[i] <= L'f')) ||
  1004. ((szBuff[i] >= L'A') && (szBuff[i] <= L'F')))
  1005. {
  1006. i++;
  1007. }
  1008. else
  1009. {
  1010. ret = FALSE;
  1011. break;
  1012. }
  1013. }
  1014. }
  1015. return ret;
  1016. }