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.

147 lines
3.4 KiB

  1. /*++
  2. Microsoft Windows
  3. Copyright (C) Microsoft Corporation, 1981 - 1999
  4. Module Name:
  5. multdevices.cpp
  6. Abstract:
  7. Author:
  8. Rahul Thombre (RahulTh) 4/30/1998
  9. Revision History:
  10. 4/30/1998 RahulTh
  11. Created this module.
  12. --*/
  13. // MultDevices.cpp : implementation file
  14. //
  15. #include "precomp.hxx"
  16. #ifdef _DEBUG
  17. #define new DEBUG_NEW
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21. //the array used for context sensitive help
  22. const DWORD g_aHelpIDs_IDD_DEVICECHOOSER[]=
  23. {
  24. IDC_CHOOSERDESC, IDH_DISABLEHELP,
  25. IDC_DEVICELIST, IDH_DEVICELIST,
  26. 0, 0
  27. };
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CMultDevices dialog
  30. CMultDevices::CMultDevices(CWnd* pParent /*=NULL*/, CDeviceList* pDevList /* = NULL*/)
  31. : CDialog(CMultDevices::IDD, pParent), m_pDevList (pDevList)
  32. {
  33. m_pParentWnd = (CSendProgress*)pParent;
  34. //{{AFX_DATA_INIT(CMultDevices)
  35. // NOTE: the ClassWizard will add member initialization here
  36. //}}AFX_DATA_INIT
  37. }
  38. void CMultDevices::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CMultDevices)
  42. DDX_Control(pDX, IDC_DEVICELIST, m_lstDevices);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CMultDevices, CDialog)
  46. //{{AFX_MSG_MAP(CMultDevices)
  47. ON_MESSAGE (WM_HELP, OnHelp)
  48. ON_MESSAGE (WM_CONTEXTMENU, OnContextMenu)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CMultDevices message handlers
  53. BOOL CMultDevices::OnInitDialog()
  54. {
  55. CDialog::OnInitDialog();
  56. int len, i;
  57. int index;
  58. TCHAR devName[MAX_PATH];
  59. EnterCriticalSection(&(m_pDevList->m_criticalSection));
  60. for (i = 0; i < m_pDevList->m_lNumDevices; i++)
  61. {
  62. wcscpy (devName, m_pDevList->m_pDeviceInfo[i].DeviceName);
  63. index = m_lstDevices.AddString(devName);
  64. if (m_pDevList->m_pDeviceInfo[i].DeviceType == TYPE_IRDA) {
  65. m_lstDevices.SetItemData (index, (DWORD)m_pDevList->m_pDeviceInfo[i].DeviceSpecific.s.Irda.DeviceId);
  66. } else {
  67. m_lstDevices.SetItemData (index, (DWORD)m_pDevList->m_pDeviceInfo[i].DeviceSpecific.s.Ip.IpAddress);
  68. }
  69. }
  70. LeaveCriticalSection(&(m_pDevList->m_criticalSection));
  71. return TRUE; // return TRUE unless you set the focus to a control
  72. // EXCEPTION: OCX Property Pages should return FALSE
  73. }
  74. void CMultDevices::OnOK()
  75. {
  76. int iSel;
  77. iSel = m_lstDevices.GetCurSel();
  78. m_pParentWnd->m_lSelectedDeviceID = (LONG) m_lstDevices.GetItemData(iSel);
  79. m_lstDevices.GetText(iSel, m_pParentWnd->m_lpszSelectedDeviceName);
  80. CDialog::OnOK();
  81. }
  82. LONG CMultDevices::OnHelp (WPARAM wParam, LPARAM lParam)
  83. {
  84. AFX_MANAGE_STATE (AfxGetStaticModuleState());
  85. LONG lResult = 0;
  86. CString szHelpFile;
  87. szHelpFile.LoadString (IDS_HELP_FILE);
  88. ::WinHelp((HWND)(((LPHELPINFO)lParam)->hItemHandle),
  89. (LPCTSTR) szHelpFile,
  90. HELP_WM_HELP,
  91. (ULONG_PTR)(LPTSTR)g_aHelpIDs_IDD_DEVICECHOOSER);
  92. return lResult;
  93. }
  94. LONG CMultDevices::OnContextMenu (WPARAM wParam, LPARAM lParam)
  95. {
  96. AFX_MANAGE_STATE (AfxGetStaticModuleState());
  97. LONG lResult = 0;
  98. CString szHelpFile;
  99. szHelpFile.LoadString (IDS_HELP_FILE);
  100. ::WinHelp((HWND)wParam,
  101. (LPCTSTR)szHelpFile,
  102. HELP_CONTEXTMENU,
  103. (ULONG_PTR)(LPVOID)g_aHelpIDs_IDD_DEVICECHOOSER);
  104. return lResult;
  105. }