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.

129 lines
4.0 KiB

  1. #include "pch.h"
  2. #pragma hdrstop
  3. #include "ncui.h"
  4. #include "lanui.h"
  5. #include "lanhelp.h"
  6. #include "wzcprops.h"
  7. #include "wzcui.h"
  8. ////////////////////////////////////////////////////////////////////////
  9. // CWZCConfigProps related stuff
  10. //
  11. //+---------------------------------------------------------------------------
  12. // class constructor
  13. CWZCConfigProps::CWZCConfigProps()
  14. {
  15. ZeroMemory(&m_wzcConfig, sizeof(WZC_WLAN_CONFIG));
  16. m_wzcConfig.Length = sizeof(WZC_WLAN_CONFIG);
  17. m_wzcConfig.InfrastructureMode = Ndis802_11Infrastructure;
  18. }
  19. //+---------------------------------------------------------------------------
  20. // Uploads the configuration into the dialog's internal data
  21. DWORD
  22. CWZCConfigProps::UploadWzcConfig(CWZCConfig *pwzcConfig)
  23. {
  24. CopyMemory(&m_wzcConfig, &(pwzcConfig->m_wzcConfig), sizeof(WZC_WLAN_CONFIG));
  25. return ERROR_SUCCESS;
  26. }
  27. //+---------------------------------------------------------------------------
  28. // INIT_DIALOG handler
  29. LRESULT
  30. CWZCConfigProps::OnInitDialog (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  31. {
  32. DWORD dwStyle;
  33. HRESULT hr = S_OK;
  34. // get all the controls handles
  35. m_hwndEdSSID = GetDlgItem(IDC_WZC_EDIT_SSID);
  36. m_hwndChkAdhoc = GetDlgItem(IDC_ADHOC);
  37. m_hwndUsePW = GetDlgItem(IDC_USEPW);
  38. // initialize the SSID field with the SSID, if one is given
  39. if (m_wzcConfig.Ssid.SsidLength != 0)
  40. {
  41. // ugly but this is life. In order to convert the SSID to LPWSTR we need a buffer.
  42. // We know an SSID can't exceed 32 chars (see NDIS_802_11_SSID from ntddndis.h) so
  43. // make room for the null terminator and that's it. We could do mem alloc but I'm
  44. // not sure it worth the effort (at runtime).
  45. WCHAR wszSSID[33];
  46. UINT nLenSSID = 0;
  47. // convert the LPSTR (original SSID format) to LPWSTR (needed in List Ctrl)
  48. nLenSSID = MultiByteToWideChar(
  49. CP_ACP,
  50. 0,
  51. (LPCSTR)m_wzcConfig.Ssid.Ssid,
  52. m_wzcConfig.Ssid.SsidLength,
  53. wszSSID,
  54. celems(wszSSID));
  55. if (nLenSSID != 0)
  56. {
  57. wszSSID[nLenSSID] = L'\0';
  58. ::SetWindowText(m_hwndEdSSID, wszSSID);
  59. }
  60. }
  61. // Check the "this network is adhoc" box if neccessary.
  62. ::SendMessage(m_hwndChkAdhoc, BM_SETCHECK, (m_wzcConfig.InfrastructureMode == Ndis802_11IBSS) ? BST_CHECKED : BST_UNCHECKED, 0);
  63. // the SSID can't be under any circumstances larger than 32 chars
  64. ::SendMessage(m_hwndEdSSID, EM_LIMITTEXT, 32, 0);
  65. ::SendMessage(m_hwndUsePW, BM_SETCHECK, (m_wzcConfig.Privacy == 1) ? BST_CHECKED : BST_UNCHECKED, 0);
  66. return LresFromHr(hr);
  67. }
  68. //+---------------------------------------------------------------------------
  69. // OK button handler
  70. LRESULT
  71. CWZCConfigProps::OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  72. {
  73. bHandled = TRUE;
  74. EndDialog(IDOK);
  75. return 0;
  76. }
  77. //+---------------------------------------------------------------------------
  78. // Cancel button handler
  79. LRESULT
  80. CWZCConfigProps::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  81. {
  82. // return S_FALSE on cancel
  83. bHandled = TRUE;
  84. EndDialog(IDCANCEL);
  85. return 0;
  86. }
  87. //+---------------------------------------------------------------------------
  88. // Context sensitive help handler
  89. extern const WCHAR c_szNetCfgHelpFile[];
  90. LRESULT
  91. CWZCConfigProps::OnContextMenu(
  92. UINT uMsg,
  93. WPARAM wParam,
  94. LPARAM lParam,
  95. BOOL& fHandled)
  96. {
  97. ::WinHelp(m_hWnd,
  98. c_szNetCfgHelpFile,
  99. HELP_CONTEXTMENU,
  100. (ULONG_PTR)g_aHelpIDs_IDC_WZC_DLG_VPROPS);
  101. return 0;
  102. }
  103. LRESULT
  104. CWZCConfigProps::OnHelp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  105. {
  106. LPHELPINFO lphi = reinterpret_cast<LPHELPINFO>(lParam);
  107. if (HELPINFO_WINDOW == lphi->iContextType)
  108. {
  109. ::WinHelp(static_cast<HWND>(lphi->hItemHandle),
  110. c_szNetCfgHelpFile,
  111. HELP_WM_HELP,
  112. (ULONG_PTR)g_aHelpIDs_IDC_WZC_DLG_VPROPS);
  113. }
  114. return 0;
  115. }