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.

851 lines
22 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: ideprop.c
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "propp.h"
  11. #include "ideprop.h"
  12. #include "resource.h"
  13. #include "xpsp1res.h"
  14. const TCHAR *szDeviceType[] = {
  15. MASTER_DEVICE_TYPE_REG_KEY,
  16. SLAVE_DEVICE_TYPE_REG_KEY
  17. };
  18. const TCHAR *szUserDeviceType[] = {
  19. USER_MASTER_DEVICE_TYPE_REG_KEY,
  20. USER_SLAVE_DEVICE_TYPE_REG_KEY
  21. };
  22. const TCHAR *szCurrentTransferMode[] = {
  23. MASTER_DEVICE_TIMING_MODE,
  24. SLAVE_DEVICE_TIMING_MODE
  25. };
  26. const TCHAR *szTransferModeAllowed[] = {
  27. USER_MASTER_DEVICE_TIMING_MODE_ALLOWED,
  28. USER_SLAVE_DEVICE_TIMING_MODE_ALLOWED
  29. };
  30. //
  31. // Help ID mapping for context sensitive help
  32. //
  33. const DWORD IdeHelpIDs[]=
  34. {
  35. IDC_MASTER_DEVICE_TYPE, IDH_DEVMGR_IDE_MASTER_DEVICE_TYPE,
  36. IDC_MASTER_XFER_MODE, IDH_DEVMGR_IDE_MASTER_XFER_MODE,
  37. IDC_MASTER_CURRENT_XFER_MODE, IDH_DEVMGR_IDE_MASTER_CURRENT_XFER_MODE,
  38. IDC_SLAVE_DEVICE_TYPE, IDH_DEVMGR_IDE_SLAVE_DEVICE_TYPE,
  39. IDC_SLAVE_XFER_MODE, IDH_DEVMGR_IDE_SLAVE_XFER_MODE,
  40. IDC_SLAVE_CURRENT_XFER_MODE, IDH_DEVMGR_IDE_SLAVE_CURRENT_XFER_MODE,
  41. 0,0
  42. };
  43. PPAGE_INFO IdeCreatePageInfo(IN HDEVINFO deviceInfoSet,
  44. IN PSP_DEVINFO_DATA deviceInfoData)
  45. {
  46. PPAGE_INFO tmp = NULL;
  47. if (!(tmp = LocalAlloc(LPTR, sizeof(PAGE_INFO)))) {
  48. return NULL;
  49. }
  50. tmp->deviceInfoSet = deviceInfoSet;
  51. tmp->deviceInfoData = deviceInfoData;
  52. tmp->hKeyDev =
  53. SetupDiCreateDevRegKey(deviceInfoSet,
  54. deviceInfoData,
  55. DICS_FLAG_GLOBAL,
  56. 0,
  57. DIREG_DRV,
  58. NULL,
  59. NULL);
  60. return tmp;
  61. }
  62. void
  63. IdeDestroyPageInfo(PPAGE_INFO * ppPageInfo)
  64. {
  65. PPAGE_INFO ppi = *ppPageInfo;
  66. if (ppi->hKeyDev != (HKEY) INVALID_HANDLE_VALUE) {
  67. RegCloseKey(ppi->hKeyDev);
  68. }
  69. LocalFree(ppi);
  70. *ppPageInfo = NULL;
  71. }
  72. HPROPSHEETPAGE
  73. IdeCreatePropertyPage(PROPSHEETPAGE * ppsp,
  74. PPAGE_INFO ppi)
  75. {
  76. //
  77. // Add the Port Settings property page
  78. //
  79. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  80. ppsp->dwFlags = PSP_USECALLBACK; // | PSP_HASHELP;
  81. ppsp->hInstance = ModuleInstance;
  82. ppsp->pszTemplate = MAKEINTRESOURCE(ID_IDE_PROPPAGE);
  83. //
  84. // following points to the dlg window proc
  85. //
  86. ppsp->pfnDlgProc = IdeDlgProc;
  87. ppsp->lParam = (LPARAM) ppi;
  88. //
  89. // Following points to the control callback of the dlg window proc.
  90. // The callback gets called before creation/after destruction of the page
  91. //
  92. ppsp->pfnCallback = IdeDlgCallback;
  93. //
  94. // Allocate the actual page
  95. //
  96. return CreatePropertySheetPage(ppsp);
  97. }
  98. BOOL APIENTRY
  99. IdePropPageProvider(LPVOID pinfo,
  100. LPFNADDPROPSHEETPAGE pfnAdd,
  101. LPARAM lParam)
  102. {
  103. PSP_PROPSHEETPAGE_REQUEST ppr;
  104. PROPSHEETPAGE psp;
  105. HPROPSHEETPAGE hpsp;
  106. PPAGE_INFO ppi = NULL;
  107. ppr = (PSP_PROPSHEETPAGE_REQUEST) pinfo;
  108. if (ppr->PageRequested == SPPSR_ENUM_ADV_DEVICE_PROPERTIES) {
  109. ppi = IdeCreatePageInfo(ppr->DeviceInfoSet,
  110. ppr->DeviceInfoData);
  111. if (!ppi) {
  112. return FALSE;
  113. }
  114. //
  115. // If this fails, it is most likely that the user does not have
  116. // write access to the devices key/subkeys in the registry.
  117. // If you only want to read the settings, then change KEY_ALL_ACCESS
  118. // to KEY_READ in CreatePageInfo.
  119. //
  120. // Administrators usually have access to these reg keys....
  121. //
  122. #if 0
  123. if (ppi->hKeyDev == (HKEY) INVALID_HANDLE_VALUE) {
  124. DWORD error = GetLastError();
  125. IdeDestroyPageInfo(&ppi);
  126. return FALSE;
  127. }
  128. #endif
  129. hpsp = IdeCreatePropertyPage(&psp,
  130. ppi);
  131. if (!hpsp) {
  132. return FALSE;
  133. }
  134. if (!pfnAdd(hpsp, lParam)) {
  135. DestroyPropertySheetPage(hpsp);
  136. return FALSE;
  137. }
  138. }
  139. return TRUE;
  140. }
  141. UINT CALLBACK
  142. IdeDlgCallback(HWND hwnd,
  143. UINT uMsg,
  144. LPPROPSHEETPAGE ppsp)
  145. {
  146. PPAGE_INFO ppi;
  147. switch (uMsg) {
  148. case PSPCB_CREATE:
  149. return TRUE; // return TRUE to continue with creation of page
  150. case PSPCB_RELEASE:
  151. ppi = (PPAGE_INFO) ppsp->lParam;
  152. IdeDestroyPageInfo(&ppi);
  153. return 0; // return value ignored
  154. default:
  155. break;
  156. }
  157. return TRUE;
  158. }
  159. void
  160. IdeInitializeControls(PPAGE_INFO ppi,
  161. HWND hDlg)
  162. {
  163. DWORD dwError,
  164. dwType,
  165. dwSize;
  166. BOOL disableControls = FALSE;
  167. HWND hwnd;
  168. ULONG i;
  169. ULONG j;
  170. TCHAR buffer[50];
  171. //
  172. // defaults
  173. for (i=0; i<2; i++) {
  174. ppi->deviceType[i] = DeviceUnknown;
  175. }
  176. if (ppi->hKeyDev == (HKEY) INVALID_HANDLE_VALUE) {
  177. //
  178. // We weren't given write access, try to read the key and translate
  179. // its value, but disable all of the controls
  180. disableControls = TRUE;
  181. ppi->hKeyDev =
  182. SetupDiOpenDevRegKey(ppi->deviceInfoSet,
  183. ppi->deviceInfoData,
  184. DICS_FLAG_GLOBAL,
  185. 0, // current
  186. DIREG_DRV,
  187. KEY_READ);
  188. }
  189. if (ppi->hKeyDev != (HKEY) INVALID_HANDLE_VALUE) {
  190. //
  191. // get user choice device types
  192. //
  193. for (i=0; i<2; i++) {
  194. //
  195. // current device type
  196. //
  197. dwSize = sizeof(DWORD);
  198. dwError = RegQueryValueEx(ppi->hKeyDev,
  199. szDeviceType[i],
  200. NULL,
  201. &dwType,
  202. (PBYTE) (ppi->currentDeviceType + i),
  203. &dwSize);
  204. if ((dwType != REG_DWORD) ||
  205. (dwSize != sizeof(DWORD)) ||
  206. (dwError != ERROR_SUCCESS)) {
  207. ppi->currentDeviceType[i] = DeviceUnknown;
  208. }
  209. if (ppi->currentDeviceType[i] == DeviceNotExist) {
  210. ppi->currentDeviceType[i] = DeviceUnknown;
  211. }
  212. //
  213. // user choice device type
  214. //
  215. dwSize = sizeof(DWORD);
  216. dwError = RegQueryValueEx(ppi->hKeyDev,
  217. szUserDeviceType[i],
  218. NULL,
  219. &dwType,
  220. (PBYTE) (ppi->deviceType + i),
  221. &dwSize);
  222. if ((dwType != REG_DWORD) ||
  223. (dwSize != sizeof(DWORD)) ||
  224. (dwError != ERROR_SUCCESS)) {
  225. ppi->deviceType[i] = DeviceUnknown;
  226. }
  227. if (ppi->deviceType[i] != DeviceNotExist) {
  228. ppi->deviceType[i] = DeviceUnknown;
  229. }
  230. //
  231. // transfer mode allowed
  232. //
  233. dwSize = sizeof(DWORD);
  234. ppi->transferModeAllowed[i] = 0xffffffff;
  235. dwError = RegQueryValueEx(ppi->hKeyDev,
  236. szTransferModeAllowed[i],
  237. NULL,
  238. &dwType,
  239. (PBYTE) (ppi->transferModeAllowed + i),
  240. &dwSize);
  241. if ((dwType != REG_DWORD) ||
  242. (dwSize != sizeof(DWORD)) ||
  243. (dwError != ERROR_SUCCESS)) {
  244. //
  245. // default
  246. //
  247. ppi->transferModeAllowed[i] = 0xffffffff;
  248. ppi->transferModeAllowedForAtapiDevice[i] = PIO_SUPPORT;
  249. } else {
  250. //
  251. // user actually picked the xfer mode to use.
  252. // set this atapi override value to -1 so
  253. // that it won't affect the user selection
  254. //
  255. ppi->transferModeAllowedForAtapiDevice[i] = 0xffffffff;
  256. }
  257. //
  258. // current transfer mode
  259. //
  260. dwSize = sizeof(DWORD);
  261. dwError = RegQueryValueEx(ppi->hKeyDev,
  262. szCurrentTransferMode[i],
  263. NULL,
  264. &dwType,
  265. (PBYTE) (ppi->currentTransferMode + i),
  266. &dwSize);
  267. if ((dwType != REG_DWORD) ||
  268. (dwSize != sizeof(DWORD)) ||
  269. (dwError != ERROR_SUCCESS)) {
  270. ppi->currentTransferMode[i] = 0;
  271. }
  272. if (ppi->deviceType[i] == DeviceNotExist) {
  273. ppi->currentTransferMode[i] = 0;
  274. }
  275. }
  276. //
  277. // init drop lists
  278. //
  279. if (LoadString(ModuleInstance,
  280. IDS_IDE_PIO_ONLY,
  281. buffer,
  282. 50)) {
  283. for (i=0; i<2; i++) {
  284. hwnd = GetDlgItem(hDlg, IDC_MASTER_XFER_MODE + i);
  285. SendMessage(hwnd,
  286. CB_ADDSTRING,
  287. 0,
  288. (LPARAM) buffer);
  289. }
  290. }
  291. if (LoadString(ModuleInstance,
  292. IDS_IDE_DMA,
  293. buffer,
  294. 50)) {
  295. for (i=0; i<2; i++) {
  296. hwnd = GetDlgItem(hDlg, IDC_MASTER_XFER_MODE + i);
  297. SendMessage(hwnd,
  298. CB_ADDSTRING,
  299. 0,
  300. (LPARAM) buffer);
  301. }
  302. }
  303. if (LoadString(ModuleInstance,
  304. IDS_IDE_AUTO_DETECT,
  305. buffer,
  306. 50)) {
  307. for (i=0; i<2; i++) {
  308. hwnd = GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i);
  309. SendMessage(hwnd,
  310. CB_ADDSTRING,
  311. 0,
  312. (LPARAM) buffer);
  313. }
  314. }
  315. if (LoadString(ModuleInstance,
  316. IDS_IDE_NONE,
  317. buffer,
  318. 50)) {
  319. for (i=0; i<2; i++) {
  320. hwnd = GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i);
  321. SendMessage(hwnd,
  322. CB_ADDSTRING,
  323. 0,
  324. (LPARAM) buffer);
  325. }
  326. }
  327. IdeUpdate(ppi, hDlg);
  328. }
  329. if (disableControls) {
  330. for (i=0; i<2; i++) {
  331. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i), FALSE);
  332. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_XFER_MODE + i), FALSE);
  333. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_CURRENT_XFER_MODE + i), FALSE);
  334. }
  335. if (ppi->hKeyDev != (HKEY) INVALID_HANDLE_VALUE) {
  336. RegCloseKey(ppi->hKeyDev);
  337. ppi->hKeyDev = INVALID_HANDLE_VALUE;
  338. }
  339. }
  340. }
  341. void
  342. IdeApplyChanges(PPAGE_INFO ppi,
  343. HWND hDlg)
  344. {
  345. DMADETECTIONLEVEL newDmaDetectionLevel;
  346. IDE_DEVICETYPE newDeviceType;
  347. ULONG i;
  348. BOOLEAN popupError = FALSE;
  349. BOOLEAN changesMade = FALSE;
  350. ULONG newXferMode;
  351. if (ppi->hKeyDev == (HKEY) INVALID_HANDLE_VALUE) {
  352. return;
  353. }
  354. //
  355. // device type
  356. //
  357. for (i=0; i<2; i++) {
  358. newDeviceType = (IDE_DEVICETYPE) SendDlgItemMessage(hDlg,
  359. IDC_MASTER_DEVICE_TYPE + i,
  360. CB_GETCURSEL,
  361. (WPARAM) 0,
  362. (LPARAM) 0);
  363. if (newDeviceType == 1) {
  364. newDeviceType = DeviceNotExist;
  365. } else {
  366. newDeviceType = DeviceUnknown;
  367. }
  368. if (ppi->deviceType[i] != newDeviceType) {
  369. ppi->deviceType[i] = newDeviceType;
  370. if (RegSetValueEx(ppi->hKeyDev,
  371. szUserDeviceType[i],
  372. 0,
  373. REG_DWORD,
  374. (PBYTE) (ppi->deviceType + i),
  375. sizeof(DWORD)) != ERROR_SUCCESS) {
  376. popupError = TRUE;
  377. } else {
  378. changesMade = TRUE;
  379. }
  380. }
  381. }
  382. //
  383. // transfer mode
  384. //
  385. for (i=0; i<2; i++) {
  386. ULONG xferModeAllowed;
  387. //
  388. // NOTE: SendDlgItemMessage will send back 64-bit result in Sundown
  389. //
  390. newXferMode = (ULONG) SendDlgItemMessage(hDlg,
  391. IDC_MASTER_XFER_MODE + i,
  392. CB_GETCURSEL,
  393. (WPARAM) 0,
  394. (LPARAM) 0);
  395. if (newXferMode == 0) {
  396. newXferMode = PIO_SUPPORT;
  397. } else {
  398. newXferMode = 0xffffffff;
  399. }
  400. xferModeAllowed = ppi->transferModeAllowed[i];
  401. if ((ppi->currentDeviceType[i] == DeviceIsAtapi) &&
  402. (!(ppi->currentTransferMode[i] & ~PIO_SUPPORT))) {
  403. //
  404. // atapi override only if the current transfer mode is not DMA
  405. // this is to take care of dvds and cdrws where we enable DMA
  406. // by default.
  407. //
  408. xferModeAllowed &= ppi->transferModeAllowedForAtapiDevice[i];
  409. }
  410. if (newXferMode != xferModeAllowed) {
  411. ppi->transferModeAllowed[i] = newXferMode;
  412. if (RegSetValueEx(ppi->hKeyDev,
  413. szTransferModeAllowed[i],
  414. 0,
  415. REG_DWORD,
  416. (PBYTE) (ppi->transferModeAllowed + i),
  417. sizeof(DWORD)) != ERROR_SUCCESS) {
  418. popupError = TRUE;
  419. } else {
  420. changesMade = TRUE;
  421. }
  422. }
  423. }
  424. if (popupError) {
  425. TCHAR buf1[MAX_PATH+1];
  426. TCHAR buf2[MAX_PATH+1];
  427. RtlZeroMemory(buf1, sizeof(buf1));
  428. RtlZeroMemory(buf2, sizeof(buf2));
  429. LoadString(ModuleInstance, IDS_IDE_SAVE_ERROR, buf1, MAX_PATH);
  430. LoadString(ModuleInstance, IDS_IDE_SAVE_ERROR, buf2, MAX_PATH);
  431. MessageBox(hDlg, buf1, buf2, MB_OK);
  432. }
  433. if (changesMade) {
  434. SP_DEVINSTALL_PARAMS devInstallParams;
  435. devInstallParams.cbSize = sizeof (devInstallParams);
  436. SetupDiGetDeviceInstallParams(ppi->deviceInfoSet,
  437. ppi->deviceInfoData,
  438. &devInstallParams
  439. );
  440. devInstallParams.Flags |= (DI_PROPERTIES_CHANGE);
  441. SetupDiSetDeviceInstallParams(ppi->deviceInfoSet,
  442. ppi->deviceInfoData,
  443. &devInstallParams
  444. );
  445. CM_Reenumerate_DevNode_Ex( ppi->deviceInfoData->DevInst,
  446. 0,
  447. NULL);
  448. }
  449. }
  450. INT_PTR APIENTRY
  451. IdeDlgProc(IN HWND hDlg,
  452. IN UINT uMessage,
  453. IN WPARAM wParam,
  454. IN LPARAM lParam)
  455. {
  456. PPAGE_INFO ppi;
  457. ppi = (PPAGE_INFO) GetWindowLongPtr(hDlg, DWLP_USER);
  458. switch (uMessage) {
  459. case WM_INITDIALOG:
  460. //
  461. // on WM_INITDIALOG call, lParam points to the property
  462. // sheet page.
  463. //
  464. // The lParam field in the property sheet page struct is set by the
  465. // caller. When I created the property sheet, I passed in a pointer
  466. // to a struct containing information about the device. Save this in
  467. // the user window long so I can access it on later messages.
  468. //
  469. ppi = (PPAGE_INFO) ((LPPROPSHEETPAGE)lParam)->lParam;
  470. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR) ppi);
  471. //
  472. // Initialize dlg controls
  473. //
  474. IdeInitializeControls(ppi,
  475. hDlg);
  476. //
  477. // Didn't set the focus to a particular control. If we wanted to,
  478. // then return FALSE
  479. //
  480. return TRUE;
  481. case WM_COMMAND:
  482. switch (HIWORD(wParam)) {
  483. case CBN_SELCHANGE:
  484. PropSheet_Changed(GetParent(hDlg), hDlg);
  485. return TRUE;
  486. default:
  487. break;
  488. }
  489. switch(LOWORD(wParam)) {
  490. default:
  491. break;
  492. }
  493. break;
  494. case WM_CONTEXTMENU:
  495. return IdeContextMenu((HWND)wParam, LOWORD(lParam), HIWORD(lParam));
  496. case WM_HELP:
  497. IdeHelp(hDlg, (LPHELPINFO) lParam);
  498. break;
  499. case WM_NOTIFY:
  500. switch (((NMHDR *)lParam)->code) {
  501. //
  502. // Sent when the user clicks on Apply OR OK !!
  503. //
  504. case PSN_APPLY:
  505. //
  506. // Do what ever action is necessary
  507. //
  508. IdeApplyChanges(ppi,
  509. hDlg);
  510. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
  511. return TRUE;
  512. default:
  513. break;
  514. }
  515. break;
  516. }
  517. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
  518. return FALSE;
  519. }
  520. void
  521. IdeUpdate (PPAGE_INFO ppi,
  522. HWND hDlg)
  523. {
  524. ULONG i;
  525. DWORD dwError,
  526. dwType,
  527. dwSize;
  528. TCHAR buffer[50];
  529. HMODULE hModule;
  530. BOOLEAN bLibLoaded;
  531. //
  532. // set current values
  533. //
  534. for (i=0; i<2; i++) {
  535. ULONG xferModeString;
  536. ULONG xferModeAllowed;
  537. hModule = ModuleInstance;
  538. bLibLoaded = FALSE;
  539. //
  540. // current device type
  541. //
  542. SendDlgItemMessage(hDlg,
  543. IDC_MASTER_DEVICE_TYPE + i,
  544. CB_SETCURSEL,
  545. ppi->deviceType[i] == DeviceNotExist? 1 : 0,
  546. 0L);
  547. if (ppi->currentDeviceType[i] != DeviceUnknown) {
  548. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i), FALSE);
  549. } else {
  550. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i), TRUE);
  551. }
  552. //
  553. // select transfer mode
  554. //
  555. xferModeAllowed = ppi->transferModeAllowed[i];
  556. if ((ppi->currentDeviceType[i] == DeviceIsAtapi) &&
  557. (!(ppi->currentTransferMode[i] & ~PIO_SUPPORT))) {
  558. //
  559. // atapi override only if the current transfer mode is not DMA
  560. // this is to take care of dvds and cdrws where we enable DMA
  561. // by default.
  562. //
  563. xferModeAllowed &= ppi->transferModeAllowedForAtapiDevice[i];
  564. }
  565. if (xferModeAllowed & ~PIO_SUPPORT) {
  566. SendDlgItemMessage(hDlg,
  567. IDC_MASTER_XFER_MODE + i,
  568. CB_SETCURSEL,
  569. 1,
  570. 0L);
  571. } else {
  572. SendDlgItemMessage(hDlg,
  573. IDC_MASTER_XFER_MODE + i,
  574. CB_SETCURSEL,
  575. 0,
  576. 0L);
  577. }
  578. //
  579. // current transfer mode
  580. //
  581. if (ppi->currentTransferMode[i] & UDMA_SUPPORT) {
  582. if (ppi->currentTransferMode[i] & UDMA_MODE6) {
  583. hModule = LoadLibraryEx(_T("xpsp1res.dll"),
  584. NULL,
  585. LOAD_LIBRARY_AS_DATAFILE
  586. );
  587. if (hModule == NULL) {
  588. hModule = ModuleInstance;
  589. xferModeString = IDC_UDMA_MODE_STRING;
  590. } else {
  591. xferModeString = IDS_UDMA_MODE6_STRING;
  592. bLibLoaded = TRUE;
  593. }
  594. } else if (ppi->currentTransferMode[i] & UDMA_MODE5) {
  595. xferModeString = IDC_UDMA_MODE5_STRING;
  596. } else if (ppi->currentTransferMode[i] & UDMA_MODE4) {
  597. xferModeString = IDC_UDMA_MODE4_STRING;
  598. } else if (ppi->currentTransferMode[i] & UDMA_MODE3) {
  599. xferModeString = IDC_UDMA_MODE3_STRING;
  600. } else if (ppi->currentTransferMode[i] & UDMA_MODE2) {
  601. xferModeString = IDC_UDMA_MODE2_STRING;
  602. } else if (ppi->currentTransferMode[i] & UDMA_MODE1) {
  603. xferModeString = IDC_UDMA_MODE1_STRING;
  604. } else if (ppi->currentTransferMode[i] & UDMA_MODE0) {
  605. xferModeString = IDC_UDMA_MODE0_STRING;
  606. } else {
  607. xferModeString = IDC_UDMA_MODE_STRING;
  608. }
  609. } else if (ppi->currentTransferMode[i] & (MWDMA_SUPPORT | SWDMA_SUPPORT)) {
  610. if (ppi->currentTransferMode[i] & MWDMA_MODE2) {
  611. xferModeString = IDC_MWDMA_MODE2_STRING;
  612. } else if (ppi->currentTransferMode[i] & MWDMA_MODE1) {
  613. xferModeString = IDC_MWDMA_MODE1_STRING;
  614. } else if (ppi->currentTransferMode[i] & SWDMA_MODE2) {
  615. xferModeString = IDC_SWDMA_MODE2_STRING;
  616. } else {
  617. xferModeString = IDC_DMA_MODE_STRING;
  618. }
  619. } else if (ppi->currentTransferMode[i] & PIO_SUPPORT) {
  620. xferModeString = IDC_PIO_MODE_STRING;
  621. } else {
  622. xferModeString = IDC_NO_MODE_STRING;
  623. }
  624. if (LoadString(hModule,
  625. xferModeString,
  626. buffer,
  627. 50)) {
  628. SendDlgItemMessage(hDlg,
  629. IDC_MASTER_CURRENT_XFER_MODE + i,
  630. WM_SETTEXT,
  631. 0,
  632. (LPARAM) buffer);
  633. }
  634. if (bLibLoaded) {
  635. FreeLibrary(hModule);
  636. hModule = ModuleInstance;
  637. bLibLoaded = FALSE;
  638. }
  639. }
  640. }
  641. BOOL
  642. IdeContextMenu(
  643. HWND HwndControl,
  644. WORD Xpos,
  645. WORD Ypos
  646. )
  647. {
  648. WinHelp(HwndControl,
  649. _T("devmgr.hlp"),
  650. HELP_CONTEXTMENU,
  651. (ULONG_PTR) IdeHelpIDs);
  652. return FALSE;
  653. }
  654. void
  655. IdeHelp(
  656. HWND ParentHwnd,
  657. LPHELPINFO HelpInfo
  658. )
  659. {
  660. if (HelpInfo->iContextType == HELPINFO_WINDOW) {
  661. WinHelp((HWND) HelpInfo->hItemHandle,
  662. _T("devmgr.hlp"),
  663. HELP_WM_HELP,
  664. (ULONG_PTR) IdeHelpIDs);
  665. }
  666. }