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.

132 lines
3.5 KiB

  1. // remotedialog.h : Declaration of the CRemoteDialog
  2. #ifndef __REMOTEDIALOG_H_
  3. #define __REMOTEDIALOG_H_
  4. #include "resource.h" // main symbols
  5. #include <atlhost.h>
  6. #include <richedit.h>
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CRemoteDialog
  9. class CRemoteDialog :
  10. public CAxDialogImpl<CRemoteDialog>
  11. {
  12. public:
  13. CRemoteDialog() : m_strMachine(_T("")), m_fRemote(FALSE), m_hwndParent(NULL)
  14. {
  15. }
  16. ~CRemoteDialog()
  17. {
  18. }
  19. enum { IDD = IDD_REMOTEDIALOG };
  20. BEGIN_MSG_MAP(CRemoteDialog)
  21. MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
  22. COMMAND_ID_HANDLER(IDOK, OnOK)
  23. COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
  24. COMMAND_HANDLER(IDC_NETWORKCOMPUTER, BN_CLICKED, OnClickedNetworkComputerButton)
  25. COMMAND_HANDLER(IDC_LOCALSYSTEM, BN_CLICKED, OnClickedLocalSystemButton)
  26. END_MSG_MAP()
  27. // Handler prototypes:
  28. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  29. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  30. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  31. private:
  32. CString m_strMachine;
  33. BOOL m_fRemote;
  34. HWND m_hwndParent;
  35. CWindow m_wndMachineName, m_wndMachineNameLabel;
  36. public:
  37. void SetRemoteDialogValues(HWND hwndParent, BOOL fRemote, LPCTSTR szMachine)
  38. {
  39. m_strMachine = szMachine;
  40. m_fRemote = fRemote;
  41. m_hwndParent = hwndParent;
  42. }
  43. void GetRemoteDialogValues(BOOL * pfRemote, CString * pstrMachine)
  44. {
  45. if (pfRemote)
  46. *pfRemote = m_fRemote;
  47. if (pstrMachine)
  48. *pstrMachine = m_strMachine;
  49. }
  50. LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  51. {
  52. m_wndMachineName.Attach(GetDlgItem(IDC_NETWORKNAME));
  53. m_wndMachineNameLabel.Attach(GetDlgItem(IDC_NETNAMELABEL));
  54. m_wndMachineName.SendMessage(EM_SETTEXTMODE, TM_PLAINTEXT, 0);
  55. SetDlgItemText(IDC_NETWORKNAME, m_strMachine);
  56. if (m_fRemote)
  57. CheckRadioButton(IDC_LOCALSYSTEM, IDC_NETWORKCOMPUTER, IDC_NETWORKCOMPUTER);
  58. else
  59. {
  60. m_wndMachineName.EnableWindow(FALSE);
  61. m_wndMachineNameLabel.EnableWindow(FALSE);
  62. CheckRadioButton(IDC_LOCALSYSTEM, IDC_NETWORKCOMPUTER, IDC_LOCALSYSTEM);
  63. }
  64. CenterWindow(m_hwndParent);
  65. return 1; // Let the system set the focus
  66. }
  67. LRESULT OnOK(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  68. {
  69. // Get the machine name from the rich edit control (use EM_GETTEXTEX
  70. // to preserve its Unicode-ness).
  71. TCHAR szBuffer[MAX_PATH];
  72. GETTEXTEX gte;
  73. gte.cb = MAX_PATH;
  74. gte.flags = GT_DEFAULT;
  75. gte.codepage = 1200; // Unicode
  76. gte.lpDefaultChar = NULL;
  77. gte.lpUsedDefChar = NULL;
  78. m_wndMachineName.SendMessage(EM_GETTEXTEX, (WPARAM)&gte, (LPARAM)szBuffer);
  79. m_strMachine = szBuffer;
  80. EndDialog(wID);
  81. return 0;
  82. }
  83. LRESULT OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  84. {
  85. m_wndMachineName.GetWindowText(m_strMachine.GetBuffer(MAX_PATH), MAX_PATH);
  86. m_strMachine.ReleaseBuffer();
  87. EndDialog(wID);
  88. return 0;
  89. }
  90. LRESULT OnClickedNetworkComputerButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  91. {
  92. UpdateMachineFieldState();
  93. return 0;
  94. }
  95. LRESULT OnClickedLocalSystemButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  96. {
  97. UpdateMachineFieldState();
  98. return 0;
  99. }
  100. void UpdateMachineFieldState()
  101. {
  102. m_fRemote = (IsDlgButtonChecked(IDC_NETWORKCOMPUTER) == BST_CHECKED);
  103. m_wndMachineName.EnableWindow(m_fRemote);
  104. m_wndMachineNameLabel.EnableWindow(m_fRemote);
  105. }
  106. };
  107. #endif //__REMOTEDIALOG_H_