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.

118 lines
3.2 KiB

  1. // ConnectionDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "emshell.h"
  5. #include "ConnectionDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CConnectionDlg dialog
  13. CConnectionDlg::CConnectionDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CConnectionDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CConnectionDlg)
  17. m_nRadio = 0;
  18. m_strRemoteMachineName = _T("");
  19. //}}AFX_DATA_INIT
  20. TCHAR szCompName[255] = _T("");
  21. DWORD dwBufSize = 255;
  22. //Get the local machine name and store it away
  23. GetComputerName(szCompName, &dwBufSize);
  24. m_strLocalMachineName = szCompName;
  25. }
  26. void CConnectionDlg::DoDataExchange(CDataExchange* pDX)
  27. {
  28. CDialog::DoDataExchange(pDX);
  29. //{{AFX_DATA_MAP(CConnectionDlg)
  30. DDX_Control(pDX, IDCONNECT, m_btnConnect);
  31. DDX_Control(pDX, IDC_RADIO_LOCAL, m_btnLocalServer);
  32. DDX_Control(pDX, IDC_RADIO_REMOTE, m_btnRemoteServer);
  33. DDX_Control(pDX, IDC_STATIC_SERVERNAME, m_idc_StaticServerName);
  34. DDX_Control(pDX, IDC_EDIT_SERVERNAME, m_idc_ServerName);
  35. DDX_Radio(pDX, IDC_RADIO_LOCAL, m_nRadio);
  36. DDX_Text(pDX, IDC_EDIT_SERVERNAME, m_strRemoteMachineName);
  37. //}}AFX_DATA_MAP
  38. }
  39. BEGIN_MESSAGE_MAP(CConnectionDlg, CDialog)
  40. //{{AFX_MSG_MAP(CConnectionDlg)
  41. ON_BN_CLICKED(IDCONNECT, OnConnect)
  42. ON_BN_CLICKED(IDC_RADIO_REMOTE, OnRadioRemote)
  43. ON_BN_CLICKED(IDC_RADIO_LOCAL, OnRadioLocal)
  44. ON_EN_CHANGE(IDC_EDIT_SERVERNAME, OnChangeEditServername)
  45. //}}AFX_MSG_MAP
  46. END_MESSAGE_MAP()
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CConnectionDlg message handlers
  49. void CConnectionDlg::OnConnect()
  50. {
  51. //Update what the user has typed in with DDE
  52. if (!m_bLocalServer) {
  53. UpdateData(TRUE);
  54. }
  55. CDialog::OnOK();
  56. }
  57. void CConnectionDlg::OnRadioRemote()
  58. {
  59. //Disable the local button, and enable the IDC_STATIC_SERVERNAME
  60. m_idc_ServerName.EnableWindow(TRUE);
  61. m_idc_StaticServerName.EnableWindow(TRUE);
  62. m_bLocalServer = FALSE;
  63. //Set the state of the connect button to false if there's no text
  64. m_btnConnect.EnableWindow(m_idc_ServerName.LineLength());
  65. }
  66. void CConnectionDlg::OnRadioLocal()
  67. {
  68. //Disable the local button, and enable the IDC_STATIC_SERVERNAME
  69. m_idc_ServerName.EnableWindow(FALSE);
  70. m_idc_StaticServerName.EnableWindow(FALSE);
  71. m_bLocalServer = TRUE;
  72. //Set the state of the connect button to TRUE
  73. m_btnConnect.EnableWindow();
  74. }
  75. void CConnectionDlg::OnChangeEditServername()
  76. {
  77. // TODO: If this is a RICHEDIT control, the control will not
  78. // send this notification unless you override the CDialog::OnInitDialog()
  79. // function and call CRichEditCtrl().SetEventMask()
  80. // with the ENM_CHANGE flag ORed into the mask.
  81. //Check to see if we have text in us. If we do, enable the Connect button
  82. m_btnConnect.EnableWindow(m_idc_ServerName.LineLength());
  83. }
  84. BOOL CConnectionDlg::OnInitDialog()
  85. {
  86. CDialog::OnInitDialog();
  87. // TODO: Add extra initialization here
  88. m_bLocalServer = (m_btnLocalServer.GetCheck() == 1);
  89. //Set the state of
  90. m_idc_ServerName.EnableWindow(!m_bLocalServer);
  91. m_idc_StaticServerName.EnableWindow(!m_bLocalServer);
  92. return TRUE; // return TRUE unless you set the focus to a control
  93. // EXCEPTION: OCX Property Pages should return FALSE
  94. }