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.

101 lines
2.4 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 -99 **/
  4. /**********************************************************************/
  5. /*
  6. getipadd.cpp
  7. Comment goes here
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "getipadd.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. // CGetIpAddressDlg dialog
  19. CGetIpAddressDlg::CGetIpAddressDlg(
  20. CIpNamePair * pipnp,
  21. CWnd* pParent /*=NULL*/)
  22. : CDialog(CGetIpAddressDlg::IDD, pParent)
  23. {
  24. ASSERT(pipnp != NULL);
  25. m_pipnp = pipnp;
  26. //{{AFX_DATA_INIT(CGetIpAddressDlg)
  27. // NOTE: the ClassWizard will add member initialization here
  28. //}}AFX_DATA_INIT
  29. }
  30. void CGetIpAddressDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. //{{AFX_DATA_MAP(CGetIpAddressDlg)
  34. DDX_Control(pDX, IDOK, m_button_Ok);
  35. DDX_Control(pDX, IDC_STATIC_NETBIOSNAME, m_static_NetBIOSName);
  36. //}}AFX_DATA_MAP
  37. DDX_Control(pDX, IDC_IPA_IPADDRESS, m_ipa_IpAddress);
  38. }
  39. BEGIN_MESSAGE_MAP(CGetIpAddressDlg, CDialog)
  40. //{{AFX_MSG_MAP(CGetIpAddressDlg)
  41. //}}AFX_MSG_MAP
  42. ON_EN_CHANGE(IDC_IPA_IPADDRESS, OnChangeIpControl)
  43. END_MESSAGE_MAP()
  44. void CGetIpAddressDlg::HandleControlStates()
  45. {
  46. DWORD dwIp;
  47. BOOL f = m_ipa_IpAddress.GetAddress(&dwIp);
  48. m_button_Ok.EnableWindow(f);
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CGetIpAddressDlg message handlers
  52. BOOL CGetIpAddressDlg::OnInitDialog()
  53. {
  54. CDialog::OnInitDialog();
  55. CString strNetBIOSName;
  56. strNetBIOSName = m_pipnp->GetNetBIOSName();
  57. m_static_NetBIOSName.SetWindowText(strNetBIOSName);
  58. m_ipa_IpAddress.SetFocusField(-1);
  59. HandleControlStates();
  60. return TRUE;
  61. }
  62. void CGetIpAddressDlg::OnChangeIpControl()
  63. {
  64. HandleControlStates();
  65. }
  66. void CGetIpAddressDlg::OnOK()
  67. {
  68. ULONG l;
  69. if (m_ipa_IpAddress.GetAddress(&l))
  70. {
  71. m_pipnp->SetIpAddress((LONG)l);
  72. CDialog::OnOK();
  73. return;
  74. }
  75. theApp.MessageBox(IDS_ERR_INVALID_IP);
  76. m_ipa_IpAddress.SetFocusField(-1);
  77. }