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.

114 lines
3.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 -99 **/
  4. /**********************************************************************/
  5. /*
  6. getnetbi.cpp
  7. Comment goes here
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "getnetbi.h"
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16. #define new DEBUG_NEW
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CGetNetBIOSNameDlg dialog
  19. CGetNetBIOSNameDlg::CGetNetBIOSNameDlg(
  20. CIpNamePair * pipnp,
  21. CWnd* pParent /*=NULL*/)
  22. : CDialog(CGetNetBIOSNameDlg::IDD, pParent)
  23. {
  24. ASSERT(pipnp != NULL);
  25. m_pipnp = pipnp;
  26. //{{AFX_DATA_INIT(CGetNetBIOSNameDlg)
  27. // NOTE: the ClassWizard will add member initialization here
  28. //}}AFX_DATA_INIT
  29. }
  30. void CGetNetBIOSNameDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CGetNetBIOSNameDlg)
  34. DDX_Control(pDX, IDOK, m_button_Ok);
  35. DDX_Control(pDX, IDC_EDIT_NETBIOSNAME, m_edit_NetBIOSName);
  36. DDX_Control(pDX, IDC_STATIC_IPADDRESS, m_static_IpAddress);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CGetNetBIOSNameDlg, CDialog)
  40. //{{AFX_MSG_MAP(CGetNetBIOSNameDlg)
  41. ON_EN_CHANGE(IDC_EDIT_NETBIOSNAME, OnChangeEditNetbiosname)
  42. //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44. void CGetNetBIOSNameDlg::HandleControlStates()
  45. {
  46. CString str;
  47. m_edit_NetBIOSName.GetWindowText(str);
  48. str.TrimRight();
  49. str.TrimLeft();
  50. m_button_Ok.EnableWindow(!str.IsEmpty());
  51. }
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CGetNetBIOSNameDlg message handlers
  54. BOOL CGetNetBIOSNameDlg::OnInitDialog()
  55. {
  56. CDialog::OnInitDialog();
  57. HandleControlStates();
  58. // Allow for LM names + 2 backslashes
  59. m_edit_NetBIOSName.LimitText(LM_NAME_MAX_LENGTH + 2);
  60. m_edit_NetBIOSName.SetFocus();
  61. m_static_IpAddress.SetWindowText((CString)m_pipnp->GetIpAddress());
  62. return TRUE;
  63. }
  64. void CGetNetBIOSNameDlg::OnChangeEditNetbiosname()
  65. {
  66. HandleControlStates();
  67. }
  68. void CGetNetBIOSNameDlg::OnOK()
  69. {
  70. CString strAddress;
  71. m_edit_NetBIOSName.GetWindowText(strAddress);
  72. strAddress.TrimRight();
  73. strAddress.TrimLeft();
  74. if (::IsValidNetBIOSName(strAddress, TRUE, TRUE))
  75. {
  76. // Address may have been cleaned up in validation,
  77. // so it should be re-displayed at once.
  78. m_edit_NetBIOSName.SetWindowText(strAddress);
  79. m_edit_NetBIOSName.UpdateWindow();
  80. // Don't copy the slashes
  81. CString strName((LPCTSTR) strAddress+2);
  82. m_pipnp->SetNetBIOSName(strName);
  83. CDialog::OnOK();
  84. return;
  85. }
  86. // Invalid address was entered
  87. theApp.MessageBox(IDS_ERR_BAD_NB_NAME);
  88. m_edit_NetBIOSName.SetSel(0,-1);
  89. }