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.

144 lines
3.6 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORP., 1993-1995
  4. * TITLE: GENPAGE.CPP
  5. * VERSION: 1.0
  6. * AUTHOR: jsenior
  7. * DATE: 10/28/1998
  8. *
  9. ********************************************************************************
  10. *
  11. * CHANGE LOG:
  12. *
  13. * DATE REV DESCRIPTION
  14. * ---------- ------- ----------------------------------------------------------
  15. * 10/28/1998 jsenior Original implementation.
  16. *
  17. *******************************************************************************/
  18. #include "bandpage.h"
  19. #include "proppage.h"
  20. #include "debug.h"
  21. #include "resource.h"
  22. #include "usbutil.h"
  23. void
  24. GenericPage::Refresh()
  25. {
  26. TCHAR buf[MAX_PATH], formatString[MAX_PATH];
  27. UsbItem *device;
  28. if (preItem) {
  29. device = preItem;
  30. } else {
  31. //
  32. // Recreate the rootItem if necessary
  33. //
  34. if (rootItem) {
  35. DeleteChunk(rootItem);
  36. delete rootItem;
  37. }
  38. rootItem = new UsbItem;
  39. if (!rootItem) {
  40. return;
  41. }
  42. AddChunk(rootItem);
  43. device = rootItem;
  44. if (FALSE) {
  45. // !rootItem->EnumerateDevice(deviceInfoData->DevInst)) {
  46. return;
  47. }
  48. }
  49. if (device->ComputePower()) {
  50. LoadString(gHInst, IDS_POWER_REQUIRED, formatString, MAX_PATH);
  51. UsbSprintf(buf, formatString, device->power);
  52. SetTextItem(hwnd, IDC_GENERIC_POWER, buf);
  53. }
  54. if (device->ComputeBandwidth()) {
  55. LoadString(gHInst, IDS_CURRENT_BANDWIDTH, formatString, MAX_PATH);
  56. UsbSprintf(buf, formatString, device->bandwidth);
  57. SetTextItem(hwnd, IDC_GENERIC_BANDWIDTH, buf);
  58. }
  59. }
  60. VOID
  61. GenericPage::Initialize()
  62. { dlgResource = IDD_GENERIC_DEVICE; }
  63. BOOL GenericPage::OnInitDialog()
  64. {
  65. if (preItem) {
  66. SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_CAPTION);
  67. }
  68. Refresh();
  69. return TRUE;
  70. }
  71. void
  72. RootPage::Refresh()
  73. {
  74. ErrorCheckingEnabled = BandwidthPage::IsErrorCheckingEnabled();
  75. CheckDlgButton(hwnd,
  76. IDC_ERROR_DETECT_DISABLE,
  77. ErrorCheckingEnabled ? BST_UNCHECKED : BST_CHECKED);
  78. }
  79. VOID
  80. RootPage::Initialize()
  81. {
  82. dlgResource = IDD_ROOT_PAGE;
  83. }
  84. BOOL RootPage::OnInitDialog()
  85. {
  86. if (preItem) {
  87. SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_CAPTION);
  88. }
  89. Refresh();
  90. return TRUE;
  91. }
  92. BOOL
  93. SetErrorChecking(DWORD ErrorCheckingEnabled)
  94. {
  95. DWORD disposition, size = sizeof(DWORD), type = REG_DWORD;
  96. HKEY hKey;
  97. if (ERROR_SUCCESS !=
  98. RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  99. TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Usb"),
  100. 0,
  101. TEXT("REG_SZ"),
  102. REG_OPTION_NON_VOLATILE,
  103. KEY_ALL_ACCESS,
  104. NULL,
  105. &hKey,
  106. &disposition)) {
  107. return FALSE;
  108. }
  109. if (ERROR_SUCCESS !=
  110. RegSetValueEx(hKey,
  111. TEXT("ErrorCheckingEnabled"),
  112. 0,
  113. type,
  114. (LPBYTE) &ErrorCheckingEnabled,
  115. size)) {
  116. return FALSE;
  117. }
  118. return TRUE;
  119. }
  120. BOOL
  121. RootPage::OnCommand(INT wNotifyCode,
  122. INT wID,
  123. HWND hCtl)
  124. {
  125. if (wID == IDC_ERROR_DETECT_DISABLE &&
  126. wNotifyCode == BN_CLICKED) {
  127. ErrorCheckingEnabled = !ErrorCheckingEnabled;
  128. SetErrorChecking(ErrorCheckingEnabled);
  129. }
  130. return 1;
  131. }