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.

2396 lines
63 KiB

  1. // WIATestView.cpp : implementation of the CWIATestView class
  2. //
  3. #include "stdafx.h"
  4. #include "WIATest.h"
  5. #include "WIATestDoc.h"
  6. #include "WIATestView.h"
  7. #include "Mainfrm.h"
  8. #include "PropEdit.h"
  9. #include "datacallback.h"
  10. #include "devicecmddlg.h"
  11. #include "iteminfodlg.h"
  12. #include "mmsystem.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CWIATestView
  20. IMPLEMENT_DYNCREATE(CWIATestView, CFormView)
  21. BEGIN_MESSAGE_MAP(CWIATestView, CFormView)
  22. //{{AFX_MSG_MAP(CWIATestView)
  23. ON_NOTIFY(TVN_SELCHANGED, IDC_DEVICE_ITEM_TREE, OnSelchangedDeviceItemTree)
  24. ON_CBN_SELCHANGE(IDC_DEVICELIST_COMBO, OnSelchangeDevicelistCombo)
  25. ON_NOTIFY(NM_DBLCLK, IDC_LIST_ITEMPROP, OnDblclkListItemprop)
  26. ON_COMMAND(ID_GETIMAGEDLG, OnGetimagedlg)
  27. ON_COMMAND(ID_IDTGETBANDED, OnIdtgetbanded)
  28. ON_COMMAND(ID_WIADATA, OnWiadata)
  29. ON_COMMAND(ID_ADDDEVICE, OnAdddevice)
  30. ON_COMMAND(ID_REFRESH, OnRefresh)
  31. ON_COMMAND(ID_VIEW_TRANSFER_TOOLBAR, OnViewTransferToolbar)
  32. ON_COMMAND(ID_EXECUTECOMMAND, OnExecutecommand)
  33. ON_COMMAND(ID_DUMPDRVITEM_INFO, OnDumpdrvitemInfo)
  34. ON_COMMAND(ID_DUMPAPPITEM_INFO, OnDumpappitemInfo)
  35. ON_WM_PAINT()
  36. ON_BN_CLICKED(IDC_PAINTMODE_CHECKBOX, OnPaintmodeCheckbox)
  37. ON_COMMAND(ID_RESETSTI, OnResetsti)
  38. ON_COMMAND(ID_FULLPREVIEW, OnFullpreview)
  39. ON_BN_CLICKED(IDC_THUMBNAILMODE, OnThumbnailmode)
  40. ON_COMMAND(ID_DELETEITEM, OnDeleteitem)
  41. ON_CBN_SELCHANGE(IDC_TYMED_COMBOBOX, OnSelchangeTymedCombobox)
  42. ON_CBN_SELCHANGE(IDC_CLIPBOARDFORMAT_COMBOBOX, OnSelchangeClipboardFormatCombobox)
  43. ON_UPDATE_COMMAND_UI(ID_VIEW_TRANSFER_TOOLBAR, OnUpdateViewTransferToolbar)
  44. ON_BN_CLICKED(IDC_PLAYAUDIO_BUTTON, OnPlayaudioButton)
  45. ON_COMMAND(ID_GETROOTITEMTEST, OnGetrootitemtest)
  46. ON_COMMAND(ID_REENUMITEMS, OnReenumitems)
  47. ON_COMMAND(ID_SAVEPROPSTREAM, OnSavepropstream)
  48. ON_COMMAND(ID_LOADPROPSTREAM, OnLoadpropstream)
  49. ON_COMMAND(ID_GET_SET_PROPSTREAM_TEST, OnGetSetPropstreamTest)
  50. ON_COMMAND(ID_ANALYZE, OnAnalyzeItem)
  51. ON_COMMAND(ID_CREATE_CHILD_ITEM, OnCreateChildItem)
  52. //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CWIATestView construction/destruction
  56. CWIATestView::CWIATestView()
  57. : CFormView(CWIATestView::IDD)
  58. {
  59. //{{AFX_DATA_INIT(CWIATestView)
  60. m_FileName = _T("");
  61. m_GUIDDisplay = _T("");
  62. //}}AFX_DATA_INIT
  63. m_pIWiaDevMgr = NULL;
  64. m_pDIB = NULL;
  65. m_pPreviewWindow = NULL;
  66. m_pFullPreviewWindow = NULL;
  67. m_PaintMode = PAINT_TOFIT;
  68. m_bThumbnailMode = FALSE;
  69. m_pThumbNail = NULL;
  70. m_hBitmap = NULL;
  71. }
  72. /**************************************************************************\
  73. * CWIATestView::~CWIATestView()
  74. *
  75. * Destructor for WIA object:
  76. * Deletes WIA preview window
  77. * Deletes FULL preview window
  78. * unregisters for Events
  79. *
  80. *
  81. * Arguments:
  82. *
  83. * none
  84. *
  85. *
  86. *
  87. * Return Value:
  88. *
  89. * status
  90. *
  91. * History:
  92. *
  93. * 2/14/1999 Original Version
  94. *
  95. \**************************************************************************/
  96. CWIATestView::~CWIATestView()
  97. {
  98. //
  99. // delete preview window pointer, if exists
  100. //
  101. if (m_pPreviewWindow != NULL)
  102. delete m_pPreviewWindow;
  103. //
  104. // delete FULL preview window pointer, if exists
  105. //
  106. if (m_pFullPreviewWindow != NULL) {
  107. m_pFullPreviewWindow->DestroyWindow();
  108. delete m_pFullPreviewWindow;
  109. }
  110. //
  111. // unregister from events
  112. //
  113. UnRegisterForAllEventsByInterface();
  114. }
  115. /**************************************************************************\
  116. * CWIATestView::DoDataExchange()
  117. *
  118. * Maps messages from controls to member variables
  119. *
  120. *
  121. * Arguments:
  122. *
  123. * pDX - CDataExchange object
  124. *
  125. * Return Value:
  126. *
  127. * void
  128. *
  129. * History:
  130. *
  131. * 2/14/1999 Original Version
  132. *
  133. \**************************************************************************/
  134. void CWIATestView::DoDataExchange(CDataExchange* pDX)
  135. {
  136. CFormView::DoDataExchange(pDX);
  137. //{{AFX_DATA_MAP(CWIATestView)
  138. DDX_Control(pDX, IDC_PLAYAUDIO_BUTTON, m_PlayAudioButton);
  139. DDX_Control(pDX, IDC_TYMED_COMBOBOX, m_TymedComboBox);
  140. DDX_Control(pDX, IDC_THUMBNAIL, m_ThumbnailImage);
  141. DDX_Control(pDX, IDC_PREVIEW, m_PreviewFrame);
  142. DDX_Control(pDX, IDC_LIST_ITEMPROP, m_ItemPropertyListControl);
  143. DDX_Control(pDX, IDC_DEVICELIST_COMBO, m_DeviceListComboBox);
  144. DDX_Control(pDX, IDC_DEVICE_ITEM_TREE, m_ItemTree);
  145. DDX_Control(pDX, IDC_CLIPBOARDFORMAT_COMBOBOX, m_ClipboardFormatComboBox);
  146. DDX_Text(pDX, IDC_FILENAME_EDITBOX, m_FileName);
  147. //}}AFX_DATA_MAP
  148. }
  149. /**************************************************************************\
  150. * CWIATestView::PreCreateWindow()
  151. *
  152. * Sets window creation parameters.
  153. *
  154. *
  155. * Arguments:
  156. *
  157. * cs - CREATESTRUCT, window construction params
  158. *
  159. * Return Value:
  160. *
  161. * status
  162. *
  163. * History:
  164. *
  165. * 2/14/1999 Original Version
  166. *
  167. \**************************************************************************/
  168. BOOL CWIATestView::PreCreateWindow(CREATESTRUCT& cs)
  169. {
  170. return CFormView::PreCreateWindow(cs);
  171. }
  172. /**************************************************************************\
  173. * CWIATestView::OnInitialUpdate()
  174. *
  175. * Initialization routine for FORM
  176. *
  177. *
  178. * Arguments:
  179. *
  180. * none
  181. *
  182. * Return Value:
  183. *
  184. * void
  185. *
  186. * History:
  187. *
  188. * 2/14/1999 Original Version
  189. *
  190. \**************************************************************************/
  191. void CWIATestView::OnInitialUpdate()
  192. {
  193. CFormView::OnInitialUpdate();
  194. //
  195. // Set default file name
  196. //
  197. m_AudioFileName = "test.wav";
  198. m_FileName = "c:\\test";
  199. UpdateData(FALSE);
  200. //
  201. // hide audio play button
  202. //
  203. m_PlayAudioButton.ShowWindow(SW_HIDE);
  204. //
  205. // resize mainframe to fit resource template
  206. //
  207. GetParentFrame()->RecalcLayout();
  208. ResizeParentToFit(FALSE);
  209. //
  210. // set transfer type radio button
  211. //
  212. CButton* pRadioButton = (CButton*)GetDlgItem(IDC_TOMEMORY);
  213. if (pRadioButton != NULL)
  214. pRadioButton->SetCheck(1);
  215. //
  216. // initialize clipboard type combo box
  217. //
  218. m_ClipboardFormatComboBox.InitClipboardFormats(NULL,NULL);
  219. //
  220. // initialize tymed combo box
  221. //
  222. m_TymedComboBox.InitTymedComboBox();
  223. //
  224. // initialize headers for Property list control
  225. //
  226. m_ItemPropertyListControl.InitHeaders();
  227. //
  228. // initialize headers for Item tree control
  229. //
  230. m_ItemTree.InitHeaders();
  231. if(FAILED(m_WIA.Initialize())){
  232. AfxMessageBox("WIA did not initialize correctly..");
  233. exit(0);
  234. }
  235. HRESULT hResult = S_OK;
  236. hResult = EnumerateWIADevices();
  237. if (SUCCEEDED(hResult))
  238. StressStatus("Device Enumeration Successful");
  239. else
  240. StressStatus("* EnumerateWIADevices() Failed",hResult);
  241. if (((CWIATestApp*)AfxGetApp())->GetDeviceIDCommandLine() == "") {
  242. if (m_WIA.GetWIADeviceCount() > 0) {
  243. if (!DoDefaultUIInit()) {
  244. StressStatus("* WIATest UI Failed attempting to do DEFAULT UI setup");
  245. exit(0);
  246. }
  247. } else {
  248. AfxMessageBox("There are no WIA devices on this system..WIATEST will now exit");
  249. exit(0);
  250. }
  251. } else
  252. if (!DoCmdLineUIInit(((CWIATestApp*)AfxGetApp())->GetDeviceIDCommandLine()))
  253. StressStatus("* WIATest UI Failed attempting to do CommandLine UI setup");
  254. if (m_pPreviewWindow == NULL) {
  255. m_pPreviewWindow = new CWIAPreview;
  256. if (m_pPreviewWindow != NULL) {
  257. RECT PreviewFrameRect;
  258. m_PreviewFrame.GetWindowRect(&PreviewFrameRect);
  259. ScreenToClient(&PreviewFrameRect);
  260. if (!m_pPreviewWindow->Create(NULL,"WIA Preview Window",WS_CHILD|WS_BORDER|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE,PreviewFrameRect,this,NULL)) {
  261. StressStatus("Preview Window Failed to create..",0);
  262. } else {
  263. //
  264. // hide the place holder frame
  265. //
  266. m_PreviewFrame.ShowWindow(SW_HIDE);
  267. //
  268. // hide both scroll bars
  269. //
  270. m_pPreviewWindow->ShowScrollBar(SB_BOTH,FALSE);
  271. //
  272. // paint NULL image (white background)
  273. //
  274. DisplayImage();
  275. }
  276. }
  277. }
  278. //
  279. // Register for Connect / Disconnect Events
  280. //
  281. RegisterForAllEventsByInterface();
  282. GetDocument()->SetTitle(m_DeviceListComboBox.GetCurrentDeviceName());
  283. ((CMainFrame*)GetParent())->ActivateSizing(TRUE);
  284. }
  285. /////////////////////////////////////////////////////////////////////////////
  286. // CWIATestView diagnostics
  287. #ifdef _DEBUG
  288. void CWIATestView::AssertValid() const
  289. {
  290. CFormView::AssertValid();
  291. }
  292. void CWIATestView::Dump(CDumpContext& dc) const
  293. {
  294. CFormView::Dump(dc);
  295. }
  296. CWIATestDoc* CWIATestView::GetDocument() // non-debug version is inline
  297. {
  298. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWIATestDoc)));
  299. return(CWIATestDoc*)m_pDocument;
  300. }
  301. #endif //_DEBUG
  302. /////////////////////////////////////////////////////////////////////////////
  303. // CWIATestView message handlers
  304. /**************************************************************************\
  305. * CWIATestView::EnumerateWIADevices()
  306. *
  307. * Enumerates all WIA devices on the system
  308. *
  309. *
  310. * Arguments:
  311. *
  312. * none
  313. *
  314. * Return Value:
  315. *
  316. * status
  317. *
  318. * History:
  319. *
  320. * 2/14/1999 Original Version
  321. *
  322. \**************************************************************************/
  323. HRESULT CWIATestView::EnumerateWIADevices()
  324. {
  325. HRESULT hResult = S_OK;
  326. LONG cItemRoot = 0;
  327. BOOL bRet = FALSE;
  328. int DeviceIndex = 0;
  329. m_DeviceListComboBox.ResetContent();
  330. //
  331. // attempt to enumerate WIA devices
  332. //
  333. m_WIA.Auto_ResetDeviceEnumerator();
  334. WIADEVICENODE* pDeviceNode = NULL;
  335. do {
  336. pDeviceNode = m_WIA.Auto_GetNextDevice();
  337. if (pDeviceNode != NULL) {
  338. BSTR bstrDeviceID = ::SysAllocString(pDeviceNode->bstrDeviceID);
  339. BSTR bstrDeviceName = ::SysAllocString(pDeviceNode->bstrDeviceName);
  340. BSTR bstrServerName = ::SysAllocString(pDeviceNode->bstrServerName);
  341. m_DeviceListComboBox.AddDeviceID(DeviceIndex, bstrDeviceName, bstrServerName, bstrDeviceID);
  342. StressStatus((CString)bstrDeviceName + " Found..");
  343. //
  344. // Free BSTRs allocated
  345. //
  346. ::SysFreeString(bstrDeviceName);
  347. ::SysFreeString(bstrServerName);
  348. DeviceIndex++;
  349. }
  350. } while (pDeviceNode != NULL);
  351. //
  352. // No devices found during enumeration?
  353. //
  354. if (DeviceIndex == 0) {
  355. m_DeviceListComboBox.AddDeviceID(-1, NULL, NULL, NULL);
  356. StressStatus("* No WIA Devices Found");
  357. }
  358. //
  359. // set the default combo box settings
  360. //
  361. m_DeviceListComboBox.SetCurSel(0);
  362. return hResult;
  363. }
  364. /**************************************************************************\
  365. * CWIATestView::DoDefaultUIInit()
  366. *
  367. * Handles default launch initialization of parameters
  368. *
  369. *
  370. * Arguments:
  371. *
  372. * none
  373. *
  374. * Return Value:
  375. *
  376. * status
  377. *
  378. * History:
  379. *
  380. * 2/14/1999 Original Version
  381. *
  382. \**************************************************************************/
  383. BOOL CWIATestView::DoDefaultUIInit()
  384. {
  385. int nDeviceNum = 0;
  386. HRESULT hResult = S_OK;
  387. if (SUCCEEDED(m_WIA.CreateWIADevice(m_DeviceListComboBox.GetCurrentDeviceID()))){
  388. if (!m_ItemTree.BuildItemTree(m_WIA.GetItemTreeList()))
  389. StressStatus("* BuildItemTree Failed");
  390. else{
  391. OnSelchangeTymedCombobox();
  392. m_ItemPropertyListControl.DisplayItemPropData(m_WIA.GetRootIWiaItem());
  393. }
  394. }else{
  395. if(IsWindow(m_ItemPropertyListControl.m_hWnd))
  396. m_ItemPropertyListControl.DeleteAllItems();
  397. if(IsWindow(m_ItemTree.m_hWnd))
  398. m_ItemTree.DeleteAllItems();
  399. return FALSE;
  400. }
  401. return TRUE;
  402. }
  403. /**************************************************************************\
  404. * CWIATestView::DoCmdLineUIInit()
  405. *
  406. * Handles command line launch initialization
  407. *
  408. *
  409. * Arguments:
  410. *
  411. * CmdLine - Device ID used to set the default device
  412. *
  413. *
  414. * Return Value:
  415. *
  416. * status
  417. *
  418. * History:
  419. *
  420. * 2/14/1999 Original Version
  421. *
  422. \**************************************************************************/
  423. BOOL CWIATestView::DoCmdLineUIInit(CString CmdLine)
  424. {
  425. int nDeviceNum = 0;
  426. HRESULT hResult = S_OK;
  427. m_DeviceListComboBox.SetCurrentSelFromID(CmdLine);
  428. if (SUCCEEDED(m_WIA.CreateWIADevice(m_DeviceListComboBox.GetCurrentDeviceID()))) {
  429. if (!m_ItemTree.BuildItemTree(m_WIA.GetItemTreeList()))
  430. StressStatus("* BuildItemTree Failed");
  431. else {
  432. OnSelchangeTymedCombobox();
  433. m_ItemPropertyListControl.DisplayItemPropData(m_WIA.GetRootIWiaItem());
  434. }
  435. }else{
  436. m_ItemPropertyListControl.DeleteAllItems();
  437. m_ItemTree.DeleteAllItems();
  438. }
  439. return TRUE;
  440. }
  441. /**************************************************************************\
  442. * CWIATestView::OnSelchangedDeviceItemTree()
  443. *
  444. * Handles the message for changing item selection in the device Item tree
  445. *
  446. *
  447. * Arguments:
  448. *
  449. * pNMHDR - Notification handler
  450. * pResult - result after notification is handled
  451. *
  452. * Return Value:
  453. *
  454. * void
  455. *
  456. * History:
  457. *
  458. * 2/14/1999 Original Version
  459. *
  460. \**************************************************************************/
  461. void CWIATestView::OnSelchangedDeviceItemTree(NMHDR* pNMHDR, LRESULT* pResult)
  462. {
  463. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  464. IWiaItem* pIWiaItem = NULL;
  465. WIAITEMTREENODE* pWiaItemTreeNode = NULL;
  466. if (m_ItemTree.GetCount() > 1) {
  467. POSITION Position = (POSITION)pNMTreeView->itemNew.lParam;
  468. if (Position) {
  469. #ifdef _SMARTUI
  470. if (m_WIA.IsRoot(Position)) {
  471. //
  472. // enable GetImageDlg button
  473. //
  474. CMainFrame* pMainFrm = (CMainFrame*)GetParent();
  475. if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_GETIMAGEDLG,FALSE))
  476. StressStatus("* GetImageDlg Button failed to be unhidden..");
  477. } else {
  478. //
  479. // disable GetImageDlg button
  480. //
  481. CMainFrame* pMainFrm = (CMainFrame*)GetParent();
  482. if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_GETIMAGEDLG,TRUE))
  483. StressStatus("* GetImageDlg Button failed to be hidden..");
  484. }
  485. #endif
  486. pWiaItemTreeNode = m_WIA.GetAt(Position);
  487. if (pWiaItemTreeNode!= NULL) {
  488. pIWiaItem = pWiaItemTreeNode->pIWiaItem;
  489. if (pIWiaItem != NULL) {
  490. //
  491. // display Item information
  492. //
  493. m_ItemPropertyListControl.DisplayItemPropData(pIWiaItem,TRUE);
  494. if (m_bThumbnailMode) {
  495. //
  496. // display item's thumbnail only if it's a child item, and
  497. // only if it's a camera child item
  498. //
  499. if ( (m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
  500. (m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo) ) {
  501. if (!m_WIA.IsRoot(Position) && !m_WIA.IsFolder(Position))
  502. DisplayItemThumbnail(pIWiaItem);
  503. }
  504. }
  505. if ((m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
  506. (m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo)) {
  507. if (!m_WIA.IsRoot(Position) && !m_WIA.IsFolder(Position)) {
  508. if (ItemHasAudio(pIWiaItem))
  509. m_PlayAudioButton.ShowWindow(SW_SHOW);
  510. else
  511. m_PlayAudioButton.ShowWindow(SW_HIDE);
  512. }
  513. else
  514. m_PlayAudioButton.ShowWindow(SW_HIDE);
  515. }
  516. OnSelchangeTymedCombobox();
  517. }
  518. }
  519. }
  520. }
  521. *pResult = 0;
  522. }
  523. /**************************************************************************\
  524. * CWIATestView::OnSelchangeDevicelistCombo()
  525. *
  526. * Handles the message for changing current devices in the device combo box
  527. *
  528. *
  529. * Arguments:
  530. *
  531. * none
  532. *
  533. * Return Value:
  534. *
  535. * void
  536. *
  537. * History:
  538. *
  539. * 2/14/1999 Original Version
  540. *
  541. \**************************************************************************/
  542. void CWIATestView::OnSelchangeDevicelistCombo()
  543. {
  544. DoDefaultUIInit();
  545. GetDocument()->SetTitle(m_DeviceListComboBox.GetCurrentDeviceName());
  546. }
  547. /**************************************************************************\
  548. * CWIATestView::OnDblclkListItemprop()
  549. *
  550. * Handles the message for double-clicking on an item in the list control
  551. *
  552. * Arguments:
  553. *
  554. * pNMHDR - Notification handler
  555. * pResult - result after notification is handled
  556. *
  557. *
  558. * Return Value:
  559. *
  560. * status
  561. *
  562. * History:
  563. *
  564. * 2/14/1999 Original Version
  565. *
  566. \**************************************************************************/
  567. void CWIATestView::OnDblclkListItemprop(NMHDR* pNMHDR, LRESULT* pResult)
  568. {
  569. CPropEdit Edit;
  570. CPropEditRange EditRange;
  571. CPropEditList EditList;
  572. CPropEditFlags EditFlags;
  573. int EditType = EDIT_NONE;
  574. ULONG AccessFlags = 0;
  575. PROPVARIANT AttrPropVar;
  576. PROPSPEC PropSpec;
  577. HRESULT hResult = S_OK;
  578. IWiaPropertyStorage *pIWiaPropStg;
  579. int nResponse = 0;
  580. //
  581. // find out what property is selected
  582. //
  583. HD_NOTIFY* phdn = (HD_NOTIFY *) pNMHDR;
  584. LV_ITEM lvitem;
  585. LONG iProp = 0;
  586. int item = phdn->iItem;
  587. //
  588. // is it a valid item?
  589. //
  590. if (item < 0)
  591. return;
  592. //
  593. // set property values to null ("")
  594. //
  595. CString strProp = "";
  596. CString strValue = "";
  597. //
  598. // Get selected values
  599. //
  600. strProp = m_ItemPropertyListControl.GetItemText(item,0);
  601. strValue = m_ItemPropertyListControl.GetItemText(item,1);
  602. lvitem.mask = LVIF_PARAM;
  603. lvitem.iItem = item;
  604. lvitem.iSubItem = 0;
  605. m_ItemPropertyListControl.GetItem(&lvitem);
  606. //
  607. // Assign Prop ID
  608. //
  609. iProp = (LONG)lvitem.lParam;
  610. //
  611. // setup dialogs with selected values (any one could be the selected type)
  612. //
  613. Edit.SetPropertyValue(strValue);
  614. Edit.SetPropertyName(strProp);
  615. EditRange.SetPropertyValue(strValue);
  616. EditRange.SetPropertyName(strProp);
  617. EditList.SetPropertyValue(strValue);
  618. EditList.SetPropertyName(strProp);
  619. EditFlags.SetPropertyValue(strValue);
  620. EditFlags.SetPropertyName(strProp);
  621. //
  622. // get access flags and var type
  623. //
  624. PropSpec.ulKind = PRSPEC_PROPID;
  625. PropSpec.propid = iProp;
  626. IWiaItem* pCurrentItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  627. if (pCurrentItem != NULL && m_WIA.IsValidItem(pCurrentItem)) {
  628. hResult = pCurrentItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  629. if (FAILED(hResult)) {
  630. StressStatus("* pCurrentItem->QueryInterface() Failed",hResult);
  631. return;
  632. } else {
  633. //
  634. // read property value for type only
  635. //
  636. PROPVARIANT PropVar;
  637. hResult = pIWiaPropStg->ReadMultiple(1,&PropSpec,&PropVar);
  638. if (hResult == S_OK) {
  639. //
  640. // write TYPE to Dialogs
  641. //
  642. Edit.SetPropertyType(PropVar.vt);
  643. EditRange.SetPropertyType(PropVar.vt);
  644. EditList.SetPropertyType(PropVar.vt);
  645. EditFlags.SetPropertyType(PropVar.vt);
  646. EditFlags.SetPropID((USHORT)iProp);
  647. } else
  648. StressStatus("* pIWiaPropStg->ReadMultiple() Failed",hResult);
  649. }
  650. hResult = pIWiaPropStg->GetPropertyAttributes(1, &PropSpec,&AccessFlags,&AttrPropVar);
  651. if (FAILED(hResult)) {
  652. StressStatus("* pCurrentItem->GetPropertyAttributes() Failed",hResult);
  653. hResult = S_OK; // do this to continue property traversal
  654. } else {
  655. //
  656. // check access flags
  657. //
  658. if ((AccessFlags & WIA_PROP_NONE)) {
  659. EditType = EDIT_NONE;
  660. }
  661. else if ((AccessFlags & WIA_PROP_RANGE)) {
  662. EditType = EDIT_RANGE;
  663. if (AttrPropVar.caul.cElems == 4) {
  664. if (EditRange.m_VT == VT_R4) {
  665. EditRange.SetRangeValues(
  666. (float)AttrPropVar.caflt.pElems[WIA_RANGE_MIN],
  667. (float)AttrPropVar.caflt.pElems[WIA_RANGE_MAX],
  668. (float)AttrPropVar.caflt.pElems[WIA_RANGE_NOM],
  669. (float)AttrPropVar.caflt.pElems[WIA_RANGE_STEP]);
  670. } else {
  671. EditRange.SetRangeValues(
  672. (int)AttrPropVar.caul.pElems[WIA_RANGE_MIN],
  673. (int)AttrPropVar.caul.pElems[WIA_RANGE_MAX],
  674. (int)AttrPropVar.caul.pElems[WIA_RANGE_NOM],
  675. (int)AttrPropVar.caul.pElems[WIA_RANGE_STEP]);
  676. }
  677. } else {
  678. //
  679. // elements does not equal 4
  680. //
  681. StressStatus("Range does not contain 4 elements");
  682. }
  683. }
  684. else if ((AccessFlags & WIA_PROP_LIST)) {
  685. UINT nElem = 0;
  686. EditType = EDIT_LIST;
  687. if(EditList.m_VT == VT_CLSID)
  688. EditList.SetArray((BYTE*)AttrPropVar.cauuid.pElems, WIA_PROP_LIST_COUNT(&AttrPropVar));
  689. else
  690. EditList.SetArray((BYTE*)AttrPropVar.caul.pElems, WIA_PROP_LIST_COUNT(&AttrPropVar));
  691. } else if ((AccessFlags & WIA_PROP_FLAG) == WIA_PROP_FLAG) {
  692. //
  693. // do flag dialog initialization here...
  694. //
  695. EditType = EDIT_FLAGS;
  696. }
  697. }
  698. //
  699. // determine which dialog to display
  700. //
  701. switch (EditType) {
  702. case EDIT_LIST:
  703. nResponse = (int) (INT_PTR)EditList.DoModal();
  704. break;
  705. case EDIT_RANGE:
  706. nResponse = (int) (INT_PTR)EditRange.DoModal();
  707. break;
  708. case EDIT_FLAGS:
  709. nResponse = (int) (INT_PTR)EditFlags.DoModal();
  710. break;
  711. default:
  712. nResponse = (int) (INT_PTR)Edit.DoModal();
  713. break;
  714. }
  715. if ((nResponse == IDOK) && (pCurrentItem != NULL)) {
  716. LONG lVal = 0;
  717. int iret = 0;
  718. if (EditType == EDIT_FLAGS) {
  719. hResult = WriteProp(EditFlags.m_VT, iProp, pIWiaPropStg, EditFlags.m_EditString.GetBuffer(20));
  720. if (hResult != S_OK)
  721. StressStatus("* WriteProp Failed Writing FLAG values",hResult);
  722. } else if (EditType == EDIT_LIST) {
  723. hResult = WriteProp(EditList.m_VT, iProp, pIWiaPropStg, EditList.m_EditString.GetBuffer(20));
  724. if (hResult != S_OK)
  725. StressStatus("* WriteProp Failed Writing LIST values",hResult);
  726. } else if (EditType == EDIT_RANGE) {
  727. hResult = WriteProp(EditRange.m_VT, iProp, pIWiaPropStg, EditRange.m_EditString.GetBuffer(20));
  728. if (hResult != S_OK)
  729. StressStatus("* WriteProp Failed Writing RANGE values",hResult);
  730. } else {
  731. hResult = WriteProp(Edit.m_VT, iProp, pIWiaPropStg, Edit.m_EditString.GetBuffer(20));
  732. if (hResult != S_OK)
  733. StressStatus("* WriteProp Failed Writing values",hResult);
  734. }
  735. //
  736. // release IPropStg and IWiaItem
  737. //
  738. pIWiaPropStg->Release();
  739. OnRefresh();
  740. }
  741. }
  742. *pResult = 0;
  743. }
  744. /**************************************************************************\
  745. * CWIATestView::OnGetimagedlg()
  746. *
  747. * Executes the GetImageDlg() call setting the intent
  748. *
  749. *
  750. * Arguments:
  751. *
  752. * none
  753. *
  754. * Return Value:
  755. *
  756. * void
  757. *
  758. * History:
  759. *
  760. * 2/14/1999 Original Version
  761. *
  762. \**************************************************************************/
  763. void CWIATestView::OnGetimagedlg()
  764. {
  765. UpdateData(TRUE);
  766. m_WIA.SetFileName(m_FileName);
  767. HRESULT hResult = S_OK;
  768. hResult = m_WIA.DoGetImageDlg(m_hWnd, 0,0,WIA_INTENT_IMAGE_TYPE_GRAYSCALE|WIA_INTENT_MINIMIZE_SIZE,m_TymedComboBox.GetCurrentTymed(),m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
  769. DisplayImage();
  770. }
  771. /**************************************************************************\
  772. * CWIATestView::OnIdtgetbanded
  773. *
  774. * Initiates a banded transfer using the currently selected item
  775. *
  776. *
  777. * Arguments:
  778. *
  779. * none
  780. *
  781. * Return Value:
  782. *
  783. * void
  784. *
  785. * History:
  786. *
  787. * 2/14/1999 Original Version
  788. *
  789. \**************************************************************************/
  790. void CWIATestView::OnIdtgetbanded()
  791. {
  792. UpdateData(TRUE);
  793. m_WIA.SetFileName(m_FileName);
  794. HRESULT hResult = S_OK;
  795. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  796. if (pIWiaItem != NULL){
  797. m_WIA.SetPreviewWindow(m_pPreviewWindow->m_hWnd);
  798. hResult = m_WIA.DoIWiaDataBandedTransfer(pIWiaItem,m_TymedComboBox.GetCurrentTymed(),m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
  799. DisplayImage();
  800. }
  801. }
  802. /**************************************************************************\
  803. * CWIATestView::
  804. *
  805. * Initiates a IWiaDataTransfer, using the currently selected item
  806. *
  807. *
  808. * Arguments:
  809. *
  810. * none
  811. *
  812. * Return Value:
  813. *
  814. * void
  815. *
  816. * History:
  817. *
  818. * 2/14/1999 Original Version
  819. *
  820. \**************************************************************************/
  821. void CWIATestView::OnWiadata()
  822. {
  823. UpdateData(TRUE);
  824. m_WIA.SetFileName(m_FileName);
  825. HRESULT hResult = S_OK;
  826. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  827. if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  828. hResult = m_WIA.DoIWiaDataGetDataTransfer(pIWiaItem,m_TymedComboBox.GetCurrentTymed(),m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
  829. DisplayImage();
  830. }
  831. }
  832. /**************************************************************************\
  833. * CWIATestView::OnAdddevice()
  834. *
  835. * Creates a thread to add a device to the Device list combo box
  836. *
  837. *
  838. * Arguments:
  839. *
  840. * none
  841. *
  842. * Return Value:
  843. *
  844. * void
  845. *
  846. * History:
  847. *
  848. * 2/14/1999 Original Version
  849. *
  850. \**************************************************************************/
  851. void CWIATestView::OnAdddevice()
  852. {
  853. static HANDLE hAddDeviceThread;
  854. static DWORD dwAddDeviceThreadId;
  855. hAddDeviceThread = CreateThread(NULL,0, &AddDeviceThread,0,0,&dwAddDeviceThreadId);
  856. if (!hAddDeviceThread)
  857. StressStatus("* CreateThread failed");
  858. }
  859. /**************************************************************************\
  860. * CWIATestView::OnRefresh()
  861. *
  862. * Forces a refresh of the selected items property data
  863. *
  864. *
  865. * Arguments:
  866. *
  867. * none
  868. *
  869. * Return Value:
  870. *
  871. * void
  872. *
  873. * History:
  874. *
  875. * 2/14/1999 Original Version
  876. *
  877. \**************************************************************************/
  878. void CWIATestView::OnRefresh()
  879. {
  880. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  881. if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem))
  882. m_ItemPropertyListControl.DisplayItemPropData(pIWiaItem);
  883. }
  884. /**************************************************************************\
  885. * AddDeviceThread
  886. *
  887. * This is a thread that controls adding a device to the device combo box
  888. *
  889. *
  890. * Arguments:
  891. *
  892. * pParam - not used at this time (extra information)
  893. *
  894. * Return Value:
  895. *
  896. * status
  897. *
  898. * History:
  899. *
  900. * 2/14/1999 Original Version
  901. *
  902. \**************************************************************************/
  903. ULONG _stdcall AddDeviceThread(LPVOID pParam)
  904. {
  905. HRESULT hResult = S_OK;
  906. CWIATestApp* pApp = (CWIATestApp*)AfxGetApp();
  907. CMainFrame* pFrame = (CMainFrame*)pApp->GetMainWnd();
  908. CWIATestView* pView = (CWIATestView*)pFrame->GetActiveView();
  909. IWiaItem* pIWiaItem = NULL;
  910. IWiaDevMgr* pIWiaDevMgr = NULL;
  911. //
  912. // initlialize OLE libs
  913. //
  914. hResult = ::OleInitialize(NULL);
  915. if (hResult != S_OK)
  916. StressStatus("* OleInitialize failed!");
  917. //
  918. // if OleInitialize is successful call CoCreateInstance for IWiaDevMgr
  919. //
  920. if (hResult == S_OK) {
  921. //
  922. // initialize IWiaDevMgr
  923. //
  924. hResult = CoCreateInstance(CLSID_WiaDevMgr, NULL, CLSCTX_LOCAL_SERVER,
  925. IID_IWiaDevMgr,(void**)&pIWiaDevMgr);
  926. if (hResult != S_OK)
  927. StressStatus("* CoCreateInstance failed - pIWiaDevMgr not created");
  928. else {
  929. StressStatus("CoCreateInstance Successful - pIWiaDevMgr created");
  930. hResult = pIWiaDevMgr->AddDeviceDlg(pFrame->m_hWnd,0);
  931. if (SUCCEEDED(hResult)){
  932. //
  933. // refresh device list
  934. //
  935. pView->RefreshDeviceList();
  936. pView->EnumerateWIADevices();
  937. //
  938. // set the default combo box settings
  939. //
  940. pView->m_DeviceListComboBox.SetCurSel(0);
  941. }
  942. else
  943. StressStatus("* No Device added ");
  944. pIWiaDevMgr->Release();
  945. }
  946. }
  947. ::OleUninitialize();
  948. return 0;
  949. }
  950. /**************************************************************************\
  951. * CWIATestView::OnViewTransferToolbar()
  952. *
  953. * Enables/Disables the Transfer toolbar
  954. *
  955. *
  956. * Arguments:
  957. *
  958. * none
  959. *
  960. * Return Value:
  961. *
  962. * void
  963. *
  964. * History:
  965. *
  966. * 2/14/1999 Original Version
  967. *
  968. \**************************************************************************/
  969. void CWIATestView::OnViewTransferToolbar()
  970. {
  971. CMainFrame* pMainFrame = (CMainFrame*)GetParent();
  972. if (pMainFrame != NULL) {
  973. if (pMainFrame->IsToolBarVisible(IDR_TRANSFER_TOOLBAR)) {
  974. //
  975. // hide toolbar
  976. //
  977. pMainFrame->ShowToolBar(IDR_TRANSFER_TOOLBAR,FALSE);
  978. } else {
  979. //
  980. // show toolbar
  981. //
  982. pMainFrame->ShowToolBar(IDR_TRANSFER_TOOLBAR,TRUE);
  983. }
  984. }
  985. }
  986. /**************************************************************************\
  987. * CWIATestView::DisplayImage
  988. *
  989. * paints the current DIB to the preview area
  990. *
  991. *
  992. * Arguments:
  993. *
  994. * none
  995. *
  996. * Return Value:
  997. *
  998. * void
  999. *
  1000. * History:
  1001. *
  1002. * 2/14/1999 Original Version
  1003. *
  1004. \**************************************************************************/
  1005. void CWIATestView::DisplayImage()
  1006. {
  1007. m_pDIB = m_WIA.GetDIB();
  1008. m_pPreviewWindow->SetPaintMode(m_PaintMode);
  1009. m_pPreviewWindow->SetDIB(m_pDIB);
  1010. m_pPreviewWindow->Invalidate();
  1011. if (m_pFullPreviewWindow != NULL) {
  1012. if (m_pFullPreviewWindow->m_hWnd != NULL) {
  1013. m_pFullPreviewWindow->SetPaintMode(PAINT_ACTUAL);
  1014. m_pFullPreviewWindow->SetDIB(m_pDIB);
  1015. m_pFullPreviewWindow->CleanBackground();
  1016. m_pFullPreviewWindow->Invalidate();
  1017. }
  1018. }
  1019. }
  1020. /**************************************************************************\
  1021. * CWIATestView::OnExecutecommand()
  1022. *
  1023. * Calls the DeviceCommand dialog, to execute device commands
  1024. *
  1025. *
  1026. * Arguments:
  1027. *
  1028. * none
  1029. *
  1030. * Return Value:
  1031. *
  1032. * void
  1033. *
  1034. * History:
  1035. *
  1036. * 2/14/1999 Original Version
  1037. *
  1038. \**************************************************************************/
  1039. void CWIATestView::OnExecutecommand()
  1040. {
  1041. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1042. if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
  1043. CDeviceCmdDlg DeviceCommandDlg;
  1044. DeviceCommandDlg.Initialize(pIWiaItem);
  1045. DeviceCommandDlg.DoModal();
  1046. OnSelchangeDevicelistCombo();
  1047. }
  1048. }
  1049. /**************************************************************************\
  1050. * CWIATestView::RegisterForAllEventsByInterface()
  1051. *
  1052. * Register this application for CONNECT/DISCONNECT events
  1053. *
  1054. *
  1055. * Arguments:
  1056. *
  1057. * none
  1058. *
  1059. * Return Value:
  1060. *
  1061. * void
  1062. *
  1063. * History:
  1064. *
  1065. * 2/14/1999 Original Version
  1066. *
  1067. \**************************************************************************/
  1068. void CWIATestView::RegisterForAllEventsByInterface()
  1069. {
  1070. //
  1071. // register connected event
  1072. //
  1073. m_pConnectEventCB = new CEventCallback;
  1074. m_pDisConnectEventCB = new CEventCallback;
  1075. m_WIA.RegisterForConnectEvents(m_pConnectEventCB);
  1076. m_WIA.RegisterForDisConnectEvents(m_pDisConnectEventCB);
  1077. }
  1078. /**************************************************************************\
  1079. * CWIATestView::UnRegisterForAllEventsByInterface()
  1080. *
  1081. * Unregister this application from CONNECT/DISCONNECT events
  1082. *
  1083. *
  1084. * Arguments:
  1085. *
  1086. * none
  1087. *
  1088. * Return Value:
  1089. *
  1090. * void
  1091. *
  1092. * History:
  1093. *
  1094. * 2/14/1999 Original Version
  1095. *
  1096. \**************************************************************************/
  1097. void CWIATestView::UnRegisterForAllEventsByInterface()
  1098. {
  1099. m_WIA.UnRegisterForConnectEvents(m_pConnectEventCB);
  1100. m_WIA.UnRegisterForDisConnectEvents(m_pDisConnectEventCB);
  1101. }
  1102. /**************************************************************************\
  1103. * CWIATestView::UpdateUI()
  1104. *
  1105. * Updates the UI by posting a selection change message on the Device list
  1106. * combo box.
  1107. * note: this is called externally, after a CONNECT/DISCONNECT event is trapped
  1108. *
  1109. *
  1110. * Arguments:
  1111. *
  1112. *
  1113. * Return Value:
  1114. *
  1115. * void
  1116. *
  1117. * History:
  1118. *
  1119. * 2/14/1999 Original Version
  1120. *
  1121. \**************************************************************************/
  1122. void CWIATestView::UpdateUI()
  1123. {
  1124. OnSelchangeDevicelistCombo();
  1125. }
  1126. /**************************************************************************\
  1127. * CWIATestView::OnDumpdrvitemInfo()
  1128. *
  1129. * Dump Driver item information for DEBUGGING ONLY
  1130. *
  1131. *
  1132. * Arguments:
  1133. *
  1134. * none
  1135. *
  1136. * Return Value:
  1137. *
  1138. * void
  1139. *
  1140. * History:
  1141. *
  1142. * 2/14/1999 Original Version
  1143. *
  1144. \**************************************************************************/
  1145. void CWIATestView::OnDumpdrvitemInfo()
  1146. {
  1147. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1148. if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
  1149. CItemInfoDlg ItemInfoDlg;
  1150. ItemInfoDlg.Initialize(pIWiaItem,FALSE);
  1151. ItemInfoDlg.DoModal();
  1152. }
  1153. }
  1154. /**************************************************************************\
  1155. * CWIATestView::OnDumpappitemInfo()
  1156. *
  1157. * Dump Application item information for DEBUGGING ONLY
  1158. *
  1159. *
  1160. * Arguments:
  1161. *
  1162. * none
  1163. *
  1164. * Return Value:
  1165. *
  1166. * void
  1167. *
  1168. * History:
  1169. *
  1170. * 2/14/1999 Original Version
  1171. *
  1172. \**************************************************************************/
  1173. void CWIATestView::OnDumpappitemInfo()
  1174. {
  1175. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1176. if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
  1177. CItemInfoDlg ItemInfoDlg;
  1178. ItemInfoDlg.Initialize(pIWiaItem,TRUE);
  1179. ItemInfoDlg.DoModal();
  1180. }
  1181. }
  1182. /**************************************************************************\
  1183. * CWIATestView::OnPaint()
  1184. *
  1185. * Handles the painting of the application window
  1186. *
  1187. *
  1188. * Arguments:
  1189. *
  1190. * none
  1191. *
  1192. * Return Value:
  1193. *
  1194. * void
  1195. *
  1196. * History:
  1197. *
  1198. * 2/14/1999 Original Version
  1199. *
  1200. \**************************************************************************/
  1201. void CWIATestView::OnPaint()
  1202. {
  1203. CPaintDC dc(this); // device context for painting
  1204. }
  1205. /**************************************************************************\
  1206. * CWIATestView::OnPaintmodeCheckbox()
  1207. *
  1208. * Enables/Disables 1 to 1 painting setting for the preview window
  1209. *
  1210. *
  1211. * Arguments:
  1212. *
  1213. * none
  1214. *
  1215. * Return Value:
  1216. *
  1217. * void
  1218. *
  1219. * History:
  1220. *
  1221. * 2/14/1999 Original Version
  1222. *
  1223. \**************************************************************************/
  1224. void CWIATestView::OnPaintmodeCheckbox()
  1225. {
  1226. if (m_PaintMode == PAINT_TOFIT)
  1227. m_PaintMode = PAINT_ACTUAL;
  1228. else
  1229. m_PaintMode = PAINT_TOFIT;
  1230. DisplayImage();
  1231. }
  1232. /**************************************************************************\
  1233. * CWIATestView::OnResetsti()
  1234. *
  1235. * Force STI to reset the current selected device.
  1236. *
  1237. *
  1238. * Arguments:
  1239. *
  1240. * none
  1241. *
  1242. * Return Value:
  1243. *
  1244. * void
  1245. *
  1246. * History:
  1247. *
  1248. * 2/14/1999 Original Version
  1249. *
  1250. \**************************************************************************/
  1251. void CWIATestView::OnResetsti()
  1252. {
  1253. //
  1254. // UnRegister from Connect / Disconnect Events
  1255. //
  1256. UnRegisterForAllEventsByInterface();
  1257. //
  1258. // cleanup all WIA devices
  1259. //
  1260. m_WIA.Shutdown();
  1261. PSTI pSti;
  1262. IStiDevice *pIStiDevice;
  1263. HRESULT hResult = S_OK;
  1264. hResult = StiCreateInstance(GetModuleHandle(NULL), STI_VERSION, &pSti, NULL);
  1265. if (hResult != S_OK)
  1266. StressStatus("* StiCreateInstance() Failed",hResult);
  1267. else {
  1268. hResult = pSti->CreateDevice(m_DeviceListComboBox.GetCurrentDeviceID(), STI_DEVICE_CREATE_STATUS, &pIStiDevice, NULL);
  1269. if (hResult != S_OK)
  1270. StressStatus("* pSti->CreateDevice() Failed",hResult);
  1271. else {
  1272. hResult = pIStiDevice->LockDevice(2000);
  1273. if (hResult != S_OK)
  1274. StressStatus("* pIStiDevice->LockDevice(2000) Failed",hResult);
  1275. else {
  1276. StressStatus("STI device is locked");
  1277. pIStiDevice->DeviceReset();
  1278. StressStatus("STI device is reset");
  1279. pIStiDevice->UnLockDevice();
  1280. StressStatus("STI device is unlocked");
  1281. pIStiDevice->Release();
  1282. pSti->Release();
  1283. }
  1284. }
  1285. }
  1286. m_WIA.Restart();
  1287. //
  1288. // Reform UI
  1289. //
  1290. DoDefaultUIInit();
  1291. //
  1292. // Register for Connect / Disconnect Events
  1293. //
  1294. RegisterForAllEventsByInterface();
  1295. }
  1296. /**************************************************************************\
  1297. * CWIATestView::OnFullpreview()
  1298. *
  1299. * Initiate a full preview window (scrolling enabled for larger pictures)
  1300. *
  1301. *
  1302. * Arguments:
  1303. *
  1304. * none
  1305. *
  1306. * Return Value:
  1307. *
  1308. * void
  1309. *
  1310. * History:
  1311. *
  1312. * 2/14/1999 Original Version
  1313. *
  1314. \**************************************************************************/
  1315. void CWIATestView::OnFullpreview()
  1316. {
  1317. if (m_pFullPreviewWindow == NULL) {
  1318. m_pFullPreviewWindow = new CWIAPreview;
  1319. if (m_pFullPreviewWindow != NULL) {
  1320. RECT PreviewFrameRect;
  1321. PreviewFrameRect.left = 0;
  1322. PreviewFrameRect.top = 0;
  1323. PreviewFrameRect.right = 400;
  1324. PreviewFrameRect.bottom = 400;
  1325. if (!m_pFullPreviewWindow->CreateEx(NULL,AfxRegisterWndClass(NULL),"WIA Preview Window",WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE,PreviewFrameRect,NULL,NULL,NULL)) {
  1326. StressStatus("FULL Preview Window Failed to create..",0);
  1327. } else {
  1328. //
  1329. // paint NULL image (white background)
  1330. //
  1331. DisplayImage();
  1332. }
  1333. }
  1334. } else {
  1335. if (m_pFullPreviewWindow->m_hWnd == NULL) {
  1336. RECT PreviewFrameRect;
  1337. PreviewFrameRect.left = 0;
  1338. PreviewFrameRect.top = 0;
  1339. PreviewFrameRect.right = 400;
  1340. PreviewFrameRect.bottom = 400;
  1341. if (!m_pFullPreviewWindow->CreateEx(NULL,AfxRegisterWndClass(NULL),"WIA Preview Window",WS_OVERLAPPEDWINDOW|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE,PreviewFrameRect,NULL,NULL,NULL)) {
  1342. StressStatus("FULL Preview Window Failed to create..",0);
  1343. } else {
  1344. //
  1345. // paint NULL image (white background)
  1346. //
  1347. DisplayImage();
  1348. }
  1349. }
  1350. m_pFullPreviewWindow->ShowWindow(SW_SHOW);
  1351. }
  1352. }
  1353. /**************************************************************************\
  1354. * CWIATestView::ResizeControls()
  1355. *
  1356. * Resize the controls along with the main frame window
  1357. *
  1358. *
  1359. * Arguments:
  1360. *
  1361. * dx - change in width of main window
  1362. * dy - change in height on main window
  1363. *
  1364. *
  1365. * Return Value:
  1366. *
  1367. * void
  1368. *
  1369. * History:
  1370. *
  1371. * 2/14/1999 Original Version
  1372. *
  1373. \**************************************************************************/
  1374. void CWIATestView::ResizeControls(int dx, int dy)
  1375. {
  1376. m_ItemPropertyListControl.Resize(dx,dy);
  1377. }
  1378. /**************************************************************************\
  1379. * CWIATestView::OnThumbnailmode()
  1380. *
  1381. * Enables/Disables thumbnailing for picture items on digitial cameras
  1382. *
  1383. *
  1384. * Arguments:
  1385. *
  1386. * none
  1387. *
  1388. * Return Value:
  1389. *
  1390. * void
  1391. *
  1392. * History:
  1393. *
  1394. * 2/14/1999 Original Version
  1395. *
  1396. \**************************************************************************/
  1397. void CWIATestView::OnThumbnailmode()
  1398. {
  1399. POSITION Position = NULL;
  1400. HTREEITEM hTreeItem = NULL;
  1401. if (m_bThumbnailMode)
  1402. m_bThumbnailMode = FALSE;
  1403. else {
  1404. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1405. if (pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)) {
  1406. if ((m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
  1407. (m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo)) {
  1408. hTreeItem = m_ItemTree.GetSelectedItem();
  1409. if (hTreeItem != NULL) {
  1410. Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
  1411. if (!m_WIA.IsRoot(Position) && !m_WIA.IsFolder(Position))
  1412. DisplayItemThumbnail(pIWiaItem);
  1413. }
  1414. }
  1415. }
  1416. m_bThumbnailMode = TRUE;
  1417. }
  1418. }
  1419. /**************************************************************************\
  1420. * CWIATestView::DisplayItemThumbnail()
  1421. *
  1422. * Display thumbnail for the target item
  1423. *
  1424. *
  1425. * Arguments:
  1426. *
  1427. * pIWiaItem - Target item to thumbnail
  1428. *
  1429. * Return Value:
  1430. *
  1431. * void
  1432. *
  1433. * History:
  1434. *
  1435. * 2/14/1999 Original Version
  1436. *
  1437. \**************************************************************************/
  1438. void CWIATestView::DisplayItemThumbnail(IWiaItem *pIWiaItem)
  1439. {
  1440. long ThumbNailHeight = 0;
  1441. long ThumbNailWidth = 0;
  1442. long ThumbNailSize = 0;
  1443. if (m_pThumbNail != NULL) {
  1444. LocalFree(m_pThumbNail);
  1445. m_pThumbNail = NULL;
  1446. }
  1447. if (m_hBitmap != NULL) {
  1448. DeleteObject(m_hBitmap);
  1449. m_hBitmap = NULL;
  1450. }
  1451. m_pThumbNail = NULL;
  1452. IWiaPropertyStorage *pIWiaPropStg;
  1453. HRESULT hResult = S_OK;
  1454. HBITMAP hBitmap = NULL;
  1455. // get item's thumbnail height & width and create thumbnail
  1456. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  1457. if (hResult == S_OK) {
  1458. //
  1459. // read height
  1460. //
  1461. hResult = ReadPropLong(WIA_IPC_THUMB_HEIGHT, pIWiaPropStg, &ThumbNailHeight);
  1462. if (hResult != S_OK) {
  1463. StressStatus("* ReadPropLong(WIA_IPC_THUMB_HEIGHT) Failed",hResult);
  1464. ThumbNailHeight = 0;
  1465. }
  1466. //
  1467. // read width
  1468. //
  1469. hResult = ReadPropLong(WIA_IPC_THUMB_WIDTH, pIWiaPropStg, &ThumbNailWidth);
  1470. if (hResult != S_OK) {
  1471. StressStatus("* ReadPropLong(WIA_IPC_THUMB_WIDTH) Failed",hResult);
  1472. ThumbNailWidth = 0;
  1473. }
  1474. //
  1475. // read thumbnail data
  1476. //
  1477. PROPVARIANT PropVar[1];
  1478. PROPSPEC PropSpec[1];
  1479. memset(PropVar, 0, sizeof(PropVar));
  1480. PropSpec[0].ulKind = PRSPEC_PROPID;
  1481. PropSpec[0].propid = WIA_IPC_THUMBNAIL;
  1482. hResult = pIWiaPropStg->ReadMultiple(1, PropSpec, PropVar);
  1483. if (hResult != S_OK) {
  1484. StressStatus("* ReadMultiple() asking for WIA_IPC_THUMBNAIL Failed",hResult);
  1485. m_pThumbNail = NULL;
  1486. } else {
  1487. ThumbNailSize = ThumbNailWidth * ThumbNailHeight * 3;
  1488. if (ThumbNailSize != (LONG)PropVar[0].caub.cElems) {
  1489. //
  1490. // force size to thumbnail's suggested size
  1491. //
  1492. ThumbNailSize = PropVar[0].caub.cElems;
  1493. }
  1494. m_pThumbNail = (PBYTE)LocalAlloc(LPTR,ThumbNailSize);
  1495. if (m_pThumbNail != NULL) {
  1496. memcpy(m_pThumbNail,PropVar[0].caub.pElems,ThumbNailSize);
  1497. HDC hdc = ::GetDC(NULL);
  1498. HDC hdcm = CreateCompatibleDC(hdc);
  1499. BITMAPINFO bmi;
  1500. bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  1501. bmi.bmiHeader.biWidth = ThumbNailWidth;
  1502. bmi.bmiHeader.biHeight = ThumbNailHeight;
  1503. bmi.bmiHeader.biPlanes = 1;
  1504. bmi.bmiHeader.biBitCount = 24;
  1505. bmi.bmiHeader.biCompression = BI_RGB;
  1506. bmi.bmiHeader.biSizeImage = 0;
  1507. bmi.bmiHeader.biXPelsPerMeter = 0;
  1508. bmi.bmiHeader.biYPelsPerMeter = 0;
  1509. bmi.bmiHeader.biClrUsed = 0;
  1510. bmi.bmiHeader.biClrImportant = 0;
  1511. PBYTE pDib = NULL;
  1512. m_hBitmap = CreateDIBSection(hdc,&bmi,DIB_RGB_COLORS,(void **)&pDib,NULL,0);
  1513. memcpy(pDib,m_pThumbNail,ThumbNailSize);
  1514. m_ThumbnailImage.SetBitmap(m_hBitmap);
  1515. m_ThumbnailImage.Invalidate();
  1516. }
  1517. }
  1518. //
  1519. // release propstg
  1520. //
  1521. pIWiaPropStg->Release();
  1522. }
  1523. }
  1524. /**************************************************************************\
  1525. * CWIATestView::OnDeleteitem()
  1526. *
  1527. * Deletes the selected item
  1528. *
  1529. *
  1530. * Arguments:
  1531. *
  1532. * none
  1533. *
  1534. * Return Value:
  1535. *
  1536. * void
  1537. *
  1538. * History:
  1539. *
  1540. * 2/14/1999 Original Version
  1541. *
  1542. \**************************************************************************/
  1543. void CWIATestView::OnDeleteitem()
  1544. {
  1545. HRESULT hResult = S_OK;
  1546. POSITION TestPosition = NULL;
  1547. POSITION Position = NULL;
  1548. HTREEITEM hTreeItem = NULL;
  1549. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1550. if (pIWiaItem == NULL) {
  1551. StressStatus("* Item selected for deletion is NULL!!!");
  1552. return;
  1553. }
  1554. if ((m_WIA.GetRootItemType() == StiDeviceTypeDigitalCamera) ||
  1555. (m_WIA.GetRootItemType() == StiDeviceTypeStreamingVideo)) {
  1556. //
  1557. // Get selected item (to be deleted)
  1558. //
  1559. hTreeItem = m_ItemTree.GetSelectedItem();
  1560. if (hTreeItem != NULL) {
  1561. //
  1562. // What's the selected item's position in the
  1563. // m_ActiveTreeList??
  1564. //
  1565. Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
  1566. }
  1567. //
  1568. // test to make sure it's not a root item
  1569. //
  1570. if (!m_WIA.IsRoot(Position)) {
  1571. if (pIWiaItem != NULL) {
  1572. hResult = pIWiaItem->DeleteItem(0);
  1573. if (hResult == S_OK) {
  1574. //
  1575. // release selected item
  1576. //
  1577. pIWiaItem->Release();
  1578. //
  1579. // kill item from m_ActiveTreeList
  1580. //
  1581. m_WIA.RemoveAt(Position);
  1582. //
  1583. // kill item from tree control (visual delete)
  1584. //
  1585. m_ItemTree.DeleteItem(hTreeItem);
  1586. }
  1587. }
  1588. } else
  1589. AfxMessageBox("You can not delete the Root Item");
  1590. } else {
  1591. //
  1592. // Get selected item (to be deleted)
  1593. //
  1594. hTreeItem = m_ItemTree.GetSelectedItem();
  1595. if (hTreeItem != NULL) {
  1596. //
  1597. // What's the selected item's position in the
  1598. // m_ActiveTreeList??
  1599. //
  1600. Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
  1601. }
  1602. //
  1603. // test to make sure it's not a root item
  1604. //
  1605. if (!m_WIA.IsRoot(Position)) {
  1606. if (pIWiaItem != NULL) {
  1607. if (MessageBox("You just attempted to delete a scanner item..\nDo you really want to execute a DeleteItem()\ncall on this scanner item to see what happens?","WIATest Testing Question",MB_YESNO|MB_ICONQUESTION) == IDYES) {
  1608. hResult = pIWiaItem->DeleteItem(0);
  1609. if (hResult == S_OK) {
  1610. OnReenumitems();
  1611. } else
  1612. StressStatus("* pIWiaItem->DeleteItem() called on a scanner item Failed",hResult);
  1613. }
  1614. }
  1615. } else
  1616. AfxMessageBox("You can not delete the Root Item");
  1617. }
  1618. }
  1619. /**************************************************************************\
  1620. * CWIATestView::OnSelchangeTymedCombobox()
  1621. *
  1622. * Handles the message for a selection change in the TYMED combo box
  1623. *
  1624. *
  1625. * Arguments:
  1626. *
  1627. * none
  1628. *
  1629. * Return Value:
  1630. *
  1631. * void
  1632. *
  1633. * History:
  1634. *
  1635. * 2/14/1999 Original Version
  1636. *
  1637. \**************************************************************************/
  1638. void CWIATestView::OnSelchangeTymedCombobox()
  1639. {
  1640. if (m_TymedComboBox.GetCurrentTymed() != TYMED_FILE) {
  1641. //
  1642. // disable File Edit box
  1643. //
  1644. CWnd* pWnd = GetDlgItem(IDC_FILENAME_EDITBOX);
  1645. if (pWnd != NULL)
  1646. pWnd->EnableWindow(FALSE);
  1647. } else {
  1648. //
  1649. // enable File Edit box
  1650. //
  1651. CWnd* pWnd = GetDlgItem(IDC_FILENAME_EDITBOX);
  1652. if (pWnd != NULL)
  1653. pWnd->EnableWindow(TRUE);
  1654. }
  1655. #ifdef _SMARTUI
  1656. if (m_TymedComboBox.GetCurrentTymed() == TYMED_CALLBACK) {
  1657. //
  1658. // hide IWiaData Toolbar button and
  1659. // unhide idtGetBanded Toolbar button
  1660. //
  1661. CMainFrame* pMainFrm = (CMainFrame*)GetParent();
  1662. if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_IDTGETBANDED,FALSE))
  1663. StressStatus("* idtGetBanded Button failed to be unhidden..");
  1664. if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_WIADATA,TRUE))
  1665. StressStatus("* IWiaData Button failed to be hidden..");
  1666. } else {
  1667. //
  1668. // hide idtGetBanded Toolbar button and
  1669. // unhide IWiaData Toolbar button
  1670. //
  1671. CMainFrame* pMainFrm = (CMainFrame*)GetParent();
  1672. if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_IDTGETBANDED,TRUE))
  1673. StressStatus("* idtGetBanded Button failed to be hidden..");
  1674. if(!pMainFrm->HideToolBarButton(IDR_TRANSFER_TOOLBAR,ID_WIADATA,FALSE))
  1675. StressStatus("* IWiaData Button failed to be unhidden..");
  1676. }
  1677. #endif
  1678. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1679. if (pIWiaItem != NULL) {
  1680. m_WIA.EnumerateSupportedFormats(pIWiaItem);
  1681. m_ClipboardFormatComboBox.InitClipboardFormats(m_WIA.GetSupportedFormatList(),m_TymedComboBox.GetCurrentTymed());
  1682. }
  1683. //
  1684. // Force update and change..
  1685. //
  1686. OnSelchangeClipboardFormatCombobox();
  1687. }
  1688. /**************************************************************************\
  1689. * CWIATestView::OnSelchangeClipboardFormatCombobox()
  1690. *
  1691. * Handles the message for a selection change in the clipboard format combo box
  1692. *
  1693. *
  1694. * Arguments:
  1695. *
  1696. * -
  1697. * -
  1698. * -
  1699. *
  1700. * Return Value:
  1701. *
  1702. * status
  1703. *
  1704. * History:
  1705. *
  1706. * 2/14/1999 Original Version
  1707. *
  1708. \**************************************************************************/
  1709. void CWIATestView::OnSelchangeClipboardFormatCombobox()
  1710. {
  1711. HRESULT hResult = S_OK;
  1712. POSITION Position = NULL;
  1713. HTREEITEM hTreeItem = NULL;
  1714. IWiaPropertyStorage *pIWiaPropStg;
  1715. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1716. if (pIWiaItem == NULL) {
  1717. StressStatus("* Item selected for setting is NULL!!!");
  1718. return;
  1719. }
  1720. //
  1721. // Get selected item
  1722. //
  1723. hTreeItem = m_ItemTree.GetSelectedItem();
  1724. if (hTreeItem != NULL) {
  1725. //
  1726. // What's the selected item's position in the
  1727. // m_ActiveTreeList??
  1728. //
  1729. Position = (POSITION)m_ItemTree.GetItemData(hTreeItem);
  1730. }
  1731. //
  1732. // test to make sure it's not a root item
  1733. //
  1734. if (!m_WIA.IsRoot(Position)) {
  1735. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  1736. if (hResult != S_OK) {
  1737. StressStatus("* pCurrentItem->QueryInterface() Failed",hResult);
  1738. return;
  1739. } else {
  1740. //
  1741. // Write property value for TYMED
  1742. //
  1743. hResult = WritePropLong(WIA_IPA_TYMED,pIWiaPropStg,m_TymedComboBox.GetCurrentTymed());
  1744. if (hResult == S_OK)
  1745. StressStatus("tymed Successfully written");
  1746. else
  1747. StressStatus("* WritePropLong(WIA_IPA_TYMED) Failed",hResult);
  1748. //
  1749. // Write property value for SUPPORTED WIA FORMAT
  1750. //
  1751. hResult = WritePropGUID(WIA_IPA_FORMAT,pIWiaPropStg,m_ClipboardFormatComboBox.GetCurrentClipboardFormat());
  1752. if (hResult == S_OK)
  1753. StressStatus("Format Successfully written");
  1754. else
  1755. StressStatus("* WritePropLong(WIA_IPA_FORMAT) Failed",hResult);
  1756. OnRefresh();
  1757. }
  1758. }
  1759. }
  1760. /**************************************************************************\
  1761. * CWIATestView::OnUpdateViewTransferToolbar()
  1762. *
  1763. * Updates the Check/uncheck display on the menu for toolbar display status
  1764. *
  1765. *
  1766. * Arguments:
  1767. *
  1768. * pCmdUI - CommandUI handler
  1769. *
  1770. * Return Value:
  1771. *
  1772. * status
  1773. *
  1774. * History:
  1775. *
  1776. * 2/14/1999 Original Version
  1777. *
  1778. \**************************************************************************/
  1779. void CWIATestView::OnUpdateViewTransferToolbar(CCmdUI* pCmdUI)
  1780. {
  1781. CMainFrame* pMainFrm = (CMainFrame*)GetParent();
  1782. if(pMainFrm != NULL)
  1783. pCmdUI->SetCheck(pMainFrm->IsToolBarVisible(IDR_TRANSFER_TOOLBAR));
  1784. }
  1785. /**************************************************************************\
  1786. * CWIATestView::OnPlayaudioButton()
  1787. *
  1788. * Plays .WAV data from an item that supports audio
  1789. *
  1790. *
  1791. * Arguments:
  1792. *
  1793. * none
  1794. *
  1795. * Return Value:
  1796. *
  1797. * void
  1798. *
  1799. * History:
  1800. *
  1801. * 2/14/1999 Original Version
  1802. *
  1803. \**************************************************************************/
  1804. void CWIATestView::OnPlayaudioButton()
  1805. {
  1806. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1807. if(pIWiaItem != NULL){
  1808. IWiaPropertyStorage *pIWiaPropStg;
  1809. PROPSPEC PropSpec[1];
  1810. PROPVARIANT PropVar[1];
  1811. PropSpec[0].ulKind = PRSPEC_PROPID;
  1812. PropSpec[0].propid = WIA_IPC_AUDIO_DATA;
  1813. memset(PropVar, 0, sizeof(PropVar));
  1814. HRESULT hResult = S_OK;
  1815. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  1816. if (hResult == S_OK) {
  1817. hResult = pIWiaPropStg->ReadMultiple(1, PropSpec, PropVar);
  1818. if(hResult == S_OK){
  1819. DWORD dwAudioSize = PropVar->caub.cElems;
  1820. BYTE* pAudioData = PropVar->caub.pElems;
  1821. if(pAudioData != NULL){
  1822. CFile AudioFile;
  1823. //
  1824. // open & write audio file
  1825. //
  1826. AudioFile.Open(m_AudioFileName,CFile::modeCreate|CFile::modeWrite,NULL);
  1827. AudioFile.Write(pAudioData,dwAudioSize);
  1828. AudioFile.Close();
  1829. PlaySound(m_AudioFileName,NULL,SND_FILENAME);
  1830. DeleteFile(m_AudioFileName);
  1831. }
  1832. }
  1833. else
  1834. StressStatus("* ReadMultiple(WIA_IPC_AUDIO_DATA) Failed",hResult);
  1835. }
  1836. }
  1837. }
  1838. /**************************************************************************\
  1839. * CWIATestView::ItemHasAudio()
  1840. *
  1841. * Determines if an item supports audio data, or contains data to be accessed.
  1842. *
  1843. *
  1844. * Arguments:
  1845. *
  1846. * pIWiaData - Target item to check for audio data
  1847. *
  1848. * Return Value:
  1849. *
  1850. * status
  1851. *
  1852. * History:
  1853. *
  1854. * 2/14/1999 Original Version
  1855. *
  1856. \**************************************************************************/
  1857. BOOL CWIATestView::ItemHasAudio(IWiaItem* pIWiaItem)
  1858. {
  1859. long lVal = 0;
  1860. if (pIWiaItem != NULL) {
  1861. IWiaPropertyStorage *pIWiaPropStg;
  1862. HRESULT hResult = S_OK;
  1863. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  1864. if (hResult == S_OK) {
  1865. //
  1866. // read Item's Audio flag
  1867. //
  1868. hResult = ReadPropLong(WIA_IPC_AUDIO_AVAILABLE, pIWiaPropStg, &lVal);
  1869. if (hResult != S_OK){
  1870. if(hResult != S_FALSE){
  1871. StressStatus("* ReadPropLong(WIA_IPC_AUDIO_AVAILABLE) Failed",hResult);
  1872. }
  1873. pIWiaPropStg->Release();
  1874. }
  1875. else
  1876. pIWiaPropStg->Release();
  1877. if(lVal)
  1878. return TRUE;
  1879. else
  1880. return FALSE;
  1881. }
  1882. }
  1883. return FALSE;
  1884. }
  1885. /**************************************************************************\
  1886. * CWIATestView::RefreshDeviceList()
  1887. *
  1888. * Called externally to force a reenumeration of WIA devices on the system
  1889. *
  1890. *
  1891. * Arguments:
  1892. *
  1893. * none
  1894. *
  1895. * Return Value:
  1896. *
  1897. * void
  1898. *
  1899. * History:
  1900. *
  1901. * 2/14/1999 Original Version
  1902. *
  1903. \**************************************************************************/
  1904. void CWIATestView::RefreshDeviceList()
  1905. {
  1906. m_WIA.EnumerateAllWIADevices();
  1907. }
  1908. /**************************************************************************\
  1909. * CWIATestView::OnGetrootitemtest()
  1910. *
  1911. * Gets the selected item, and gets the root item from it.
  1912. * Driver and application item information are dumped.
  1913. * DEBUGGING ONLY
  1914. *
  1915. * Arguments:
  1916. *
  1917. * none
  1918. *
  1919. * Return Value:
  1920. *
  1921. * void
  1922. *
  1923. * History:
  1924. *
  1925. * 2/14/1999 Original Version
  1926. *
  1927. \**************************************************************************/
  1928. void CWIATestView::OnGetrootitemtest()
  1929. {
  1930. HRESULT hr = S_OK;
  1931. IWiaItem* pIWiaItem = NULL;
  1932. IWiaItem* pNewRootItem = NULL;
  1933. pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  1934. if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  1935. hr = pIWiaItem->GetRootItem(&pNewRootItem);
  1936. if(hr == S_OK){
  1937. CItemInfoDlg ItemInfoDlg;
  1938. ItemInfoDlg.Initialize(pNewRootItem,TRUE);
  1939. ItemInfoDlg.DoModal();
  1940. CItemInfoDlg ItemInfoDlg2;
  1941. ItemInfoDlg2.Initialize(pNewRootItem,FALSE);
  1942. ItemInfoDlg2.DoModal();
  1943. pNewRootItem->Release();
  1944. }
  1945. }
  1946. }
  1947. /**************************************************************************\
  1948. * CWIATestView::OnReenumitems()
  1949. *
  1950. * Force a rennumeration of all child items, preserving the ROOT item
  1951. *
  1952. *
  1953. * Arguments:
  1954. *
  1955. * none
  1956. *
  1957. * Return Value:
  1958. *
  1959. * void
  1960. *
  1961. * History:
  1962. *
  1963. * 2/14/1999 Original Version
  1964. *
  1965. \**************************************************************************/
  1966. void CWIATestView::OnReenumitems()
  1967. {
  1968. HRESULT hResult = S_OK;
  1969. if (SUCCEEDED(m_WIA.ReEnumerateItems())){
  1970. if (!m_ItemTree.BuildItemTree(m_WIA.GetItemTreeList()))
  1971. StressStatus("* BuildItemTree Failed");
  1972. else{
  1973. OnSelchangeTymedCombobox();
  1974. m_ItemPropertyListControl.DisplayItemPropData(m_WIA.GetRootIWiaItem());
  1975. }
  1976. }else{
  1977. m_ItemPropertyListControl.DeleteAllItems();
  1978. m_ItemTree.DeleteAllItems();
  1979. }
  1980. }
  1981. /**************************************************************************\
  1982. * CWIATestView::OnSavepropstream()
  1983. *
  1984. * Writes the currently selected item's property stream to a data file
  1985. * "propstrm.wia"
  1986. *
  1987. *
  1988. * Arguments:
  1989. *
  1990. * none
  1991. *
  1992. * Return Value:
  1993. *
  1994. * void
  1995. *
  1996. * History:
  1997. *
  1998. * 2/14/1999 Original Version
  1999. *
  2000. \**************************************************************************/
  2001. void CWIATestView::OnSavepropstream()
  2002. {
  2003. HRESULT hResult = S_OK;
  2004. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  2005. if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  2006. hResult = m_WIA.SavePropStreamToFile("propstrm.wia", pIWiaItem);
  2007. if (SUCCEEDED(hResult))
  2008. StressStatus("Stream was saved successfully...");
  2009. else
  2010. StressStatus("* Stream Failed to be saved...",hResult);
  2011. }
  2012. else
  2013. StressStatus("* Target Item is NULL");
  2014. }
  2015. /**************************************************************************\
  2016. * CWIATestView::OnLoadpropstream()
  2017. *
  2018. * Reads a previously saved property stream file, and creates a property
  2019. * stream. This stream is then set to the currently selected item.
  2020. *
  2021. *
  2022. * Arguments:
  2023. *
  2024. * none
  2025. *
  2026. * Return Value:
  2027. *
  2028. * void
  2029. *
  2030. * History:
  2031. *
  2032. * 2/14/1999 Original Version
  2033. *
  2034. \**************************************************************************/
  2035. void CWIATestView::OnLoadpropstream()
  2036. {
  2037. HRESULT hResult = S_OK;
  2038. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  2039. if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  2040. hResult = m_WIA.ReadPropStreamFromFile("propstrm.wia", pIWiaItem);
  2041. if (SUCCEEDED(hResult))
  2042. StressStatus("Stream was restored successfully...");
  2043. else
  2044. StressStatus("* Stream Failed to be saved...",hResult);
  2045. }
  2046. else
  2047. StressStatus("* Target Item is NULL");
  2048. //
  2049. // Refresh property display
  2050. //
  2051. OnRefresh();
  2052. }
  2053. /**************************************************************************\
  2054. * CWIATestView::OnGetSetPropstreamTest()
  2055. *
  2056. * Gets a property stream from the currently selected item, and then
  2057. * Sets the same stream back to it.
  2058. *
  2059. *
  2060. * Arguments:
  2061. *
  2062. * none
  2063. *
  2064. * Return Value:
  2065. *
  2066. * void
  2067. *
  2068. * History:
  2069. *
  2070. * 2/14/1999 Original Version
  2071. *
  2072. \**************************************************************************/
  2073. void CWIATestView::OnGetSetPropstreamTest()
  2074. {
  2075. HRESULT hResult = S_OK;
  2076. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  2077. if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  2078. hResult = m_WIA.GetSetPropStreamTest(pIWiaItem);
  2079. if (SUCCEEDED(hResult))
  2080. StressStatus("GET / SET Test was successful ");
  2081. else
  2082. StressStatus("* GET / SET Test Failed...",hResult);
  2083. }
  2084. else
  2085. StressStatus("* Target Item is NULL");
  2086. //
  2087. // Refresh property display
  2088. //
  2089. OnRefresh();
  2090. }
  2091. /**************************************************************************\
  2092. * CWIATestView::OnAnalyzeItem()
  2093. *
  2094. * Runs the AnalyzeItem method of the currently selected item.
  2095. *
  2096. *
  2097. * Arguments:
  2098. *
  2099. * none
  2100. *
  2101. * Return Value:
  2102. *
  2103. * void
  2104. *
  2105. * History:
  2106. *
  2107. * 01/13/2000 Original Version
  2108. *
  2109. \**************************************************************************/
  2110. void CWIATestView::OnAnalyzeItem()
  2111. {
  2112. HRESULT hResult = S_OK;
  2113. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  2114. if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  2115. hResult = m_WIA.AnalyzeItem(pIWiaItem);
  2116. if (SUCCEEDED(hResult)) {
  2117. StressStatus("AnalyzeItem run successfully...");
  2118. OnReenumitems();
  2119. }
  2120. else
  2121. StressStatus("* AnalyzeItem failed...",hResult);
  2122. }
  2123. else
  2124. StressStatus("* Target Item is NULL");
  2125. }
  2126. /**************************************************************************\
  2127. * CWIATestView::OnCreateChildItem()
  2128. *
  2129. * Runs the AnalyzeItem method of the currently selected item.
  2130. *
  2131. *
  2132. * Arguments:
  2133. *
  2134. * none
  2135. *
  2136. * Return Value:
  2137. *
  2138. * void
  2139. *
  2140. * History:
  2141. *
  2142. * 01/13/2000 Original Version
  2143. *
  2144. \**************************************************************************/
  2145. void CWIATestView::OnCreateChildItem()
  2146. {
  2147. HRESULT hResult = S_OK;
  2148. IWiaItem* pIWiaItem = m_ItemTree.GetSelectedIWiaItem(m_WIA.GetItemTreeList());
  2149. if(pIWiaItem != NULL && m_WIA.IsValidItem(pIWiaItem)){
  2150. hResult = m_WIA.CreateChildItem(pIWiaItem);
  2151. if (SUCCEEDED(hResult)) {
  2152. StressStatus("Successfully created a new child item...");
  2153. OnReenumitems();
  2154. }
  2155. else
  2156. StressStatus("* CreateChildItem failed...",hResult);
  2157. }
  2158. else
  2159. StressStatus("* Target Item is NULL");
  2160. }