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.

72 lines
2.5 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 1998
  4. *
  5. * TITLE: WIASELD.CPP
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 5/12/1998
  12. *
  13. * DESCRIPTION: Interface definitions for ChooseWIADevice API
  14. *
  15. *******************************************************************************/
  16. #include "precomp.h"
  17. #pragma hdrstop
  18. HRESULT WINAPI SelectDeviceDlg( PSELECTDEVICEDLG pSelectDeviceDlg )
  19. {
  20. //
  21. // Double check arguments
  22. //
  23. if (!pSelectDeviceDlg)
  24. return(E_POINTER);
  25. if (pSelectDeviceDlg->cbSize != sizeof(SELECTDEVICEDLG))
  26. return(E_INVALIDARG);
  27. // Put up a wait cursor
  28. CWaitCursor wc;
  29. CComPtr<IWiaDevMgr> pWiaDevMgr;
  30. HRESULT hr = CoCreateInstance(CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER, IID_IWiaDevMgr, (void**)&pWiaDevMgr);
  31. if (SUCCEEDED(hr))
  32. {
  33. CDeviceList DeviceList( pWiaDevMgr, pSelectDeviceDlg->nDeviceType );
  34. if (DeviceList.Size() == 0)
  35. {
  36. return WIA_S_NO_DEVICE_AVAILABLE;
  37. }
  38. else if (DeviceList.Size() == 1 && !(pSelectDeviceDlg->nFlags & WIA_SELECT_DEVICE_NODEFAULT))
  39. {
  40. hr = CChooseDeviceDialog::CreateWiaDevice( pWiaDevMgr, DeviceList[0], NULL, pSelectDeviceDlg->ppWiaItemRoot, pSelectDeviceDlg->pbstrDeviceID );
  41. }
  42. else
  43. {
  44. // BUGBUG: I have to register ComboBoxEx32 class too, since it is
  45. // used by the shell property pages. Perhaps I will move it out of
  46. // here...
  47. INITCOMMONCONTROLSEX icex;
  48. icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
  49. icex.dwICC = ICC_WIN95_CLASSES | ICC_USEREX_CLASSES;
  50. InitCommonControlsEx(&icex);
  51. CChooseDeviceDialogParams ChooseDeviceDialogParams;
  52. ChooseDeviceDialogParams.pSelectDeviceDlg = pSelectDeviceDlg;
  53. ChooseDeviceDialogParams.pDeviceList = &DeviceList;
  54. hr = (HRESULT)DialogBoxParam(
  55. g_hInstance,
  56. MAKEINTRESOURCE(IDD_CHOOSEWIADEVICE),
  57. pSelectDeviceDlg->hwndParent,
  58. reinterpret_cast<DLGPROC>(CChooseDeviceDialog::DialogProc),
  59. reinterpret_cast<LPARAM>(&ChooseDeviceDialogParams)
  60. );
  61. }
  62. }
  63. return(hr);
  64. }