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.

2099 lines
58 KiB

  1. // nwlnkipx.cpp : Implementation of CNwlnkIPX
  2. #include "pch.h"
  3. #pragma hdrstop
  4. #include "nwlnkipx.h"
  5. #include "ncatlui.h"
  6. #include "ncui.h"
  7. extern const WCHAR c_szNetCfgHelpFile[];
  8. extern const WCHAR c_sz8Zeros[];
  9. static const FRAME_TYPE aFDDI_Frames[] = {{IDS_AUTO, AUTO},
  10. {IDS_FDDI, F802_2},
  11. {IDS_FDDI_SNAP, SNAP},
  12. {IDS_FDDI_802_3, F802_3},
  13. {0,0}
  14. };
  15. static const FRAME_TYPE aTOKEN_Frames[] = {{IDS_AUTO, AUTO},
  16. {IDS_TK, F802_2},
  17. {IDS_802_5, SNAP},
  18. {0,0}
  19. };
  20. static const FRAME_TYPE aARCNET_Frames[] = {
  21. {IDS_AUTO, AUTO},
  22. {IDS_ARCNET, ARCNET},
  23. {0,0}
  24. };
  25. static const FRAME_TYPE aEthernet_Frames[] = {
  26. {IDS_AUTO, AUTO},
  27. {IDS_ETHERNET, ETHERNET},
  28. {IDS_802_2, F802_2},
  29. {IDS_802_3, F802_3},
  30. {IDS_SNAP, SNAP},
  31. {0,0}
  32. };
  33. static const MEDIA_TYPE MediaMap[] = {{FDDI_MEDIA, aFDDI_Frames},
  34. {TOKEN_MEDIA, aTOKEN_Frames},
  35. {ARCNET_MEDIA, aARCNET_Frames},
  36. {ETHERNET_MEDIA, aEthernet_Frames}
  37. };
  38. //+---------------------------------------------------------------------------
  39. //
  40. // Member: EditSubclassProc
  41. //
  42. // Purpose: Subclass proc for network number edit controls. The
  43. // subclassing forces only correct input
  44. //
  45. // Parameters: none
  46. //
  47. // Returns: nothing
  48. //
  49. // Author: scottbri 28-Apr-1997
  50. //
  51. STDAPI EditSubclassProc( HWND hwnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
  52. {
  53. WNDPROC pIpxEditProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
  54. // Allow copy/paste keys (CTRL)
  55. if ((!(GetKeyState(VK_CONTROL) & 0x8000)) &&
  56. (wMsg == WM_CHAR))
  57. {
  58. // Check for invalid hex characters
  59. if (!(((WCHAR)wParam >= L'0' && (WCHAR)wParam <= L'9') ||
  60. ((WCHAR)wParam >= L'a' && (WCHAR)wParam <= L'f') ||
  61. ((WCHAR)wParam >= L'A' && (WCHAR)wParam <= L'F') ||
  62. ((WCHAR)wParam == VK_BACK)))
  63. {
  64. // Not allowed
  65. MessageBeep(MB_ICONEXCLAMATION);
  66. return 0L;
  67. }
  68. }
  69. return CallWindowProc( pIpxEditProc, hwnd, wMsg, wParam, lParam );
  70. }
  71. LRESULT CommonIPXOnContextMenu(HWND hWnd, const DWORD * padwHelpIDs)
  72. {
  73. Assert(padwHelpIDs);
  74. WinHelp(hWnd,
  75. c_szNetCfgHelpFile,
  76. HELP_CONTEXTMENU,
  77. (ULONG_PTR)padwHelpIDs);
  78. return 0;
  79. }
  80. LRESULT CommonIPXOnHelp(LPARAM lParam, const DWORD * padwHelpIDs)
  81. {
  82. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  83. Assert(lphi);
  84. Assert(padwHelpIDs);
  85. if (HELPINFO_WINDOW == lphi->iContextType)
  86. {
  87. if (padwHelpIDs != NULL)
  88. {
  89. WinHelp(static_cast<HWND>(lphi->hItemHandle),
  90. c_szNetCfgHelpFile,
  91. HELP_WM_HELP,
  92. (ULONG_PTR)padwHelpIDs);
  93. }
  94. }
  95. return 0;
  96. }
  97. //+---------------------------------------------------------------------------
  98. //
  99. // Member: CIpxConfigDlg::CIpxConfigDlg
  100. //
  101. // Purpose: ctor for the CIpxConfigDlg class
  102. //
  103. // Parameters: none
  104. //
  105. // Returns: nothing
  106. //
  107. // Author: scottbri 28-Apr-1997
  108. //
  109. CIpxConfigDlg::CIpxConfigDlg(CNwlnkIPX *pmsc, CIpxEnviroment * pIpxEnviroment,
  110. CIpxAdapterInfo * pAI)
  111. {
  112. // Note these parameters are on loan, do not free them...
  113. Assert(NULL != pmsc);
  114. Assert(NULL != pIpxEnviroment);
  115. m_pmsc = pmsc;
  116. m_pIpxEnviroment = pIpxEnviroment;
  117. ZeroMemory(&m_WrkstaDlgInfo, sizeof(m_WrkstaDlgInfo));
  118. m_pAICurrent = pAI;
  119. }
  120. //+---------------------------------------------------------------------------
  121. //
  122. // Member: CIpxConfigDlg::OnInitDialog
  123. //
  124. // Purpose: Called when this dialog is first brought up.
  125. //
  126. // Parameters:
  127. // uMsg [in]
  128. // wParam [in] See the ATL documentation for params.
  129. // lParam [in]
  130. // bHandled [in]
  131. //
  132. // Returns: See the ATL documentation for return results.
  133. //
  134. // Author: scottbri 11-Apr-1997
  135. //
  136. // Notes:
  137. //
  138. LRESULT CIpxConfigDlg::OnInitDialog(UINT uMsg, WPARAM wParam,
  139. LPARAM lParam, BOOL& bHandled)
  140. {
  141. UINT nIdx;
  142. int aIds[] = {IDS_IPXPP_TEXT_1, IDS_IPXPP_TEXT_2};
  143. tstring strText;
  144. WCHAR szBuf[12];
  145. HWND hwndEdit = GetDlgItem(EDT_IPXPP_NETWORKNUMBER);
  146. HWND hwndEditINN = GetDlgItem(EDT_IPXAS_INTERNAL);
  147. // Build the property page's informative text block
  148. for (nIdx=0; nIdx < celems(aIds); nIdx++)
  149. strText += SzLoadIds(aIds[nIdx]);
  150. ::SetWindowText(GetDlgItem(IDC_IPXPP_TEXT), strText.c_str());
  151. // Subclass the network number edit control
  152. ::SetWindowLongPtr(hwndEdit, GWLP_USERDATA, ::GetWindowLongPtr(hwndEdit, GWLP_WNDPROC));
  153. ::SetWindowLongPtr(hwndEdit, GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
  154. ::SetWindowLongPtr(hwndEditINN, GWLP_USERDATA, (LONG_PTR) ::GetWindowLongPtr(hwndEditINN, GWLP_WNDPROC));
  155. ::SetWindowLongPtr(hwndEditINN, GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
  156. // Limit the text in the network # edit control
  157. ::SendMessage(hwndEdit, EM_LIMITTEXT, MAX_NETNUM_SIZE, 0L);
  158. ::SendMessage(hwndEditINN, EM_LIMITTEXT, MAX_NETNUM_SIZE, 0L);
  159. // Populate the Inernal Network Number edit control
  160. HexSzFromDw(szBuf, m_pIpxEnviroment->DwVirtualNetworkNumber());
  161. ::SetWindowText(hwndEditINN,szBuf);
  162. // If no adapter cards are present inform the user
  163. // and disable the UI.
  164. Assert(NULL != m_pIpxEnviroment);
  165. if (NULL == m_pAICurrent)
  166. {
  167. int aIdc[] = {CMB_IPXPP_FRAMETYPE,
  168. EDT_IPXPP_NETWORKNUMBER,
  169. IDC_STATIC_NETNUM,
  170. IDC_STATIC_FRAMETYPE,
  171. GB_IPXPP_ADAPTER,
  172. IDC_IPXPP_ADAPTER_TEXT };
  173. // Disable the dialog controls
  174. for (nIdx = 0; nIdx<celems(aIdc); nIdx++)
  175. ::ShowWindow(GetDlgItem(aIdc[nIdx]), SW_HIDE);
  176. }
  177. else
  178. {
  179. Assert(m_pAICurrent);
  180. Assert(!m_pAICurrent->FDeletePending());
  181. Assert(!m_pAICurrent->FDisabled());
  182. Assert(!m_pAICurrent->FHidden());
  183. // Move the Adapter Info to the dialog's internal form
  184. m_WrkstaDlgInfo.pAI = m_pAICurrent;
  185. m_WrkstaDlgInfo.dwMediaType = m_pAICurrent->DwMediaType();
  186. m_WrkstaDlgInfo.dwFrameType = m_pAICurrent->DwFrameType();
  187. m_WrkstaDlgInfo.dwNetworkNumber = m_pAICurrent->DwNetworkNumber();
  188. // Adjust the UI to reflect the currently selected adapter
  189. AdapterChanged();
  190. }
  191. return FALSE;
  192. }
  193. //+---------------------------------------------------------------------------
  194. //
  195. // Member: CIpxConfigDlg::OnOk
  196. //
  197. // Purpose: Called when the OK button is pressed.
  198. //
  199. // Parameters:
  200. // idCtrl [in]
  201. // pnmh [in] See the ATL documentation for params.
  202. // bHandled [in]
  203. //
  204. // Returns: See the ATL documentation for return results.
  205. //
  206. // Author: scottbri 11-Apr-1997
  207. //
  208. // Notes:
  209. //
  210. LRESULT CIpxConfigDlg::OnOk(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  211. {
  212. HRESULT hr = S_OK;
  213. HWND hwndEdit = GetDlgItem(EDT_IPXAS_INTERNAL);
  214. WCHAR szBuf[12];
  215. ::GetWindowText(hwndEdit,szBuf,sizeof(szBuf)/sizeof(WCHAR));
  216. if (0 == lstrlenW(szBuf))
  217. {
  218. NcMsgBox(m_hWnd, IDS_MANUAL_FRAME_DETECT, IDS_INCORRECT_NETNUM, MB_OK | MB_ICONEXCLAMATION);
  219. ::SetFocus(hwndEdit);
  220. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  221. return TRUE;
  222. }
  223. // Update the virtual network number
  224. m_pIpxEnviroment->SetVirtualNetworkNumber(DwFromSz(szBuf, 16));
  225. if (NULL != m_pAICurrent)
  226. {
  227. m_pAICurrent->SetDirty(TRUE);
  228. // Force update of the currently selection items in our internal data
  229. // structure. This handles the case case of someone changing only
  230. // network num, and nothing else on the page.
  231. FrameTypeChanged();
  232. // Apply the internal data to original adapter info
  233. UpdateLstPtstring(m_WrkstaDlgInfo.pAI->m_lstpstrFrmType,
  234. m_WrkstaDlgInfo.dwFrameType);
  235. UpdateLstPtstring(m_WrkstaDlgInfo.pAI->m_lstpstrNetworkNum,
  236. m_WrkstaDlgInfo.dwNetworkNumber);
  237. }
  238. TraceError("CIpxConfigDlg::OnOk", hr);
  239. return LresFromHr(hr);
  240. }
  241. //+---------------------------------------------------------------------------
  242. //
  243. // Member: CIpxConfigDlg::OnContextMenu
  244. //
  245. // Purpose: Context sensitive help support.
  246. //
  247. // Author: jeffspr 13 Apr 1999
  248. //
  249. // Notes:
  250. //
  251. LRESULT CIpxConfigDlg::OnContextMenu(UINT uMsg, WPARAM wParam,
  252. LPARAM lParam, BOOL& fHandled)
  253. {
  254. return ::CommonIPXOnContextMenu(m_hWnd, g_aHelpIDs_DLG_IPX_CONFIG);
  255. }
  256. //+---------------------------------------------------------------------------
  257. //
  258. // Member: CIpxConfigDlg::OnHelp
  259. //
  260. // Purpose: Context sensitive help support.
  261. //
  262. // Author: jeffspr 13 Apr 1999
  263. //
  264. // Notes:
  265. //
  266. LRESULT CIpxConfigDlg::OnHelp(UINT uMsg, WPARAM wParam,
  267. LPARAM lParam, BOOL& fHandled)
  268. {
  269. return ::CommonIPXOnHelp(lParam, g_aHelpIDs_DLG_IPX_CONFIG);
  270. }
  271. //+---------------------------------------------------------------------------
  272. //
  273. // Member: CIpxConfigDlg::GetFrameType
  274. //
  275. // Purpose:
  276. //
  277. // Parameters:
  278. //
  279. // Returns:
  280. //
  281. // Author: scottbri 25-Apr-1997
  282. //
  283. const FRAME_TYPE *CIpxConfigDlg::GetFrameType(DWORD dwMediaType)
  284. {
  285. // Locate the media type
  286. for (int i=0; i<celems(MediaMap); i++)
  287. if (MediaMap[i].dwMediaType == dwMediaType)
  288. return MediaMap[i].aFrameType;
  289. return aEthernet_Frames;
  290. }
  291. //+---------------------------------------------------------------------------
  292. //
  293. // Member: CIpxConfigDlg::UpdateNetworkNumber
  294. //
  295. // Purpose:
  296. //
  297. // Parameters:
  298. //
  299. // Returns:
  300. //
  301. // Author: scottbri 28-Apr-1997
  302. //
  303. // Notes:
  304. //
  305. void CIpxConfigDlg::UpdateNetworkNumber(DWORD dwNetworkNumber,
  306. DWORD dwFrameType)
  307. {
  308. HWND hwndEdit = GetDlgItem(EDT_IPXPP_NETWORKNUMBER);
  309. if (dwFrameType != AUTO)
  310. {
  311. WCHAR szBuf[12];
  312. HexSzFromDw(szBuf, dwNetworkNumber);
  313. ::SetWindowText(hwndEdit, szBuf);
  314. ::EnableWindow(hwndEdit, TRUE);
  315. ::EnableWindow(GetDlgItem(IDC_STATIC_NETNUM), TRUE);
  316. }
  317. else
  318. {
  319. ::SetWindowText(hwndEdit, L"");
  320. ::EnableWindow(hwndEdit, FALSE);
  321. ::EnableWindow(GetDlgItem(IDC_STATIC_NETNUM), FALSE);
  322. }
  323. }
  324. //+---------------------------------------------------------------------------
  325. //
  326. // Member: CIpxConfigDlg::AdapterChanged
  327. //
  328. // Purpose:
  329. //
  330. // Parameters:
  331. //
  332. // Returns:
  333. //
  334. // Author: scottbri 28-Apr-1997
  335. //
  336. void CIpxConfigDlg::AdapterChanged()
  337. {
  338. DWORD dwFrameType;
  339. HWND hwndFrame = GetDlgItem(CMB_IPXPP_FRAMETYPE);
  340. HWND hwndEdit = GetDlgItem(EDT_IPXPP_NETWORKNUMBER);
  341. int nIdxLoop;
  342. int nIdx;
  343. const FRAME_TYPE * pft;
  344. if ((NULL == hwndFrame) || (NULL == m_pAICurrent))
  345. return;
  346. // Locate the Correct Frame Type info for this adapter's media type
  347. pft = GetFrameType(m_WrkstaDlgInfo.dwMediaType);
  348. Assert(NULL != pft);
  349. // Populate the Frame Type Combo
  350. ::SendMessage(hwndFrame, CB_RESETCONTENT, 0, 0L);
  351. for (nIdxLoop=0;
  352. pft[nIdxLoop].nFrameIds != 0;
  353. nIdxLoop++)
  354. {
  355. // Add the Frame Type's descriptive string
  356. nIdx = ::SendMessage(hwndFrame, CB_ADDSTRING, 0,
  357. (LPARAM)(PCWSTR)SzLoadIds(pft[nIdxLoop].nFrameIds));
  358. if (CB_ERR == nIdx)
  359. break;
  360. // Add the Frame Type for convenient access later
  361. ::SendMessage(hwndFrame, CB_SETITEMDATA, nIdx,
  362. pft[nIdxLoop].dwFrameType);
  363. }
  364. // Update the network number based on the frame type
  365. UpdateNetworkNumber(m_WrkstaDlgInfo.dwNetworkNumber,
  366. m_WrkstaDlgInfo.dwFrameType);
  367. switch (m_WrkstaDlgInfo.dwFrameType)
  368. {
  369. case ETHERNET:
  370. nIdx = IDS_ETHERNET;
  371. break;
  372. case F802_2:
  373. switch (m_WrkstaDlgInfo.dwMediaType)
  374. {
  375. case TOKEN_MEDIA:
  376. nIdx = IDS_TK;
  377. break;
  378. case FDDI_MEDIA:
  379. nIdx = IDS_FDDI;
  380. break;
  381. default:
  382. nIdx = IDS_802_2;
  383. break;
  384. }
  385. break;
  386. case F802_3:
  387. switch (m_WrkstaDlgInfo.dwMediaType)
  388. {
  389. case FDDI_MEDIA:
  390. nIdx = IDS_FDDI_802_3;
  391. break;
  392. default:
  393. nIdx = IDS_802_3;
  394. break;
  395. }
  396. break;
  397. case SNAP:
  398. switch (m_WrkstaDlgInfo.dwMediaType)
  399. {
  400. case TOKEN_MEDIA:
  401. nIdx = IDS_802_5;
  402. break;
  403. case FDDI_MEDIA:
  404. nIdx = IDS_FDDI_SNAP;
  405. break;
  406. default:
  407. nIdx = IDS_SNAP;
  408. break;
  409. }
  410. break;
  411. case ARCNET:
  412. nIdx = IDS_ARCNET;
  413. break;
  414. case AUTO:
  415. // Fall through...
  416. default:
  417. nIdx = IDS_AUTO;
  418. break;
  419. }
  420. // Set the frame type in the combo box
  421. ::SendMessage(hwndFrame, CB_SETCURSEL,
  422. ::SendMessage(hwndFrame, CB_FINDSTRINGEXACT,
  423. 0, ((LPARAM)(PCWSTR)SzLoadIds(nIdx))), 0);
  424. }
  425. //+---------------------------------------------------------------------------
  426. //
  427. // Member: CIpxConfigDlg::FrameTypeChanged
  428. //
  429. // Purpose:
  430. //
  431. // Parameters:
  432. //
  433. // Returns:
  434. //
  435. // Author: scottbri 28-Apr-1997
  436. //
  437. void CIpxConfigDlg::FrameTypeChanged()
  438. {
  439. HWND hwndFrame = GetDlgItem(CMB_IPXPP_FRAMETYPE);
  440. int nIdx;
  441. if (NULL == m_pAICurrent)
  442. return;
  443. // Locate the currently selected frame type
  444. nIdx = ::SendMessage(hwndFrame, CB_GETCURSEL, 0, 0L);
  445. if (CB_ERR == nIdx)
  446. return;
  447. // Update the currently selected frame type
  448. m_WrkstaDlgInfo.dwFrameType = ::SendMessage(hwndFrame, CB_GETITEMDATA, nIdx, 0L);
  449. SetNetworkNumber(&m_WrkstaDlgInfo.dwNetworkNumber);
  450. UpdateNetworkNumber(m_WrkstaDlgInfo.dwNetworkNumber,
  451. m_WrkstaDlgInfo.dwFrameType);
  452. }
  453. void CIpxConfigDlg::SetNetworkNumber(DWORD *pdw)
  454. {
  455. WCHAR szBuf[30];
  456. WCHAR szBuf2[30];
  457. szBuf[0] = NULL;
  458. HWND hwndEdit = GetDlgItem(EDT_IPXPP_NETWORKNUMBER);
  459. if (NULL == hwndEdit)
  460. {
  461. return;
  462. }
  463. // Get the new number and normalize it...
  464. ::GetWindowText(hwndEdit, szBuf, sizeof(szBuf)/sizeof(WCHAR));
  465. *pdw = DwFromSz(szBuf, 16);
  466. HexSzFromDw(szBuf2, *pdw);
  467. // Update the edit control if a parsing produced a net change
  468. if (lstrcmpW(szBuf,szBuf2) != 0)
  469. {
  470. ::SetWindowText(hwndEdit, szBuf2);
  471. }
  472. }
  473. //+---------------------------------------------------------------------------
  474. //
  475. // Member: CIpxConfigDlg::HandleNetworkNumber
  476. //
  477. // Purpose: Called when the network number edit control gets a message.
  478. //
  479. // Parameters: See the ATL documentation for params.
  480. //
  481. // Returns: See the ATL documentation for return results.
  482. //
  483. // Author: scottbri 13-Aug-1997
  484. //
  485. // Notes:
  486. //
  487. LRESULT
  488. CIpxConfigDlg::HandleNetworkNumber(
  489. WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  490. {
  491. if (EN_CHANGE == wNotifyCode)
  492. {
  493. SetChangedFlag();
  494. }
  495. if ((wNotifyCode != EN_KILLFOCUS) || (NULL == m_pAICurrent))
  496. return 0L;
  497. SetNetworkNumber(&m_WrkstaDlgInfo.dwNetworkNumber);
  498. return 0L;
  499. }
  500. //+---------------------------------------------------------------------------
  501. //
  502. // Member: CIpxConfigDlg::HandleFrameCombo
  503. //
  504. // Purpose:
  505. //
  506. // Parameters:
  507. //
  508. // Returns:
  509. //
  510. // Author: scottbri 28-Apr-1997
  511. //
  512. LRESULT CIpxConfigDlg::HandleFrameCombo(WORD wNotifyCode, WORD wID,
  513. HWND hWndCtl, BOOL& bHandled)
  514. {
  515. Assert(CMB_IPXPP_FRAMETYPE == wID);
  516. if (CBN_SELENDOK != wNotifyCode)
  517. {
  518. bHandled = FALSE;
  519. return 0L;
  520. }
  521. FrameTypeChanged();
  522. SetChangedFlag();
  523. bHandled = TRUE;
  524. return 0L;
  525. }
  526. //+---------------------------------------------------------------------------
  527. //
  528. // Member: CIpxASConfigDlg::CIpxASConfigDlg
  529. //
  530. // Purpose: ctor for the CIpxASConfigDlg class
  531. //
  532. // Parameters: none
  533. //
  534. // Returns: nothing
  535. //
  536. // Author: scottbri 28-Apr-1997
  537. //
  538. CIpxASConfigDlg::CIpxASConfigDlg(CNwlnkIPX *pmsc,
  539. CIpxEnviroment * pIpxEnviroment,
  540. CIpxAdapterInfo * pAI)
  541. {
  542. // Note these parameters are on loan, do not free them...
  543. Assert(NULL != pmsc);
  544. Assert(NULL != pIpxEnviroment);
  545. m_pmsc = pmsc;
  546. m_pIpxEnviroment = pIpxEnviroment;
  547. m_pAICurrent = pAI;
  548. m_nRadioBttn = 0;
  549. m_dwMediaType = ETHERNET_MEDIA;
  550. }
  551. //+---------------------------------------------------------------------------
  552. //
  553. // Member: CIpxASConfigDlg::~CIpxASConfigDlg
  554. //
  555. // Purpose: dtor for the CIpxASConfigDlg class
  556. //
  557. // Parameters: none
  558. //
  559. // Returns: nothing
  560. //
  561. // Author: scottbri 28-Apr-1997
  562. //
  563. CIpxASConfigDlg::~CIpxASConfigDlg()
  564. {
  565. DeleteColString(&m_lstpstrFrmType);
  566. DeleteColString(&m_lstpstrNetworkNum);
  567. m_pmsc = NULL;
  568. m_pIpxEnviroment = NULL;
  569. m_pAICurrent = NULL;
  570. }
  571. //+---------------------------------------------------------------------------
  572. //
  573. // Member: CIpxASConfigDlg::FIsNetNumberInUse
  574. //
  575. // Purpose: Compare a network number to those already in use.
  576. // Returning TRUE if the network number is already present.
  577. //
  578. // Parameters: dwFrameType - Frame Type as a DWORD
  579. // pszNetNum - Network number as a hex string
  580. //
  581. // Returns: BOOL, TRUE if the network number is already present, FALSE otherwise
  582. //
  583. // Author: scottbri 29-Apr-1997
  584. //
  585. BOOL CIpxASConfigDlg::FIsNetNumberInUse(DWORD dwFrameType, PCWSTR pszNetNum)
  586. {
  587. DWORD dwNetNum = DwFromSz(pszNetNum, 16);
  588. if (0 == dwNetNum)
  589. {
  590. return FALSE;
  591. }
  592. list<tstring *>::iterator iterFrmType = m_lstpstrFrmType.begin();
  593. list<tstring *>::iterator iterNetworkNum = m_lstpstrNetworkNum.begin();
  594. while (iterFrmType != m_lstpstrFrmType.end() &&
  595. iterNetworkNum != m_lstpstrNetworkNum.end())
  596. {
  597. tstring *pstr1 = *iterFrmType;
  598. tstring *pstr2 = *iterNetworkNum;
  599. if ((DwFromSz(pstr1->c_str(), 16) == dwFrameType) &&
  600. (DwFromSz(pstr2->c_str(),16) == dwNetNum))
  601. {
  602. return TRUE;
  603. }
  604. iterFrmType++;
  605. iterNetworkNum++;
  606. }
  607. return FALSE;
  608. }
  609. //+---------------------------------------------------------------------------
  610. //
  611. // Member: CIpxASConfigDlg::OnInitDialog
  612. //
  613. // Purpose: Called when this dialog is first brought up.
  614. //
  615. // Parameters:
  616. // uMsg [in]
  617. // wParam [in] See the ATL documentation for params.
  618. // lParam [in]
  619. // bHandled [in]
  620. //
  621. // Returns: See the ATL documentation for return results.
  622. //
  623. // Author: scottbri 11-Apr-1997
  624. //
  625. // Notes:
  626. //
  627. LRESULT CIpxASConfigDlg::OnInitDialog(UINT uMsg, WPARAM wParam,
  628. LPARAM lParam, BOOL& bHandled)
  629. {
  630. // Initialize the listview column headings
  631. int aIds[] = {IDS_IPXAS_FRAME_TYPE,IDS_IPXAS_NETWORK_NUM};
  632. HWND hwndTmp;
  633. int iCol;
  634. LV_COLUMN lvc;
  635. RECT rc;
  636. WCHAR szBuf[12];
  637. m_hwndLV = GetDlgItem(LVC_IPXAS_DEST);
  638. ::GetClientRect(m_hwndLV, &rc);
  639. lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
  640. lvc.fmt = LVCFMT_LEFT;
  641. lvc.cx = (rc.right - rc.left) / 2;
  642. UINT nIdx;
  643. int aIds2[] = {IDS_IPXPP_TEXT_1, IDS_IPXPP_TEXT_2};
  644. tstring strText;
  645. // Build the property page's informative text block
  646. for (nIdx=0; nIdx < celems(aIds2); nIdx++)
  647. {
  648. strText += SzLoadIds(aIds2[nIdx]);
  649. }
  650. ::SetWindowText(GetDlgItem(IDC_IPXPP_TEXT), strText.c_str());
  651. // Add columns
  652. for (iCol = 0; iCol < celems(aIds); iCol++)
  653. {
  654. lvc.iSubItem = iCol;
  655. lvc.pszText = (PWSTR)SzLoadIds(aIds[iCol]);
  656. if (ListView_InsertColumn(m_hwndLV, iCol, &lvc) == -1)
  657. return FALSE;
  658. }
  659. // Initialize the Internal Network Number Edit Control
  660. HexSzFromDw(szBuf, m_pIpxEnviroment->DwVirtualNetworkNumber());
  661. hwndTmp = GetDlgItem(EDT_IPXAS_INTERNAL);
  662. ::SetWindowText(hwndTmp,szBuf);
  663. // Subclass the edit control to allow only network number's
  664. ::SetWindowLongPtr(hwndTmp, GWLP_USERDATA, ::GetWindowLongPtr(hwndTmp, GWLP_WNDPROC));
  665. ::SetWindowLongPtr(hwndTmp, GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
  666. // Limit the text in the network # edit control
  667. ::SendMessage(hwndTmp, EM_LIMITTEXT, MAX_NETNUM_SIZE, 0L);
  668. // Initialize the rest of the Server's General page
  669. InitGeneralPage();
  670. UpdateButtons();
  671. return FALSE;
  672. }
  673. //+---------------------------------------------------------------------------
  674. //
  675. // Member: CIpxASConfigDlg::UpdateButtons
  676. //
  677. // Purpose: Update the button settings on the server's IPX general page
  678. //
  679. // Parameters: none
  680. //
  681. // Returns: nothing
  682. //
  683. // Author: scottbri 28-Apr-1997
  684. //
  685. void CIpxASConfigDlg::UpdateButtons()
  686. {
  687. INT nCount = ListView_GetItemCount(m_hwndLV);
  688. HWND hwndEdit = GetDlgItem(BTN_IPXAS_EDIT);
  689. HWND hwndRemove = GetDlgItem(BTN_IPXAS_REMOVE);
  690. HWND hwndAdd = GetDlgItem(BTN_IPXAS_ADD);
  691. BOOL fEnableAdd = FALSE;
  692. BOOL fEnableEditRemove = TRUE;
  693. Assert(NULL != m_hwndLV);
  694. if ((0 == nCount) || !IsDlgButtonChecked(BTN_IPXAS_MANUAL))
  695. {
  696. fEnableEditRemove = FALSE;
  697. }
  698. ::EnableWindow(hwndRemove, fEnableEditRemove);
  699. ::EnableWindow(hwndEdit, fEnableEditRemove);
  700. if (NULL != m_pAICurrent)
  701. {
  702. fEnableAdd = !(nCount >= DetermineMaxNumFrames());
  703. }
  704. if (!IsDlgButtonChecked(BTN_IPXAS_MANUAL))
  705. {
  706. fEnableAdd = FALSE;
  707. }
  708. ::EnableWindow(hwndAdd, fEnableAdd);
  709. }
  710. //+---------------------------------------------------------------------------
  711. //
  712. // Member: CIpxASConfigDlg::DetermineMaxNumFrames
  713. //
  714. // Purpose: Return the max number of frames allowed for a give adapter
  715. // based on that adapters media type.
  716. //
  717. // Parameters: none
  718. //
  719. // Returns: nothing
  720. //
  721. // Author: scottbri 28-Apr-1997
  722. //
  723. int CIpxASConfigDlg::DetermineMaxNumFrames()
  724. {
  725. int n;
  726. if (NULL == m_pAICurrent)
  727. return 0;
  728. switch(m_dwMediaType)
  729. {
  730. case FDDI_MEDIA:
  731. n = 3;
  732. break;
  733. case TOKEN_MEDIA:
  734. n = 2;
  735. break;
  736. case ARCNET_MEDIA:
  737. n = 1;
  738. break;
  739. default:
  740. n = 4;
  741. break;
  742. }
  743. return n;
  744. }
  745. //+---------------------------------------------------------------------------
  746. //
  747. // Member: CIpxASConfigDlg::InitGeneralPage
  748. //
  749. // Purpose: Initialize the Server's IPX general page
  750. //
  751. // Parameters: none
  752. //
  753. // Returns: nothing
  754. //
  755. // Author: scottbri 28-Apr-1997
  756. //
  757. void CIpxASConfigDlg::InitGeneralPage()
  758. {
  759. // Populate the adapter list
  760. int nIdx;
  761. // Copy the adapter list info to a local structure
  762. // to allow user manipulation
  763. if (NULL != m_pAICurrent)
  764. {
  765. Assert(!m_pAICurrent->FDeletePending());
  766. Assert(!m_pAICurrent->FDisabled());
  767. Assert(!m_pAICurrent->FHidden());
  768. // Move the Adapter Info to the dialog's internal form
  769. m_dwMediaType = m_pAICurrent->DwMediaType();
  770. // Frame Type lists contain one of two possible values
  771. // 1) One AUTO entry
  772. // 2) One or more non-AUTO frame types
  773. //
  774. // If the first is not AUTO, then copy the frame and network number
  775. // pairs. Otherwise, leave the local lists empty
  776. DWORD dw = DwFromLstPtstring(m_pAICurrent->m_lstpstrFrmType, c_dwPktTypeDefault, 16);
  777. if (AUTO != dw)
  778. {
  779. list<tstring*>::iterator iterFrmType;
  780. list<tstring*>::iterator iterNetworkNum;
  781. m_nRadioBttn = BTN_IPXAS_MANUAL;
  782. // Make an internal copy of the adapter's frame type and
  783. // Network number information
  784. for (iterFrmType = m_pAICurrent->m_lstpstrFrmType.begin(),
  785. iterNetworkNum = m_pAICurrent->m_lstpstrNetworkNum.begin();
  786. iterFrmType != m_pAICurrent->m_lstpstrFrmType.end(),
  787. iterNetworkNum != m_pAICurrent->m_lstpstrNetworkNum.end();
  788. iterFrmType++, iterNetworkNum++)
  789. {
  790. // Copy the Frame Type
  791. tstring *pstr1 = *iterFrmType;
  792. m_lstpstrFrmType.push_back(new tstring(pstr1->c_str()));
  793. // Copy the Network number
  794. tstring *pstr2 = *iterNetworkNum;
  795. m_lstpstrNetworkNum.push_back(new tstring(pstr2->c_str()));
  796. }
  797. }
  798. else
  799. {
  800. m_nRadioBttn = BTN_IPXAS_AUTO;
  801. }
  802. // Update the UI to reflect the currently selected adapter
  803. UpdateRadioButtons();
  804. HrUpdateListView();
  805. UpdateButtons();
  806. }
  807. else
  808. {
  809. // No adapters installed, disable the dialog sensibly
  810. //
  811. ::EnableWindow(GetDlgItem(BTN_IPXAS_MANUAL), FALSE);
  812. ::EnableWindow(GetDlgItem(BTN_IPXAS_ADD), FALSE);
  813. }
  814. }
  815. //+---------------------------------------------------------------------------
  816. //
  817. // Member: CIpxASConfigDlg::HrAddItemToList
  818. //
  819. // Purpose: Add a row to the list view
  820. //
  821. // Parameters: idsFrameName - ie ARCNET, Ethernet II, etc
  822. // pszNetNum - Network number as a hex string
  823. //
  824. // Returns: HRESULT, S_OK if everything was added correctly
  825. //
  826. // Author: scottbri 29-Apr-1997
  827. //
  828. HRESULT CIpxASConfigDlg::HrAddItemToList(int idsFrameName, PCWSTR pszNetNum)
  829. {
  830. int nIdx;
  831. LV_ITEM lvi;
  832. int nCount = ListView_GetItemCount(m_hwndLV);
  833. // Add the item info to the list view
  834. lvi.mask = LVIF_TEXT | LVIF_PARAM;
  835. lvi.iItem = nCount;
  836. lvi.iSubItem = 0;
  837. lvi.state = 0;
  838. lvi.stateMask = 0;
  839. lvi.pszText = (PWSTR)SzLoadIds(idsFrameName);
  840. lvi.cchTextMax = lstrlenW(lvi.pszText);
  841. lvi.iImage = 0;
  842. lvi.lParam = idsFrameName;
  843. nIdx = ListView_InsertItem(m_hwndLV, &lvi);
  844. if (-1 == nIdx)
  845. {
  846. return E_OUTOFMEMORY;
  847. }
  848. Assert(lvi.iItem == nIdx);
  849. lvi.mask = LVIF_TEXT;
  850. lvi.iSubItem = 1;
  851. lvi.pszText = (PWSTR)pszNetNum;
  852. lvi.cchTextMax = lstrlenW(lvi.pszText);
  853. if (FALSE == ListView_SetItem(m_hwndLV, &lvi))
  854. {
  855. return E_OUTOFMEMORY;
  856. }
  857. return S_OK;
  858. }
  859. //+---------------------------------------------------------------------------
  860. //
  861. // Member: CIpxASConfigDlg::HrUpdateListView
  862. //
  863. // Purpose: Update the contents of the listview
  864. //
  865. // Parameters: none
  866. //
  867. // Returns: HRESULT, S_OK if everything was added correctly
  868. //
  869. // Author: scottbri 29-Apr-1997
  870. //
  871. HRESULT CIpxASConfigDlg::HrUpdateListView()
  872. {
  873. HRESULT hr = S_OK;
  874. Assert(NULL != m_pAICurrent);
  875. int nSize = m_lstpstrFrmType.size();
  876. if (0 == nSize)
  877. return S_OK;
  878. // The list view is expected to be empty when this function is called
  879. Assert(0 == ListView_GetItemCount(m_hwndLV));
  880. // For efficency tell the list view how many items we're adding
  881. ListView_SetItemCount(m_hwndLV, nSize);
  882. // Enumerate the frame type/network number pairs use that data to
  883. // populate the list view
  884. list<tstring *>::iterator iterFrmType = m_lstpstrFrmType.begin();
  885. list<tstring *>::iterator iterNetworkNum = m_lstpstrNetworkNum.begin();
  886. while (iterFrmType != m_lstpstrFrmType.end() &&
  887. iterNetworkNum != m_lstpstrNetworkNum.end())
  888. {
  889. tstring *pstr1 = *iterFrmType;
  890. tstring *pstr2 = *iterNetworkNum;
  891. DWORD dwFrameType = DwFromSz(pstr1->c_str(), 16);
  892. if (F802_2 == dwFrameType)
  893. {
  894. switch (m_dwMediaType)
  895. {
  896. case TOKEN_MEDIA:
  897. hr = HrAddItemToList(IDS_TK, pstr2->c_str());
  898. break;
  899. case FDDI_MEDIA:
  900. hr = HrAddItemToList(IDS_FDDI, pstr2->c_str());
  901. break;
  902. case ARCNET_MEDIA:
  903. hr = HrAddItemToList(IDS_ARCNET, pstr2->c_str());
  904. break;
  905. default:
  906. hr = HrAddItemToList(IDS_802_2, pstr2->c_str());
  907. break;
  908. }
  909. }
  910. else if (ETHERNET == dwFrameType)
  911. {
  912. hr = HrAddItemToList(IDS_ETHERNET, pstr2->c_str());
  913. }
  914. else if (F802_3 == dwFrameType)
  915. {
  916. switch (m_dwMediaType)
  917. {
  918. case FDDI_MEDIA:
  919. hr = HrAddItemToList(IDS_FDDI_802_3, pstr2->c_str());
  920. break;
  921. default:
  922. hr = HrAddItemToList(IDS_802_3, pstr2->c_str());
  923. break;
  924. }
  925. }
  926. else if (SNAP == dwFrameType)
  927. {
  928. switch (m_dwMediaType)
  929. {
  930. case TOKEN_MEDIA:
  931. hr = HrAddItemToList(IDS_802_5, pstr2->c_str());
  932. break;
  933. case FDDI_MEDIA:
  934. hr = HrAddItemToList(IDS_SNAP, pstr2->c_str());
  935. break;
  936. default:
  937. hr = HrAddItemToList(IDS_SNAP, pstr2->c_str());
  938. break;
  939. }
  940. }
  941. else
  942. {
  943. Assert(ARCNET == dwFrameType);
  944. hr = HrAddItemToList(IDS_ARCNET, pstr2->c_str());
  945. }
  946. // Was the network number already present in the list?
  947. if (S_FALSE == hr)
  948. {
  949. // Remove the duplicate network number and frame
  950. // Note that this usage of erase correctly advances both iterators
  951. delete pstr1;
  952. delete pstr2;
  953. iterFrmType = m_lstpstrFrmType.erase(iterFrmType);
  954. iterNetworkNum = m_lstpstrNetworkNum.erase(iterNetworkNum);
  955. hr = S_OK; // Normalize return
  956. }
  957. else if (FAILED(hr))
  958. {
  959. break;
  960. }
  961. else
  962. {
  963. Assert(SUCCEEDED(hr));
  964. // Advance the iterators
  965. iterFrmType++;
  966. iterNetworkNum++;
  967. }
  968. }
  969. // Select the first item in the list
  970. ListView_SetItemState(m_hwndLV, 0, LVIS_SELECTED, LVIS_SELECTED);
  971. return hr;
  972. }
  973. //+---------------------------------------------------------------------------
  974. //
  975. // Member: CIpxASConfigDlg::HandleRadioButton
  976. //
  977. // Purpose: React to changes to the dialog's radio buttons
  978. //
  979. // Parameters: Std ATL handler params
  980. //
  981. // Returns: LRESULT
  982. //
  983. // Author: scottbri 21-Aug-1997
  984. //
  985. LRESULT CIpxASConfigDlg::HandleRadioButton(WORD wNotifyCode, WORD wID,
  986. HWND hWndCtl, BOOL& bHandled)
  987. {
  988. bHandled = FALSE;
  989. if ((wNotifyCode != BN_CLICKED) || (NULL == m_pAICurrent))
  990. return 0;
  991. SetChangedFlag();
  992. Assert((BTN_IPXAS_AUTO==wID) || (BTN_IPXAS_MANUAL==wID));
  993. m_nRadioBttn = wID;
  994. UpdateButtons();
  995. bHandled = TRUE;
  996. return 0;
  997. }
  998. //+---------------------------------------------------------------------------
  999. //
  1000. // Member: CIpxASConfigDlg::UpdateRadioButtons
  1001. //
  1002. // Purpose: Update the radio button settings based on the selected adapter
  1003. //
  1004. // Parameters: none
  1005. //
  1006. // Returns: nothing
  1007. //
  1008. // Author: scottbri 29-Apr-1997
  1009. //
  1010. void CIpxASConfigDlg::UpdateRadioButtons()
  1011. {
  1012. DWORD dw;
  1013. if (NULL == m_pAICurrent)
  1014. {
  1015. return;
  1016. }
  1017. if (0 == m_nRadioBttn)
  1018. {
  1019. m_nRadioBttn = BTN_IPXAS_AUTO;
  1020. }
  1021. CheckRadioButton(BTN_IPXAS_AUTO, BTN_IPXAS_MANUAL, m_nRadioBttn);
  1022. }
  1023. //+---------------------------------------------------------------------------
  1024. //
  1025. // Member: CIpxASConfigDlg::OnOk
  1026. //
  1027. // Purpose: Called when the OK button is pressed.
  1028. //
  1029. // Parameters:
  1030. // idCtrl [in]
  1031. // pnmh [in] See the ATL documentation for params.
  1032. // bHandled [in]
  1033. //
  1034. // Returns: See the ATL documentation for return results.
  1035. //
  1036. // Author: scottbri 11-Apr-1997
  1037. //
  1038. // Notes:
  1039. //
  1040. LRESULT CIpxASConfigDlg::OnOk(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  1041. {
  1042. HRESULT hr = S_OK;
  1043. WCHAR szBuf[12];
  1044. HWND hwndEdit = GetDlgItem(EDT_IPXAS_INTERNAL);
  1045. ::GetWindowText(hwndEdit,szBuf,sizeof(szBuf)/sizeof(WCHAR));
  1046. if (0 == lstrlenW(szBuf))
  1047. {
  1048. NcMsgBox(m_hWnd, IDS_MANUAL_FRAME_DETECT, IDS_INCORRECT_NETNUM, MB_OK | MB_ICONEXCLAMATION);
  1049. ::SetFocus(hwndEdit);
  1050. ::SetWindowLongPtr(m_hWnd, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
  1051. return TRUE;
  1052. }
  1053. // Update the virtual network number
  1054. m_pIpxEnviroment->SetVirtualNetworkNumber(DwFromSz(szBuf, 16));
  1055. // Rewrite the local versions of the frame type and Network Numbers
  1056. if (NULL != m_pAICurrent)
  1057. {
  1058. m_pAICurrent->SetDirty(TRUE);
  1059. // First empty the respective destination lists...
  1060. Assert(NULL != m_pAICurrent);
  1061. DeleteColString(&m_pAICurrent->m_lstpstrFrmType);
  1062. DeleteColString(&m_pAICurrent->m_lstpstrNetworkNum);
  1063. // When the listbox is empty we're in AUTO mode
  1064. if (0 == ListView_GetItemCount(m_hwndLV))
  1065. {
  1066. m_nRadioBttn = BTN_IPXAS_AUTO;
  1067. CheckRadioButton(BTN_IPXAS_AUTO, BTN_IPXAS_MANUAL, m_nRadioBttn);
  1068. }
  1069. // Only transfer the Frame Type/Network Number information if manual
  1070. // frame type detection was requested.
  1071. if (BTN_IPXAS_MANUAL == m_nRadioBttn)
  1072. {
  1073. // Then create new destination lists from the local data
  1074. list<tstring *>::iterator iterFrmType = m_lstpstrFrmType.begin();
  1075. list<tstring *>::iterator iterNetworkNum = m_lstpstrNetworkNum.begin();
  1076. for (;iterFrmType != m_lstpstrFrmType.end(),
  1077. iterNetworkNum != m_lstpstrNetworkNum.end();
  1078. iterFrmType++,
  1079. iterNetworkNum++)
  1080. {
  1081. tstring *pstr1 = *iterFrmType;
  1082. tstring *pstr2 = *iterNetworkNum;
  1083. m_pAICurrent->m_lstpstrFrmType.push_back(new tstring(pstr1->c_str()));
  1084. m_pAICurrent->m_lstpstrNetworkNum.push_back(new tstring(pstr2->c_str()));
  1085. }
  1086. }
  1087. Assert(m_pAICurrent->m_lstpstrFrmType.size() == m_pAICurrent->m_lstpstrNetworkNum.size());
  1088. // If the destination lists end up empty, supply default values
  1089. if (0 == m_pAICurrent->m_lstpstrFrmType.size())
  1090. {
  1091. WCHAR szBuf[12];
  1092. HexSzFromDw(szBuf, c_dwPktTypeDefault);
  1093. m_pAICurrent->m_lstpstrFrmType.push_back(new tstring(szBuf));
  1094. m_pAICurrent->m_lstpstrNetworkNum.push_back(new tstring(c_sz8Zeros));
  1095. }
  1096. }
  1097. TraceError("CIpxASConfigDlg::OnOk", hr);
  1098. return LresFromHr(hr);
  1099. }
  1100. //+---------------------------------------------------------------------------
  1101. //
  1102. // Member: CIpxASConfigDlg::OnContextMenu
  1103. //
  1104. // Purpose: Context sensitive help support.
  1105. //
  1106. // Author: jeffspr 13 Apr 1999
  1107. //
  1108. // Notes:
  1109. //
  1110. LRESULT CIpxASConfigDlg::OnContextMenu(UINT uMsg, WPARAM wParam,
  1111. LPARAM lParam, BOOL& fHandled)
  1112. {
  1113. return CommonIPXOnContextMenu(m_hWnd, g_aHelpIDs_DLG_IPXAS_CONFIG);
  1114. }
  1115. //+---------------------------------------------------------------------------
  1116. //
  1117. // Member: CIpxASConfigDlg::OnHelp
  1118. //
  1119. // Purpose: Context sensitive help support.
  1120. //
  1121. // Author: jeffspr 13 Apr 1999
  1122. //
  1123. // Notes:
  1124. //
  1125. LRESULT CIpxASConfigDlg::OnHelp(UINT uMsg, WPARAM wParam,
  1126. LPARAM lParam, BOOL& fHandled)
  1127. {
  1128. return ::CommonIPXOnHelp(lParam, g_aHelpIDs_DLG_IPXAS_CONFIG);
  1129. }
  1130. //+---------------------------------------------------------------------------
  1131. //
  1132. // Member: CIpxASConfigDlg::OnAdd
  1133. //
  1134. // Purpose: Called when the Add button is pressed. Used to add additional
  1135. // frame type/network number pairs
  1136. //
  1137. // Parameters:
  1138. // wNotifyCode [in]
  1139. // wID [in]
  1140. // pnmh [in] See the ATL documentation for params.
  1141. // bHandled [in]
  1142. //
  1143. // Returns: See the ATL documentation for return results.
  1144. //
  1145. // Author: scottbri 29-Apr-1997
  1146. //
  1147. LRESULT CIpxASConfigDlg::OnAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1148. {
  1149. CASAddDialog * pdlg;
  1150. if (NULL == m_pAICurrent)
  1151. return 0;
  1152. SetChangedFlag();
  1153. // Bring up the dialog
  1154. pdlg = new CASAddDialog(this, m_hwndLV, m_dwMediaType,
  1155. c_dwPktTypeDefault, c_sz8Zeros);
  1156. if (pdlg == NULL)
  1157. {
  1158. return(ERROR_NOT_ENOUGH_MEMORY);
  1159. }
  1160. if (pdlg->DoModal(m_hWnd) == IDOK)
  1161. {
  1162. // Update the internal structures and the dialog with the returned values
  1163. if (S_OK == HrAddItemToList(pdlg->IdsGetFrameType(), pdlg->SzGetNetworkNumber()))
  1164. {
  1165. // Validated above, so add to the internal list
  1166. WCHAR szBuf[12];
  1167. HexSzFromDw(szBuf,pdlg->DwGetFrameType());
  1168. m_lstpstrFrmType.push_back(new tstring(szBuf));
  1169. m_lstpstrNetworkNum.push_back(new tstring(pdlg->SzGetNetworkNumber()));
  1170. // Select the new item
  1171. int nCount = ListView_GetItemCount(m_hwndLV);
  1172. Assert(0 < nCount);
  1173. ListView_SetItemState(m_hwndLV, nCount-1, LVIS_SELECTED, LVIS_SELECTED);
  1174. // Update the state of the Add, Edit, and Remove buttons
  1175. HWND hwndFocus = GetFocus();
  1176. UpdateButtons();
  1177. if (!::IsWindowEnabled(hwndFocus))
  1178. {
  1179. ::SetFocus(GetDlgItem(BTN_IPXAS_EDIT));
  1180. }
  1181. }
  1182. }
  1183. delete pdlg;
  1184. return 0;
  1185. }
  1186. LRESULT CIpxASConfigDlg::HandleInternalNetworkNumber(
  1187. WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1188. {
  1189. if (EN_CHANGE == wNotifyCode)
  1190. {
  1191. SetChangedFlag();
  1192. }
  1193. return 0;
  1194. }
  1195. //+---------------------------------------------------------------------------
  1196. //
  1197. // Member: CIpxASConfigDlg::OnEdit
  1198. //
  1199. // Purpose: Called when the Edit button is pressed. Used to edit a
  1200. // Frame Type/Network number pair
  1201. //
  1202. // Parameters:
  1203. // wNotifyCode [in]
  1204. // wID [in]
  1205. // pnmh [in] See the ATL documentation for params.
  1206. // bHandled [in]
  1207. //
  1208. // Returns: See the ATL documentation for return results.
  1209. //
  1210. // Author: scottbri 29-Apr-1997
  1211. //
  1212. LRESULT CIpxASConfigDlg::OnEdit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1213. {
  1214. int nIdx = 0;
  1215. int nIdxSelected;
  1216. // Locate the selected row in the listview
  1217. if (FALSE == FGetSelectedRowIdx(&nIdxSelected))
  1218. return 0;
  1219. if (NULL == m_pAICurrent)
  1220. return 0;
  1221. SetChangedFlag();
  1222. // Enumerate the internal data to locate the frame type/network number for
  1223. // the selection
  1224. list<tstring *>::iterator iterFrmType = m_lstpstrFrmType.begin();
  1225. list<tstring *>::iterator iterNetworkNum = m_lstpstrNetworkNum.begin();
  1226. while ((iterFrmType != m_lstpstrFrmType.end()) &&
  1227. (iterNetworkNum != m_lstpstrNetworkNum.end()))
  1228. {
  1229. if (nIdx == nIdxSelected)
  1230. {
  1231. tstring *pstr1 = *iterNetworkNum;
  1232. tstring *pstr2 = *iterFrmType;
  1233. // Create the dialog
  1234. CASEditDialog * pdlg = new CASEditDialog(this, m_hwndLV,
  1235. DwFromSz(pstr2->c_str(), 16),
  1236. pstr1->c_str());
  1237. if (pdlg->DoModal(m_hWnd) == IDOK)
  1238. {
  1239. LV_ITEM lvi;
  1240. // Apply the dialog changes to the ListView Control
  1241. ZeroMemory(&lvi, sizeof(lvi));
  1242. lvi.mask = LVIF_TEXT;
  1243. lvi.iItem = nIdxSelected;
  1244. lvi.iSubItem = 1;
  1245. lvi.pszText = (PWSTR)pdlg->SzGetNetworkNumber();
  1246. ListView_SetItem(m_hwndLV, &lvi);
  1247. // Apply the changes to the local data
  1248. *(*iterNetworkNum) = pdlg->SzGetNetworkNumber();
  1249. }
  1250. delete pdlg;
  1251. break;
  1252. }
  1253. nIdx++;
  1254. iterFrmType++;
  1255. iterNetworkNum++;
  1256. }
  1257. return 0;
  1258. }
  1259. //+---------------------------------------------------------------------------
  1260. //
  1261. // Member: CIpxASConfigDlg::FGetSelectedRowIdx
  1262. //
  1263. // Purpose: Returns the index of the selected row in the listview, if it exists
  1264. //
  1265. // Parameters: pnIdx [out] - The selected row's zero based index
  1266. //
  1267. // Returns: BOOL, TRUE if a selected row exists, FALSE otherwise
  1268. //
  1269. BOOL CIpxASConfigDlg::FGetSelectedRowIdx(int *pnIdx)
  1270. {
  1271. int nCount = ListView_GetItemCount(m_hwndLV);
  1272. int nIdx;
  1273. LV_ITEM lvi;
  1274. lvi.mask = LVIF_STATE;
  1275. lvi.iSubItem = 0;
  1276. lvi.stateMask = LVIS_SELECTED;
  1277. // Determine the selected pair
  1278. for (nIdx = 0; nIdx < nCount; nIdx++)
  1279. {
  1280. lvi.iItem = nIdx;
  1281. if ((TRUE == ListView_GetItem(m_hwndLV, &lvi)) &&
  1282. (lvi.state & LVIS_SELECTED))
  1283. {
  1284. // Located the selected Item
  1285. *pnIdx = nIdx;
  1286. return TRUE;
  1287. }
  1288. }
  1289. *pnIdx = 0;
  1290. return FALSE;
  1291. }
  1292. //+---------------------------------------------------------------------------
  1293. //
  1294. // Member: CIpxASConfigDlg::OnRemove
  1295. //
  1296. // Purpose: Called when the Remove button is pressed. Used to remove a
  1297. // Frame Type/Network Number pair.
  1298. //
  1299. // Parameters:
  1300. // wNotifyCode [in]
  1301. // wID [in]
  1302. // pnmh [in] See the ATL documentation for params.
  1303. // bHandled [in]
  1304. //
  1305. // Returns: See the ATL documentation for return results.
  1306. //
  1307. // Author: scottbri 29-Apr-1997
  1308. //
  1309. LRESULT
  1310. CIpxASConfigDlg::OnRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1311. {
  1312. int nCount;
  1313. int nIdx = 0;
  1314. int nIdxSelected;
  1315. #ifdef DBG
  1316. BOOL fFound = FALSE;
  1317. #endif
  1318. // Locate the selected row in the listview
  1319. if (FALSE == FGetSelectedRowIdx(&nIdxSelected))
  1320. return 0;
  1321. if (NULL == m_pAICurrent)
  1322. return 0;
  1323. SetChangedFlag();
  1324. // Remove the row from the internal local representation and listview
  1325. list<tstring *>::iterator iterFrmType = m_lstpstrFrmType.begin();
  1326. list<tstring *>::iterator iterNetworkNum = m_lstpstrNetworkNum.begin();
  1327. while ((iterFrmType != m_lstpstrFrmType.end()) &&
  1328. (iterNetworkNum != m_lstpstrNetworkNum.end()))
  1329. {
  1330. if (nIdx == nIdxSelected)
  1331. {
  1332. #ifdef DBG
  1333. fFound = TRUE;
  1334. #endif
  1335. // Remove and free the Frame Type piece
  1336. tstring *pstr = *iterFrmType;
  1337. m_lstpstrFrmType.erase(iterFrmType);
  1338. delete pstr;
  1339. // Remove and free the Network Number piece
  1340. pstr = *iterNetworkNum;
  1341. m_lstpstrNetworkNum.erase(iterNetworkNum);
  1342. delete pstr;
  1343. // We're done...
  1344. break;
  1345. }
  1346. nIdx++;
  1347. iterFrmType++;
  1348. iterNetworkNum++;
  1349. }
  1350. #ifdef DBG
  1351. Assert(TRUE == fFound);
  1352. #endif
  1353. // Remove the frame type/network number pair from the list view
  1354. ListView_DeleteItem(m_hwndLV, nIdxSelected);
  1355. nCount = ListView_GetItemCount(m_hwndLV);
  1356. if (nCount <= nIdxSelected)
  1357. {
  1358. nIdxSelected = nCount - 1;
  1359. }
  1360. if (0 <= nIdxSelected)
  1361. {
  1362. ListView_SetItemState(m_hwndLV, nIdxSelected, LVIS_SELECTED, LVIS_SELECTED);
  1363. }
  1364. // Update the state of the Add, Edit, and Remove buttons
  1365. HWND hwndFocus = GetFocus();
  1366. UpdateButtons();
  1367. if (!::IsWindowEnabled(hwndFocus))
  1368. {
  1369. ::SetFocus(GetDlgItem(BTN_IPXAS_ADD));
  1370. }
  1371. return 0;
  1372. }
  1373. #ifdef INCLUDE_RIP_ROUTING
  1374. //+---------------------------------------------------------------------------
  1375. //
  1376. // Member: CIpxASInternalDlg::CIpxASInternalDlg
  1377. //
  1378. // Purpose: ctor for the CIpxASInternalDlg class
  1379. //
  1380. // Parameters: none
  1381. //
  1382. // Returns: nothing
  1383. //
  1384. // Author: scottbri 29-Apr-1997
  1385. //
  1386. CIpxASInternalDlg::CIpxASInternalDlg(CNwlnkIPX *pmsc,
  1387. CIpxEnviroment * pIpxEnviroment)
  1388. {
  1389. // Note these parameters are on loan, do not free them...
  1390. Assert(NULL != pmsc);
  1391. Assert(NULL != pIpxEnviroment);
  1392. m_pmsc = pmsc;
  1393. m_pIpxEnviroment = pIpxEnviroment;
  1394. m_dwRipValue = 0;
  1395. }
  1396. //+---------------------------------------------------------------------------
  1397. //
  1398. // Member: CIpxASInternalDlg::OnInitDialog
  1399. //
  1400. // Purpose:
  1401. //
  1402. // Parameters:
  1403. // wNotifyCode [in]
  1404. // wID [in]
  1405. // pnmh [in] See the ATL documentation for params.
  1406. // bHandled [in]
  1407. //
  1408. // Returns: See the ATL documentation for return results.
  1409. //
  1410. LRESULT
  1411. CIpxASInternalDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled)
  1412. {
  1413. ::EnableWindow(GetDlgItem(BTN_IPXAS_RIP), m_pIpxEnviroment->FRipEnabled());
  1414. CheckDlgButton(BTN_IPXAS_RIP, m_pIpxEnviroment->FRipEnabled());
  1415. return 0;
  1416. }
  1417. //+---------------------------------------------------------------------------
  1418. //
  1419. // Member: CIpxASInternalDlg::OnRip
  1420. //
  1421. // Purpose: Handle changes to the Rip check box on the routing page
  1422. //
  1423. // Parameters:
  1424. // wNotifyCode [in]
  1425. // wID [in]
  1426. // pnmh [in] See the ATL documentation for params.
  1427. // bHandled [in]
  1428. //
  1429. // Returns: See the ATL documentation for return results.
  1430. //
  1431. LRESULT
  1432. CIpxASInternalDlg::OnRip(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  1433. {
  1434. if (BN_CLICKED != wNotifyCode)
  1435. {
  1436. bHandled = FALSE;
  1437. return 0L;
  1438. }
  1439. if (!m_pIpxEnviroment->FRipInstalled())
  1440. {
  1441. // Don't allow the user to check this box, if rip isn't installed
  1442. if (IsDlgButtonChecked(BTN_IPXAS_RIP))
  1443. CheckDlgButton(BTN_IPXAS_RIP, FALSE);
  1444. // Tell the user they must install RIP first
  1445. //$ REVIEW - Post Beta 1, this should trigger Rip Installation
  1446. NcMsgBox(m_hWnd, IDS_ROUTING, IDS_INSTALL_RIP,
  1447. MB_OK | MB_ICONEXCLAMATION);
  1448. }
  1449. else
  1450. {
  1451. m_dwRipValue = 0;
  1452. // Ask the user if they want type 20 broadcast enabled
  1453. if (!m_pIpxEnviroment->FRipInstalled())
  1454. {
  1455. if (IDYES == NcMsgBox(m_hWnd, IDS_ROUTING, IDS_NETBIOS_BROADCAST,
  1456. MB_YESNO | MB_ICONQUESTION))
  1457. m_dwRipValue = 1;
  1458. }
  1459. }
  1460. return 0L;
  1461. }
  1462. //+---------------------------------------------------------------------------
  1463. //
  1464. // Member: CIpxASInternalDlg::OnOk
  1465. //
  1466. // Purpose: Called when the OK button is pressed.
  1467. //
  1468. // Parameters:
  1469. // idCtrl [in]
  1470. // pnmh [in] See the ATL documentation for params.
  1471. // bHandled [in]
  1472. //
  1473. // Returns: See the ATL documentation for return results.
  1474. //
  1475. // Author: scottbri 29-Apr-1997
  1476. //
  1477. LRESULT CIpxASInternalDlg::OnOk(int idCtrl, LPNMHDR pnmh, BOOL& bHandled)
  1478. {
  1479. HRESULT hr = S_OK;
  1480. // Was the RIP checkbox changed?
  1481. if (IsDlgButtonChecked(BTN_IPXAS_RIP) != m_pIpxEnviroment->FRipEnabled())
  1482. {
  1483. m_pIpxEnviroment->ChangeRipEnabling(IsDlgButtonChecked(BTN_IPXAS_RIP),
  1484. m_dwRipValue);
  1485. }
  1486. TraceError("CIpxASInternalDlg::OnOk", hr);
  1487. return LresFromHr(hr);
  1488. }
  1489. //+---------------------------------------------------------------------------
  1490. //
  1491. // Member: CIpxASInternalDlg::OnContextMenu
  1492. //
  1493. // Purpose: Context sensitive help support.
  1494. //
  1495. // Author: jeffspr 13 Apr 1999
  1496. //
  1497. // Notes:
  1498. //
  1499. LRESULT CIpxASInternalDlg::OnContextMenu(UINT uMsg, WPARAM wParam,
  1500. LPARAM lParam, BOOL& fHandled)
  1501. {
  1502. return ::CommonIPXOnContextMenu(m_hWnd, g_aHelpIDs_DLG_IPXAS_INTERNAL);
  1503. }
  1504. //+---------------------------------------------------------------------------
  1505. //
  1506. // Member: CIpxASInternalDlg::OnHelp
  1507. //
  1508. // Purpose: Context sensitive help support.
  1509. //
  1510. // Author: jeffspr 13 Apr 1999
  1511. //
  1512. // Notes:
  1513. //
  1514. LRESULT CIpxASInternalDlg::OnHelp(UINT uMsg, WPARAM wParam,
  1515. LPARAM lParam, BOOL& fHandled)
  1516. {
  1517. return ::CommonIPXOnHelp(lParam, g_aHelpIDs_DLG_IPXAS_INTERNAL);
  1518. }
  1519. #endif // INCLUDE_RIP_ROUTING
  1520. //+---------------------------------------------------------------------------
  1521. //
  1522. // Function: CenterChildOverListView
  1523. //
  1524. // Purpose: Center the specified top level window over the listview
  1525. // control of the parent dialog
  1526. //
  1527. // Parameters: hwnd - Dialog to center
  1528. //
  1529. // Returns: nothing
  1530. //
  1531. void CenterChildOverListView(HWND hwnd, HWND hwndLV)
  1532. {
  1533. RECT rc;
  1534. ::GetWindowRect(hwndLV, &rc);
  1535. ::SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0,
  1536. SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE);
  1537. }
  1538. //+---------------------------------------------------------------------------
  1539. //
  1540. // Member: CASAddDialog::CASAddDialog
  1541. //
  1542. // Purpose: ctor for the CASAddDialog class
  1543. //
  1544. // Parameters: dwMediaType -
  1545. // dwFrameType -
  1546. // szNetworkNumber -
  1547. //
  1548. // Returns: nothing
  1549. //
  1550. CASAddDialog::CASAddDialog(CIpxASConfigDlg * pASCD, HWND hwndLV,
  1551. DWORD dwMediaType, DWORD dwFrameType,
  1552. PCWSTR pszNetworkNum) :
  1553. m_strNetworkNumber(pszNetworkNum)
  1554. {
  1555. m_pASCD = pASCD; // Borrowed pointer
  1556. m_hwndLV = hwndLV;
  1557. m_dwMediaType = dwMediaType;
  1558. m_dwFrameType = dwFrameType;
  1559. m_idsFrameType = 0; // Out param
  1560. }
  1561. //+---------------------------------------------------------------------------
  1562. //
  1563. // Member: CASAddDialog::OnInitDialog
  1564. //
  1565. // Purpose:
  1566. //
  1567. // Parameters:
  1568. // wNotifyCode [in]
  1569. // wID [in]
  1570. // pnmh [in] See the ATL documentation for params.
  1571. // bHandled [in]
  1572. //
  1573. // Returns: See the ATL documentation for return results.
  1574. //
  1575. LRESULT
  1576. CASAddDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled)
  1577. {
  1578. Assert(NULL != m_hwndLV);
  1579. HWND hwndCBM = GetDlgItem(CMB_IPXAS_DEST);
  1580. HWND hwndEdit = GetDlgItem(EDT_IPXAS_NETNUM);
  1581. // Search for the set of frames matching this adapter's media type
  1582. for (int idxMM=0; idxMM < celems(MediaMap); idxMM++)
  1583. {
  1584. if (m_dwMediaType == MediaMap[idxMM].dwMediaType)
  1585. {
  1586. const FRAME_TYPE *ft = MediaMap[idxMM].aFrameType;
  1587. // For each frame type not already in use, present in the server's
  1588. // general page ListView, add the available combo box
  1589. for (int idxFT=0; 0 != ft[idxFT].nFrameIds; idxFT++)
  1590. {
  1591. LV_FINDINFO lvfi;
  1592. lvfi.flags = LVFI_STRING;
  1593. lvfi.psz = SzLoadIds(ft[idxFT].nFrameIds);
  1594. if ((IDS_AUTO != ft[idxFT].nFrameIds) &&
  1595. (-1 == ListView_FindItem(m_hwndLV, -1, &lvfi)))
  1596. {
  1597. int idx = ::SendMessage(hwndCBM, CB_ADDSTRING, 0,
  1598. (LPARAM)SzLoadIds(ft[idxFT].nFrameIds));
  1599. if (CB_ERR != idx)
  1600. {
  1601. // Store the IDS we used for future reference
  1602. ::SendMessage(hwndCBM, CB_SETITEMDATA, idx, ft[idxFT].nFrameIds);
  1603. }
  1604. }
  1605. }
  1606. break;
  1607. }
  1608. }
  1609. // Select the first item in the combo box
  1610. Assert(0 != ::SendMessage(hwndCBM, CB_GETCOUNT, 0, 0L));
  1611. ::SendMessage(hwndCBM, CB_SETCURSEL, 0, 0L);
  1612. // Subclass the network number edit control
  1613. ::SetWindowLongPtr(hwndEdit, GWLP_USERDATA,
  1614. ::GetWindowLongPtr(hwndEdit, GWLP_WNDPROC));
  1615. ::SetWindowLongPtr(hwndEdit, GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
  1616. // Limit the text in the network # edit control
  1617. ::SendMessage(hwndEdit, EM_LIMITTEXT, MAX_NETNUM_SIZE, 0L);
  1618. // Initialize the network controls contents
  1619. ::SetWindowText(hwndEdit, m_strNetworkNumber.c_str());
  1620. // Center window of parent's listview window
  1621. CenterChildOverListView(m_hWnd, m_hwndLV);
  1622. return 0;
  1623. }
  1624. //+---------------------------------------------------------------------------
  1625. //
  1626. // Member: CASAddDialog::OnOk
  1627. //
  1628. // Purpose:
  1629. //
  1630. // Parameters:
  1631. // wNotifyCode [in]
  1632. // wID [in]
  1633. // pnmh [in] See the ATL documentation for params.
  1634. // bHandled [in]
  1635. //
  1636. // Returns: See the ATL documentation for return results.
  1637. //
  1638. LRESULT
  1639. CASAddDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled)
  1640. {
  1641. HWND hwndCBM = GetDlgItem(CMB_IPXAS_DEST);
  1642. WCHAR szBuf[12];
  1643. // Retrieve the network number
  1644. ::GetWindowText(GetDlgItem(EDT_IPXAS_NETNUM), szBuf, sizeof(szBuf)/sizeof(WCHAR));
  1645. if (lstrlenW(szBuf))
  1646. {
  1647. // Normalize value (String -> Number -> Formated String)
  1648. DWORD dw = DwFromSz(szBuf, 16);
  1649. HexSzFromDw(szBuf, dw);
  1650. }
  1651. else
  1652. {
  1653. // Tell the user they must enter a number
  1654. NcMsgBox(m_hWnd, IDS_MANUAL_FRAME_DETECT, IDS_INCORRECT_NETNUM,
  1655. MB_OK | MB_ICONEXCLAMATION);
  1656. return 0L;
  1657. }
  1658. // Retrieve the selection form the combo box
  1659. int idx = ::SendMessage(hwndCBM, CB_GETCURSEL, 0, 0L);
  1660. if (CB_ERR != idx)
  1661. {
  1662. UINT idsFrameType = ::SendMessage(hwndCBM, CB_GETITEMDATA, idx, 0L);
  1663. Assert(CB_ERR != idsFrameType);
  1664. // Look up the Frame IDS to retreive the actual frame type
  1665. for (int idxMM=0; idxMM < celems(MediaMap); idxMM++)
  1666. {
  1667. if (MediaMap[idxMM].dwMediaType != m_dwMediaType)
  1668. {
  1669. continue;
  1670. }
  1671. const FRAME_TYPE *ft = MediaMap[idxMM].aFrameType;
  1672. for (int idxFT=0; 0 != ft[idxFT].nFrameIds; idxFT++)
  1673. {
  1674. if (ft[idxFT].nFrameIds != idsFrameType)
  1675. {
  1676. continue;
  1677. }
  1678. // Ensure the frame type/netnum is not in use elsewhere
  1679. if (m_pASCD->FIsNetNumberInUse(ft[idxFT].dwFrameType, szBuf))
  1680. {
  1681. // Warn the user that the network number specified
  1682. // was already in use.
  1683. NcMsgBox(m_hWnd, IDS_GENERAL, IDS_NETNUM_INUSE,
  1684. MB_OK | MB_ICONEXCLAMATION);
  1685. goto Done;
  1686. }
  1687. m_strNetworkNumber = szBuf;
  1688. // Return the stashed Frame IDS
  1689. m_idsFrameType = idsFrameType;
  1690. // Return the selected frame type
  1691. m_dwFrameType = ft[idxFT].dwFrameType;
  1692. EndDialog(IDOK);
  1693. return 0;
  1694. }
  1695. }
  1696. }
  1697. Done:
  1698. return 0;
  1699. }
  1700. //+---------------------------------------------------------------------------
  1701. //
  1702. // Member: CASAddDlg::OnContextMenu
  1703. //
  1704. // Purpose: Context sensitive help support.
  1705. //
  1706. // Author: jeffspr 13 Apr 1999
  1707. //
  1708. // Notes:
  1709. //
  1710. LRESULT CASAddDialog::OnContextMenu(UINT uMsg, WPARAM wParam,
  1711. LPARAM lParam, BOOL& fHandled)
  1712. {
  1713. return ::CommonIPXOnContextMenu(m_hWnd, g_aHelpIDs_DLG_IPXAS_FRAME_ADD);
  1714. }
  1715. //+---------------------------------------------------------------------------
  1716. //
  1717. // Member: CASAddDlg::OnHelp
  1718. //
  1719. // Purpose: Context sensitive help support.
  1720. //
  1721. // Author: jeffspr 13 Apr 1999
  1722. //
  1723. // Notes:
  1724. //
  1725. LRESULT CASAddDialog::OnHelp(UINT uMsg, WPARAM wParam,
  1726. LPARAM lParam, BOOL& fHandled)
  1727. {
  1728. return ::CommonIPXOnHelp(lParam, g_aHelpIDs_DLG_IPXAS_FRAME_ADD);
  1729. }
  1730. //+---------------------------------------------------------------------------
  1731. //
  1732. // Member: CASEditDialog::OnInitDialog
  1733. //
  1734. // Purpose: Initialize the contents of the Edit Network Number dialog
  1735. //
  1736. // Parameters:
  1737. // wNotifyCode [in]
  1738. // wID [in]
  1739. // pnmh [in] See the ATL documentation for params.
  1740. // bHandled [in]
  1741. //
  1742. // Returns: See the ATL documentation for return results.
  1743. //
  1744. LRESULT
  1745. CASEditDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled)
  1746. {
  1747. HWND hwndEdit = GetDlgItem(EDT_IPXAS_NETNUM);
  1748. // Set the initial contents of the network number edit control
  1749. ::SetWindowText(hwndEdit, SzGetNetworkNumber());
  1750. // Subclass the network number edit control
  1751. ::SetWindowLongPtr(hwndEdit, GWLP_USERDATA,
  1752. ::GetWindowLongPtr(hwndEdit, GWLP_WNDPROC));
  1753. ::SetWindowLongPtr(hwndEdit, GWLP_WNDPROC, (LONG_PTR)EditSubclassProc);
  1754. // Limit the text in the network # edit control
  1755. ::SendMessage(hwndEdit, EM_LIMITTEXT, MAX_NETNUM_SIZE, 0L);
  1756. // Center the dialog over the listview of the parent
  1757. CenterChildOverListView(m_hWnd, m_hwndLV);
  1758. return 0L;
  1759. }
  1760. //+---------------------------------------------------------------------------
  1761. //
  1762. // Member: CASEditDialog::OnOk
  1763. //
  1764. // Purpose: Process the Apply request for the Edit Network Number dialog
  1765. //
  1766. // Parameters:
  1767. // wNotifyCode [in]
  1768. // wID [in]
  1769. // pnmh [in] See the ATL documentation for params.
  1770. // bHandled [in]
  1771. //
  1772. // Returns: See the ATL documentation for return results.
  1773. //
  1774. LRESULT
  1775. CASEditDialog::OnOk(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& fHandled)
  1776. {
  1777. DWORD dw;
  1778. WCHAR szBuf[12];
  1779. HWND hwndEdit = GetDlgItem(EDT_IPXAS_NETNUM);
  1780. ::GetWindowText(hwndEdit, szBuf, sizeof(szBuf)/sizeof(WCHAR));
  1781. if (0 == lstrlenW(szBuf))
  1782. {
  1783. // Tell the user they must enter a number
  1784. NcMsgBox(m_hWnd, IDS_MANUAL_FRAME_DETECT, IDS_INCORRECT_NETNUM,
  1785. MB_OK | MB_ICONEXCLAMATION);
  1786. return 0L;
  1787. }
  1788. // Normalize the return value
  1789. dw = DwFromSz(szBuf, 16);
  1790. HexSzFromDw(szBuf, dw);
  1791. // If the network number was changed, verify it's uniqueness
  1792. if ((0 != lstrcmpW(szBuf, m_strNetworkNumber.c_str())) &&
  1793. m_pASCD->FIsNetNumberInUse(m_dwFrameType, szBuf))
  1794. {
  1795. // Warn the user that the network number specified
  1796. // was already in use.
  1797. NcMsgBox(m_hWnd, IDS_GENERAL, IDS_NETNUM_INUSE,
  1798. MB_OK | MB_ICONEXCLAMATION);
  1799. return 0L;
  1800. }
  1801. // Persist the return value
  1802. m_strNetworkNumber = szBuf;
  1803. EndDialog(IDOK);
  1804. return 0L;
  1805. }
  1806. //+---------------------------------------------------------------------------
  1807. //
  1808. // Member: CASEditDlg::OnContextMenu
  1809. //
  1810. // Purpose: Context sensitive help support.
  1811. //
  1812. // Author: jeffspr 13 Apr 1999
  1813. //
  1814. // Notes:
  1815. //
  1816. LRESULT CASEditDialog::OnContextMenu(UINT uMsg, WPARAM wParam,
  1817. LPARAM lParam, BOOL& fHandled)
  1818. {
  1819. return ::CommonIPXOnContextMenu(m_hWnd, g_aHelpIDs_DLG_IPXAS_FRAME_EDIT);
  1820. }
  1821. //+---------------------------------------------------------------------------
  1822. //
  1823. // Member: CASEditDlg::OnHelp
  1824. //
  1825. // Purpose: Context sensitive help support.
  1826. //
  1827. // Author: jeffspr 13 Apr 1999
  1828. //
  1829. // Notes:
  1830. //
  1831. LRESULT CASEditDialog::OnHelp(UINT uMsg, WPARAM wParam,
  1832. LPARAM lParam, BOOL& fHandled)
  1833. {
  1834. return ::CommonIPXOnHelp(lParam, g_aHelpIDs_DLG_IPXAS_FRAME_EDIT);
  1835. }