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.

223 lines
6.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1997.
  5. //
  6. // File: T D E V I C E S . C P P
  7. //
  8. // Contents: Device dialog for UPnP Device Tray
  9. //
  10. // Notes:
  11. //
  12. // Author: jeffspr 16 Dec 1999
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "pch.h"
  16. #pragma hdrstop
  17. #include <windowsx.h>
  18. #include "tfind.h"
  19. #include "clist.h"
  20. #include "clistndn.h"
  21. extern CComModule _Module;
  22. #include <atlbase.h>
  23. #include <atlwin.h>
  24. //---[ Prototypes ]-----------------------------------------------------------
  25. BOOL CALLBACK DevicePropsGenPageProc(
  26. HWND hDlg,
  27. UINT message,
  28. WPARAM wParam,
  29. LPARAM lParam);
  30. HRESULT HrCreateDevicePropertySheets(
  31. HWND hwndOwner,
  32. NewDeviceNode * pNDN);
  33. //+---------------------------------------------------------------------------
  34. //
  35. // Function: HrCreateDevicePropertySheets
  36. //
  37. // Purpose: Bring up the propsheet pages for a selected device
  38. //
  39. // Arguments:
  40. // hwndOwner [in] Our parent window
  41. // pNDN [in] The device info
  42. //
  43. // Returns:
  44. //
  45. // Author: jeffspr 6 Jan 2000
  46. //
  47. // Notes:
  48. //
  49. HRESULT HrCreateDevicePropertySheets(
  50. HWND hwndOwner,
  51. NewDeviceNode * pNDN)
  52. {
  53. Assert(pNDN);
  54. HRESULT hr = S_OK;
  55. PROPSHEETPAGE psp[2] = {0};
  56. PROPSHEETHEADER psh = {0};
  57. TCHAR * szGenPage = TszFromWsz(WszLoadIds(IDS_UPNPTRAYUI_GENERAL));
  58. // Fill in the propsheet info for the General and Advanced pages
  59. // of the device propsheet dialog
  60. //
  61. psp[0].dwSize = sizeof(PROPSHEETPAGE);
  62. psp[0].dwFlags = PSP_USETITLE;
  63. psp[0].hInstance = _Module.GetResourceInstance();
  64. psp[0].pszTemplate = MAKEINTRESOURCE(IDD_DEVICE_PROPERTIES_GEN);
  65. psp[0].pszIcon = NULL;
  66. psp[0].pfnDlgProc = (DLGPROC)DevicePropsGenPageProc;
  67. psp[0].pszTitle = szGenPage;
  68. psp[0].lParam = (LPARAM) pNDN;
  69. psh.dwSize = sizeof(PROPSHEETHEADER);
  70. psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW |
  71. PSH_NOCONTEXTHELP | PSH_PROPTITLE;
  72. psh.hwndParent = hwndOwner;
  73. psh.hInstance = _Module.GetResourceInstance();
  74. psh.pszIcon = NULL;
  75. psh.pszCaption = pNDN->pszDisplayName;
  76. psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
  77. psh.ppsp = (LPCPROPSHEETPAGE) &psp;
  78. if (PropertySheet(&psh) == -1)
  79. {
  80. hr = E_FAIL;
  81. }
  82. delete szGenPage;
  83. return hr;
  84. }
  85. //---[ DevicePropsGenPageProc ]------------------------------------------------
  86. //
  87. // Dlg Proc for the Discovered Devices dialog
  88. //
  89. //-----------------------------------------------------------------------------
  90. BOOL CALLBACK DevicePropsGenPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  91. {
  92. static LPPROPSHEETPAGE pPSP = NULL;
  93. static BOOL fApplyNow = FALSE;
  94. HRESULT hr = S_OK;
  95. int iSelection = 0;
  96. static NewDeviceNode * pNDN = NULL;
  97. // WM_COMMAND stuff
  98. static int iID = 0;
  99. static HWND hwndCtl= NULL;
  100. static UINT uiCodeNotify = 0;
  101. // WM_NOTIFY stuff
  102. static NMHDR FAR *pnmhdr = NULL;
  103. switch(message)
  104. {
  105. case WM_INITDIALOG:
  106. pPSP = (LPPROPSHEETPAGE)lParam;
  107. fApplyNow=FALSE;
  108. AssertSz(pPSP, "Propsheet page NULL in DevicePropsGenPageProc");
  109. pNDN = (NewDeviceNode *) pPSP->lParam;
  110. Assert(pNDN);
  111. // Fill in the text fields from the device data
  112. //
  113. SendDlgItemMessage(hDlg, IDC_TXT_DEVICE_CAPTION, WM_SETTEXT, 0,
  114. (LPARAM) pNDN->pszDisplayName);
  115. SendDlgItemMessage(hDlg, IDC_TXT_MODEL_MANUFACTURER, WM_SETTEXT, 0,
  116. (LPARAM) pNDN->pszManufacturerName);
  117. SendDlgItemMessage(hDlg, IDC_TXT_MODEL_DESCRIPTION, WM_SETTEXT, 0,
  118. (LPARAM) pNDN->pszDescription);
  119. SendDlgItemMessage(hDlg, IDC_TXT_MODEL_NUMBER, WM_SETTEXT, 0,
  120. (LPARAM) pNDN->pszModelNumber);
  121. SendDlgItemMessage(hDlg, IDC_TXT_MODEL_NAME, WM_SETTEXT, 0,
  122. (LPARAM) pNDN->pszModelName);
  123. SendDlgItemMessage(hDlg, IDC_TXT_LOCATION, WM_SETTEXT, 0,
  124. (LPARAM) pNDN->pszPresentationURL);
  125. if(!GetParent(GetParent(hDlg)))
  126. {
  127. SetForegroundWindow(GetParent(hDlg));
  128. }
  129. // disable cancel button as this is a readonly page
  130. ::PostMessage(GetParent(hDlg), PSM_CANCELTOCLOSE, 0, 0L);
  131. return FALSE;
  132. case WM_DESTROY:
  133. break;
  134. case WM_COMMAND:
  135. iID = GET_WM_COMMAND_ID(wParam, lParam);
  136. hwndCtl = GET_WM_COMMAND_HWND(wParam, lParam);
  137. uiCodeNotify = (UINT) GET_WM_COMMAND_CMD(wParam, lParam);
  138. return(FALSE);
  139. case WM_NOTIFY:
  140. // See commctrl.h if Chicago's version of WM_NOTIFY changes.
  141. pnmhdr = (NMHDR FAR *)lParam;
  142. iID = (int) wParam;
  143. AssertSz(pnmhdr, "Travel Experts");
  144. switch(pnmhdr->code)
  145. {
  146. case PSN_APPLY:
  147. break;
  148. case PSN_KILLACTIVE:
  149. // validate here
  150. return TRUE;
  151. case PSN_SETACTIVE:
  152. return TRUE;
  153. case PSN_WIZBACK:
  154. case PSN_WIZNEXT:
  155. case PSN_WIZFINISH:
  156. case PSN_QUERYCANCEL:
  157. break;
  158. case PSN_RESET: // Cancelling dialog
  159. break;
  160. case PSN_HELP: // Help button was pressed
  161. // dwMailHelpContext = IDH_INTERNET_SEND_DLG;
  162. // WinHelp(hDlg, MAIL_HELP_NAME, HELP_CONTEXT, dwMailHelpContext);
  163. break;
  164. // We don't process any of these
  165. //
  166. case PSN_GETOBJECT:
  167. case PSN_TRANSLATEACCELERATOR:
  168. case PSN_QUERYINITIALFOCUS:
  169. break;
  170. default:
  171. // This will break in the future. In my way of thinking, this is good
  172. // because it informs us of new functionality that we can support,
  173. // so I'll fire this assert.
  174. //
  175. //AssertSz(FALSE, "Eeeeeeee-gads! Unknown PSN_");
  176. break;
  177. }
  178. return TRUE;
  179. }
  180. //
  181. return FALSE;
  182. }