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.

825 lines
23 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. const TCHAR *szDeviceType[] = {
  14. MASTER_DEVICE_TYPE_REG_KEY,
  15. SLAVE_DEVICE_TYPE_REG_KEY
  16. };
  17. const TCHAR *szUserDeviceType[] = {
  18. USER_MASTER_DEVICE_TYPE_REG_KEY,
  19. USER_SLAVE_DEVICE_TYPE_REG_KEY
  20. };
  21. const TCHAR *szCurrentTransferMode[] = {
  22. MASTER_DEVICE_TIMING_MODE,
  23. SLAVE_DEVICE_TIMING_MODE
  24. };
  25. const TCHAR *szTransferModeAllowed[] = {
  26. USER_MASTER_DEVICE_TIMING_MODE_ALLOWED,
  27. USER_SLAVE_DEVICE_TIMING_MODE_ALLOWED
  28. };
  29. //
  30. // Help ID mapping for context sensitive help
  31. //
  32. const DWORD IdeHelpIDs[]=
  33. {
  34. IDC_MASTER_DEVICE_TYPE, IDH_DEVMGR_IDE_MASTER_DEVICE_TYPE,
  35. IDC_MASTER_XFER_MODE, IDH_DEVMGR_IDE_MASTER_XFER_MODE,
  36. IDC_MASTER_CURRENT_XFER_MODE, IDH_DEVMGR_IDE_MASTER_CURRENT_XFER_MODE,
  37. IDC_SLAVE_DEVICE_TYPE, IDH_DEVMGR_IDE_SLAVE_DEVICE_TYPE,
  38. IDC_SLAVE_XFER_MODE, IDH_DEVMGR_IDE_SLAVE_XFER_MODE,
  39. IDC_SLAVE_CURRENT_XFER_MODE, IDH_DEVMGR_IDE_SLAVE_CURRENT_XFER_MODE,
  40. 0,0
  41. };
  42. PPAGE_INFO IdeCreatePageInfo(IN HDEVINFO deviceInfoSet,
  43. IN PSP_DEVINFO_DATA deviceInfoData)
  44. {
  45. PPAGE_INFO tmp = NULL;
  46. if (!(tmp = LocalAlloc(LPTR, sizeof(PAGE_INFO)))) {
  47. return NULL;
  48. }
  49. tmp->deviceInfoSet = deviceInfoSet;
  50. tmp->deviceInfoData = deviceInfoData;
  51. tmp->hKeyDev =
  52. SetupDiCreateDevRegKey(deviceInfoSet,
  53. deviceInfoData,
  54. DICS_FLAG_GLOBAL,
  55. 0,
  56. DIREG_DRV,
  57. NULL,
  58. NULL);
  59. return tmp;
  60. }
  61. void
  62. IdeDestroyPageInfo(PPAGE_INFO * ppPageInfo)
  63. {
  64. PPAGE_INFO ppi = *ppPageInfo;
  65. if (ppi->hKeyDev != (HKEY) INVALID_HANDLE_VALUE) {
  66. RegCloseKey(ppi->hKeyDev);
  67. }
  68. LocalFree(ppi);
  69. *ppPageInfo = NULL;
  70. }
  71. HPROPSHEETPAGE
  72. IdeCreatePropertyPage(PROPSHEETPAGE * ppsp,
  73. PPAGE_INFO ppi)
  74. {
  75. //
  76. // Add the Port Settings property page
  77. //
  78. ppsp->dwSize = sizeof(PROPSHEETPAGE);
  79. ppsp->dwFlags = PSP_USECALLBACK; // | PSP_HASHELP;
  80. ppsp->hInstance = ModuleInstance;
  81. ppsp->pszTemplate = MAKEINTRESOURCE(ID_IDE_PROPPAGE);
  82. //
  83. // following points to the dlg window proc
  84. //
  85. ppsp->pfnDlgProc = IdeDlgProc;
  86. ppsp->lParam = (LPARAM) ppi;
  87. //
  88. // Following points to the control callback of the dlg window proc.
  89. // The callback gets called before creation/after destruction of the page
  90. //
  91. ppsp->pfnCallback = IdeDlgCallback;
  92. //
  93. // Allocate the actual page
  94. //
  95. return CreatePropertySheetPage(ppsp);
  96. }
  97. BOOL APIENTRY
  98. IdePropPageProvider(LPVOID pinfo,
  99. LPFNADDPROPSHEETPAGE pfnAdd,
  100. LPARAM lParam)
  101. {
  102. PSP_PROPSHEETPAGE_REQUEST ppr;
  103. PROPSHEETPAGE psp;
  104. HPROPSHEETPAGE hpsp;
  105. PPAGE_INFO ppi = NULL;
  106. ppr = (PSP_PROPSHEETPAGE_REQUEST) pinfo;
  107. if (ppr->PageRequested == SPPSR_ENUM_ADV_DEVICE_PROPERTIES) {
  108. ppi = IdeCreatePageInfo(ppr->DeviceInfoSet,
  109. ppr->DeviceInfoData);
  110. if (!ppi) {
  111. return FALSE;
  112. }
  113. //
  114. // If this fails, it is most likely that the user does not have
  115. // write access to the devices key/subkeys in the registry.
  116. // If you only want to read the settings, then change KEY_ALL_ACCESS
  117. // to KEY_READ in CreatePageInfo.
  118. //
  119. // Administrators usually have access to these reg keys....
  120. //
  121. #if 0
  122. if (ppi->hKeyDev == (HKEY) INVALID_HANDLE_VALUE) {
  123. DWORD error = GetLastError();
  124. IdeDestroyPageInfo(&ppi);
  125. return FALSE;
  126. }
  127. #endif
  128. hpsp = IdeCreatePropertyPage(&psp,
  129. ppi);
  130. if (!hpsp) {
  131. IdeDestroyPageInfo(&ppi);
  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. //
  530. // set current values
  531. //
  532. for (i=0; i<2; i++) {
  533. ULONG xferModeString;
  534. ULONG xferModeAllowed;
  535. //
  536. // current device type
  537. //
  538. SendDlgItemMessage(hDlg,
  539. IDC_MASTER_DEVICE_TYPE + i,
  540. CB_SETCURSEL,
  541. ppi->deviceType[i] == DeviceNotExist? 1 : 0,
  542. 0L);
  543. if (ppi->currentDeviceType[i] != DeviceUnknown) {
  544. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i), FALSE);
  545. } else {
  546. EnableWindow(GetDlgItem(hDlg, IDC_MASTER_DEVICE_TYPE + i), TRUE);
  547. }
  548. //
  549. // select transfer mode
  550. //
  551. xferModeAllowed = ppi->transferModeAllowed[i];
  552. if ((ppi->currentDeviceType[i] == DeviceIsAtapi) &&
  553. (!(ppi->currentTransferMode[i] & ~PIO_SUPPORT))) {
  554. //
  555. // atapi override only if the current transfer mode is not DMA
  556. // this is to take care of dvds and cdrws where we enable DMA
  557. // by default.
  558. //
  559. xferModeAllowed &= ppi->transferModeAllowedForAtapiDevice[i];
  560. }
  561. if (xferModeAllowed & ~PIO_SUPPORT) {
  562. SendDlgItemMessage(hDlg,
  563. IDC_MASTER_XFER_MODE + i,
  564. CB_SETCURSEL,
  565. 1,
  566. 0L);
  567. } else {
  568. SendDlgItemMessage(hDlg,
  569. IDC_MASTER_XFER_MODE + i,
  570. CB_SETCURSEL,
  571. 0,
  572. 0L);
  573. }
  574. //
  575. // current transfer mode
  576. //
  577. if (ppi->currentTransferMode[i] & UDMA_SUPPORT) {
  578. if (ppi->currentTransferMode[i] & UDMA_MODE6) {
  579. xferModeString = IDC_UDMA_MODE6_STRING;
  580. } else if (ppi->currentTransferMode[i] & UDMA_MODE5) {
  581. xferModeString = IDC_UDMA_MODE5_STRING;
  582. } else if (ppi->currentTransferMode[i] & UDMA_MODE4) {
  583. xferModeString = IDC_UDMA_MODE4_STRING;
  584. } else if (ppi->currentTransferMode[i] & UDMA_MODE3) {
  585. xferModeString = IDC_UDMA_MODE3_STRING;
  586. } else if (ppi->currentTransferMode[i] & UDMA_MODE2) {
  587. xferModeString = IDC_UDMA_MODE2_STRING;
  588. } else if (ppi->currentTransferMode[i] & UDMA_MODE1) {
  589. xferModeString = IDC_UDMA_MODE1_STRING;
  590. } else if (ppi->currentTransferMode[i] & UDMA_MODE0) {
  591. xferModeString = IDC_UDMA_MODE0_STRING;
  592. } else {
  593. xferModeString = IDC_UDMA_MODE_STRING;
  594. }
  595. } else if (ppi->currentTransferMode[i] & (MWDMA_SUPPORT | SWDMA_SUPPORT)) {
  596. if (ppi->currentTransferMode[i] & MWDMA_MODE2) {
  597. xferModeString = IDC_MWDMA_MODE2_STRING;
  598. } else if (ppi->currentTransferMode[i] & MWDMA_MODE1) {
  599. xferModeString = IDC_MWDMA_MODE1_STRING;
  600. } else if (ppi->currentTransferMode[i] & SWDMA_MODE2) {
  601. xferModeString = IDC_SWDMA_MODE2_STRING;
  602. } else {
  603. xferModeString = IDC_DMA_MODE_STRING;
  604. }
  605. } else if (ppi->currentTransferMode[i] & PIO_SUPPORT) {
  606. xferModeString = IDC_PIO_MODE_STRING;
  607. } else {
  608. xferModeString = IDC_NO_MODE_STRING;
  609. }
  610. if (LoadString(ModuleInstance,
  611. xferModeString,
  612. buffer,
  613. 50)) {
  614. SendDlgItemMessage(hDlg,
  615. IDC_MASTER_CURRENT_XFER_MODE + i,
  616. WM_SETTEXT,
  617. 0,
  618. (LPARAM) buffer);
  619. }
  620. }
  621. }
  622. BOOL
  623. IdeContextMenu(
  624. HWND HwndControl,
  625. WORD Xpos,
  626. WORD Ypos
  627. )
  628. {
  629. WinHelp(HwndControl,
  630. _T("devmgr.hlp"),
  631. HELP_CONTEXTMENU,
  632. (ULONG_PTR) IdeHelpIDs);
  633. return FALSE;
  634. }
  635. void
  636. IdeHelp(
  637. HWND ParentHwnd,
  638. LPHELPINFO HelpInfo
  639. )
  640. {
  641. if (HelpInfo->iContextType == HELPINFO_WINDOW) {
  642. WinHelp((HWND) HelpInfo->hItemHandle,
  643. _T("devmgr.hlp"),
  644. HELP_WM_HELP,
  645. (ULONG_PTR) IdeHelpIDs);
  646. }
  647. }