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.

1655 lines
44 KiB

  1. // WIATestUI.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "WIATest.h"
  5. #include "WIATestUI.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CWIAPropListCtrl
  13. /**************************************************************************\
  14. * CWIAPropListCtrl::CWIAPropListCtrl()
  15. *
  16. * Constructor for the CWIAPropListCtrl class
  17. *
  18. *
  19. * Arguments:
  20. *
  21. * none
  22. *
  23. * Return Value:
  24. *
  25. * none
  26. *
  27. * History:
  28. *
  29. * 2/14/1999 Original Version
  30. *
  31. \**************************************************************************/
  32. CWIAPropListCtrl::CWIAPropListCtrl()
  33. {
  34. }
  35. /**************************************************************************\
  36. * CWIAPropListCtrl::~CWIAPropListCtrl()
  37. *
  38. * Destructor for the CWIAPropListCtrl class
  39. *
  40. *
  41. * Arguments:
  42. *
  43. * none
  44. *
  45. * Return Value:
  46. *
  47. * none
  48. *
  49. * History:
  50. *
  51. * 2/14/1999 Original Version
  52. *
  53. \**************************************************************************/
  54. CWIAPropListCtrl::~CWIAPropListCtrl()
  55. {
  56. }
  57. BEGIN_MESSAGE_MAP(CWIAPropListCtrl, CListCtrl)
  58. //{{AFX_MSG_MAP(CWIAPropListCtrl)
  59. ON_WM_SHOWWINDOW()
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // CWIAPropListCtrl message handlers
  64. /**************************************************************************\
  65. * CWIAPropListCtrl::InitHeaders()
  66. *
  67. * Constructs the headers / colums for the list control
  68. *
  69. *
  70. * Arguments:
  71. *
  72. * none
  73. *
  74. * Return Value:
  75. *
  76. * none
  77. *
  78. * History:
  79. *
  80. * 2/14/1999 Original Version
  81. *
  82. \**************************************************************************/
  83. void CWIAPropListCtrl::InitHeaders()
  84. {
  85. LVCOLUMN lv;
  86. int i = 0;
  87. // initialize item property list control column headers
  88. // Property name
  89. lv.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
  90. lv.fmt = LVCFMT_LEFT ;
  91. lv.cx = 100;
  92. lv.pszText = "Property";
  93. lv.cchTextMax = 0;
  94. lv.iSubItem = 0;
  95. lv.iImage = 0;
  96. lv.iOrder = 0;
  97. i = InsertColumn(0,&lv);
  98. // Property Value (current)
  99. lv.cx = 125;
  100. lv.iOrder = 1;
  101. lv.iSubItem = 1;
  102. lv.pszText = "Value";
  103. i = InsertColumn(1,&lv);
  104. // VT_???
  105. lv.cx = 85;
  106. lv.iOrder = 2;
  107. lv.iSubItem = 2;
  108. lv.pszText = "Var Type";
  109. i = InsertColumn(2,&lv);
  110. // Property access Flags
  111. lv.cx = 500;
  112. lv.iOrder = 3;
  113. lv.iSubItem = 3;
  114. lv.pszText = "Access Flags";
  115. i = InsertColumn(3,&lv);
  116. }
  117. /**************************************************************************\
  118. * CWIAPropListCtrl::ConvertPropVarToString()
  119. *
  120. * Converts the Property value to a string for display only
  121. *
  122. *
  123. * Arguments:
  124. *
  125. * pPropVar - Target Property Variant
  126. * pszVal - String value converted
  127. *
  128. * Return Value:
  129. *
  130. * none
  131. *
  132. * History:
  133. *
  134. * 2/14/1999 Original Version
  135. *
  136. \**************************************************************************/
  137. void CWIAPropListCtrl::ConvertPropVarToString(PROPVARIANT *pPropVar,LPSTR szVal)
  138. {
  139. char szValue[MAX_PATH];
  140. switch (pPropVar->vt) {
  141. case VT_I1:
  142. {
  143. sprintf(szValue,"%d",pPropVar->cVal);
  144. strcpy(szVal,szValue);
  145. }
  146. break;
  147. case VT_UI1:
  148. {
  149. sprintf(szValue,"%d",pPropVar->bVal);
  150. strcpy(szVal,szValue);
  151. }
  152. break;
  153. case VT_I2:
  154. {
  155. sprintf(szValue,"%d",pPropVar->iVal);
  156. strcpy(szVal,szValue);
  157. }
  158. break;
  159. case VT_UI2:
  160. {
  161. sprintf(szValue,"%d",pPropVar->uiVal);
  162. strcpy(szVal,szValue);
  163. }
  164. break;
  165. case VT_UI4:
  166. {
  167. sprintf(szValue,"%d",pPropVar->ulVal);
  168. strcpy(szVal,szValue);
  169. }
  170. break;
  171. case VT_UI8:
  172. {
  173. sprintf(szValue,"%d",pPropVar->lVal);
  174. strcpy(szVal,szValue);
  175. }
  176. break;
  177. case VT_INT:
  178. {
  179. sprintf(szValue,"%d",pPropVar->intVal);
  180. strcpy(szVal,szValue);
  181. }
  182. break;
  183. case VT_I4:
  184. {
  185. sprintf(szValue,"%d",pPropVar->lVal);
  186. strcpy(szVal,szValue);
  187. }
  188. break;
  189. case VT_I8:
  190. {
  191. sprintf(szValue,"%d",pPropVar->hVal);
  192. strcpy(szVal,szValue);
  193. }
  194. break;
  195. case VT_R4:
  196. {
  197. sprintf(szValue,"%2.5f",pPropVar->fltVal);
  198. strcpy(szVal,szValue);
  199. }
  200. break;
  201. case VT_R8:
  202. {
  203. sprintf(szValue,"%2.5f",pPropVar->dblVal);
  204. strcpy(szVal,szValue);
  205. }
  206. break;
  207. case VT_BSTR:
  208. {
  209. if (WideCharToMultiByte(CP_ACP, 0,pPropVar->bstrVal, -1,
  210. szValue, MAX_PATH,NULL,NULL) > 0) {
  211. strcpy(szVal,szValue);
  212. } else
  213. strcpy(szVal,"");
  214. }
  215. break;
  216. case VT_LPSTR:
  217. {
  218. strcpy(szVal,pPropVar->pszVal);
  219. }
  220. break;
  221. case VT_LPWSTR:
  222. {
  223. sprintf(szValue,"%ws",pPropVar->pwszVal);
  224. strcpy(szVal,szValue);
  225. }
  226. break;
  227. case VT_UINT:
  228. {
  229. sprintf(szValue,"%d",pPropVar->uintVal);
  230. strcpy(szVal,szValue);
  231. }
  232. break;
  233. case VT_CLSID:
  234. {
  235. UCHAR *pwszUUID = NULL;
  236. UuidToStringA(pPropVar->puuid,&pwszUUID);
  237. sprintf(szValue,"%s",pwszUUID);
  238. strcpy(szVal,szValue);
  239. RpcStringFree(&pwszUUID);
  240. }
  241. break;
  242. default:
  243. {
  244. sprintf(szValue,"%d",pPropVar->lVal);
  245. strcpy(szVal,szValue);
  246. }
  247. break;
  248. }
  249. }
  250. /**************************************************************************\
  251. * CWIAPropListCtrl::DisplayItemPropData()
  252. *
  253. * Displays formatted property data from the specified item
  254. *
  255. *
  256. * Arguments:
  257. *
  258. * pIWiaItem - Target item
  259. *
  260. * Return Value:
  261. *
  262. * none
  263. *
  264. * History:
  265. *
  266. * 2/14/1999 Original Version
  267. *
  268. \**************************************************************************/
  269. void CWIAPropListCtrl::DisplayItemPropData(IWiaItem *pIWiaItem,BOOL bAccessFlags)
  270. {
  271. HRESULT hResult = S_OK;
  272. IWiaPropertyStorage *pIWiaPropStg = NULL;
  273. BSTR bstrFullItemName = NULL;
  274. BOOL bSuccess = FALSE;
  275. int ItemNumber = 0;
  276. //
  277. // if the IWiaItem is NULL, Clean the display and exit
  278. //
  279. if (pIWiaItem == NULL) {
  280. DeleteAllItems();
  281. return;
  282. }
  283. //
  284. // Delete all Items (Possible others)
  285. //
  286. DeleteAllItems();
  287. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  288. if (hResult == S_OK) {
  289. //
  290. // Start Enumeration
  291. //
  292. IEnumSTATPROPSTG *pIPropEnum;
  293. hResult = pIWiaPropStg->Enum(&pIPropEnum);
  294. if (hResult == S_OK) {
  295. STATPROPSTG StatPropStg;
  296. do {
  297. hResult = pIPropEnum->Next(1,&StatPropStg,NULL);
  298. if (hResult == S_OK) {
  299. if (StatPropStg.lpwstrName != NULL) {
  300. //
  301. // read property value
  302. //
  303. PROPSPEC PropSpec;
  304. PROPVARIANT PropVar;
  305. PropSpec.ulKind = PRSPEC_PROPID;
  306. PropSpec.propid = StatPropStg.propid;
  307. hResult = pIWiaPropStg->ReadMultiple(1,&PropSpec,&PropVar);
  308. if (hResult == S_OK) {
  309. CHAR szPropName[MAX_PATH];
  310. CHAR szValue[MAX_PATH];
  311. CHAR szText[MAX_PATH];
  312. LV_ITEM lvitem;
  313. lvitem.mask = LVIF_TEXT | LVIF_PARAM;
  314. lvitem.iItem = ItemNumber;
  315. lvitem.iSubItem = 0;
  316. lvitem.pszText = szText;
  317. lvitem.iImage = NULL;
  318. lvitem.lParam = StatPropStg.propid;
  319. //
  320. // Write property name to list control
  321. //
  322. if (WideCharToMultiByte(CP_ACP, 0,StatPropStg.lpwstrName,-1,
  323. szPropName, MAX_PATH,NULL,NULL) > 0) {
  324. strcpy(szText,szPropName);
  325. InsertItem(&lvitem);
  326. //
  327. // move to next column for setting the value
  328. //
  329. lvitem.mask = LVIF_TEXT;
  330. lvitem.iSubItem = 1;
  331. } else
  332. strcpy(szPropName,"");
  333. //
  334. // Write propery value to list control
  335. //
  336. ConvertPropVarToString(&PropVar,szText);
  337. SetItem(&lvitem);
  338. ItemNumber++;
  339. //
  340. // Display output to the debugger
  341. //
  342. CString msg;
  343. msg.Format("Property: %s = %s",szPropName,szText);
  344. StressStatus(msg);
  345. if (bAccessFlags) {
  346. //
  347. // display access flags and var type
  348. //
  349. ULONG AccessFlags = 0;
  350. ULONG VarType = 0;
  351. PROPVARIANT AttrPropVar; // not used at this time
  352. hResult = pIWiaPropStg->GetPropertyAttributes(1, &PropSpec,&AccessFlags,&AttrPropVar);
  353. if (hResult != S_OK) {
  354. StressStatus("* pIWiaItem->GetPropertyAttributes() Failed",hResult);
  355. hResult = S_OK; // do this to continue property traversal
  356. } else {
  357. //
  358. // display access flags
  359. //
  360. lvitem.mask = LVIF_TEXT;
  361. lvitem.iSubItem = 3;
  362. if (ConvertAccessFlagsToString(lvitem.pszText,AccessFlags))
  363. SetItem(&lvitem);
  364. }
  365. }
  366. //
  367. // display var type
  368. //
  369. lvitem.mask = LVIF_TEXT;
  370. lvitem.iSubItem = 2;
  371. if (ConvertVarTypeToString(lvitem.pszText,PropVar.vt))
  372. SetItem(&lvitem);
  373. }
  374. } else {
  375. CString msg;
  376. msg.Format("* Property with NULL name, propid = %li\n",StatPropStg.propid);
  377. StressStatus(msg);
  378. }
  379. }
  380. //
  381. // clean up property name
  382. //
  383. CoTaskMemFree(StatPropStg.lpwstrName);
  384. } while (hResult == S_OK);
  385. }
  386. pIPropEnum->Release();
  387. pIWiaPropStg->Release();
  388. }
  389. //
  390. // auto resize columns to fit data
  391. //
  392. for (int Col = 0; Col <4;Col++)
  393. SetColumnWidth(Col, LVSCW_AUTOSIZE );
  394. }
  395. /**************************************************************************\
  396. * CWIAPropListCtrl::ConvertAccessFlagsToString()
  397. *
  398. * Converts the accessflag into a readable string for display only
  399. *
  400. *
  401. * Arguments:
  402. *
  403. * pszText - target string pointer for formatted string
  404. * AccessFlag - Flag to convert
  405. *
  406. * Return Value:
  407. *
  408. * none
  409. *
  410. * History:
  411. *
  412. * 2/14/1999 Original Version
  413. *
  414. \**************************************************************************/
  415. BOOL CWIAPropListCtrl::ConvertAccessFlagsToString(char* pszText,ULONG AccessFlags)
  416. {
  417. if (pszText == NULL)
  418. return FALSE;
  419. CString sFlag = "";
  420. if ((AccessFlags & WIA_PROP_READ) == WIA_PROP_READ)
  421. sFlag += "WIA_PROP_READ | ";
  422. if ((AccessFlags & WIA_PROP_WRITE) == WIA_PROP_WRITE)
  423. sFlag += "WIA_PROP_WRITE | ";
  424. if (sFlag == "WIA_PROP_READ | WIA_PROP_WRITE | ")
  425. sFlag = "WIA_PROP_RW | ";
  426. if ((AccessFlags & WIA_PROP_NONE) == WIA_PROP_NONE)
  427. sFlag += "WIA_PROP_NONE | ";
  428. if ((AccessFlags & WIA_PROP_RANGE) == WIA_PROP_RANGE)
  429. sFlag += "WIA_PROP_RANGE | ";
  430. if ((AccessFlags & WIA_PROP_LIST) == WIA_PROP_LIST)
  431. sFlag += "WIA_PROP_LIST | ";
  432. if ((AccessFlags & WIA_PROP_FLAG) == WIA_PROP_FLAG)
  433. sFlag += "WIA_PROP_FLAG | ";
  434. // check for unknown access flags
  435. if (sFlag.GetLength() == 0)
  436. sFlag.Format("WIA_PROP_UNKNOWN = %d ",AccessFlags);
  437. sFlag = sFlag.Left(sFlag.GetLength()-3);
  438. strcpy(pszText,sFlag.GetBuffer(256));
  439. return TRUE;
  440. }
  441. /**************************************************************************\
  442. * CWIAPropListCtrl::ConvertVarTypeToString()
  443. *
  444. * Converts Var Type to a readable string for display only
  445. *
  446. *
  447. * Arguments:
  448. *
  449. * pszText - Target string pointer for formatted string data
  450. * VarType - Var type to convert
  451. *
  452. * Return Value:
  453. *
  454. * none
  455. *
  456. * History:
  457. *
  458. * 2/14/1999 Original Version
  459. *
  460. \**************************************************************************/
  461. BOOL CWIAPropListCtrl::ConvertVarTypeToString(char* pszText,ULONG VarType)
  462. {
  463. if (pszText == NULL)
  464. return FALSE;
  465. switch (VarType) {
  466. case VT_EMPTY: // nothing
  467. strcpy(pszText,TEXT("VT_EMPTY"));
  468. break;
  469. case VT_NULL: // SQL style Null
  470. strcpy(pszText,TEXT("VT_NULL"));
  471. break;
  472. case VT_I2: // 2 byte signed int
  473. strcpy(pszText,TEXT("VT_I2"));
  474. break;
  475. case VT_I4: // 4 byte signed int
  476. strcpy(pszText,TEXT("VT_I4"));
  477. break;
  478. case VT_R4: // 4 byte real
  479. strcpy(pszText,TEXT("VT_R4"));
  480. break;
  481. case VT_R8: // 8 byte real
  482. strcpy(pszText,TEXT("VT_R8"));
  483. break;
  484. case VT_CY: // currency
  485. strcpy(pszText,TEXT("VT_CY"));
  486. break;
  487. case VT_DATE: // date
  488. strcpy(pszText,TEXT("VT_DATE"));
  489. break;
  490. case VT_BSTR: // OLE Automation string
  491. strcpy(pszText,TEXT("VT_BSTR"));
  492. break;
  493. case VT_DISPATCH: // IDispatch *
  494. strcpy(pszText,TEXT("VT_DISPATCH"));
  495. break;
  496. case VT_ERROR: // SCODE
  497. strcpy(pszText,TEXT("VT_ERROR"));
  498. break;
  499. case VT_BOOL: // True=-1, False=0
  500. strcpy(pszText,TEXT("VT_BOOL"));
  501. break;
  502. case VT_VARIANT: // VARIANT *
  503. strcpy(pszText,TEXT("VT_VARIANT"));
  504. break;
  505. case VT_UNKNOWN: // IUnknown *
  506. strcpy(pszText,TEXT("VT_UNKNOWN"));
  507. break;
  508. case VT_DECIMAL: // 16 byte fixed point
  509. strcpy(pszText,TEXT("VT_DECIMAL"));
  510. break;
  511. case VT_RECORD: // user defined type
  512. strcpy(pszText,TEXT("VT_RECORD"));
  513. break;
  514. case VT_I1: // signed char
  515. strcpy(pszText,TEXT("VT_I1"));
  516. break;
  517. case VT_UI1: // unsigned char
  518. strcpy(pszText,TEXT("VT_UI1"));
  519. break;
  520. case VT_UI2: // unsigned short
  521. strcpy(pszText,TEXT("VT_UI2"));
  522. break;
  523. case VT_UI4: // unsigned short
  524. strcpy(pszText,TEXT("VT_UI4"));
  525. break;
  526. case VT_I8: // signed 64-bit int
  527. strcpy(pszText,TEXT("VT_I8"));
  528. break;
  529. case VT_UI8: // unsigned 64-bit int
  530. strcpy(pszText,TEXT("VT_UI8"));
  531. break;
  532. case VT_INT: // signed machine int
  533. strcpy(pszText,TEXT("VT_INT"));
  534. break;
  535. case VT_UINT: // unsigned machine int
  536. strcpy(pszText,TEXT("VT_UINT"));
  537. break;
  538. case VT_VOID: // C style void
  539. strcpy(pszText,TEXT("VT_VOID"));
  540. break;
  541. case VT_HRESULT: // Standard return type
  542. strcpy(pszText,TEXT("VT_HRESULT"));
  543. break;
  544. case VT_PTR: // pointer type
  545. strcpy(pszText,TEXT("VT_PTR"));
  546. break;
  547. case VT_SAFEARRAY: // (use VT_ARRAY in VARIANT)
  548. strcpy(pszText,TEXT("VT_SAFEARRAY"));
  549. break;
  550. case VT_CARRAY: // C style array
  551. strcpy(pszText,TEXT("VT_CARRAY"));
  552. break;
  553. case VT_USERDEFINED: // user defined type
  554. strcpy(pszText,TEXT("VT_USERDEFINED"));
  555. break;
  556. case VT_LPSTR: // null terminated string
  557. strcpy(pszText,TEXT("VT_LPSTR"));
  558. break;
  559. case VT_LPWSTR: // wide null terminated string
  560. strcpy(pszText,TEXT("VT_LPWSTR"));
  561. break;
  562. case VT_FILETIME: // FILETIME
  563. strcpy(pszText,TEXT("VT_FILETIME"));
  564. break;
  565. case VT_BLOB: // Length prefixed bytes
  566. strcpy(pszText,TEXT("VT_BLOB"));
  567. break;
  568. case VT_STREAM: // Name of the stream follows
  569. strcpy(pszText,TEXT("VT_STREAM"));
  570. break;
  571. case VT_STORAGE: // Name of the storage follows
  572. strcpy(pszText,TEXT("VT_STORAGE"));
  573. break;
  574. case VT_STREAMED_OBJECT: // Stream contains an object
  575. strcpy(pszText,TEXT("VT_STREAMED_OBJECT"));
  576. break;
  577. case VT_STORED_OBJECT: // Storage contains an object
  578. strcpy(pszText,TEXT("VT_STORED_OBJECT"));
  579. break;
  580. case VT_VERSIONED_STREAM: // Stream with a GUID version
  581. strcpy(pszText,TEXT("VT_VERSIONED_STREAM"));
  582. break;
  583. case VT_BLOB_OBJECT: // Blob contains an object
  584. strcpy(pszText,TEXT("VT_BLOB_OBJECT"));
  585. break;
  586. case VT_CF: // Clipboard format
  587. strcpy(pszText,TEXT("VT_CF"));
  588. break;
  589. case VT_CLSID: // A Class ID
  590. strcpy(pszText,TEXT("VT_CLSID"));
  591. break;
  592. case VT_VECTOR: // simple counted array
  593. strcpy(pszText,TEXT("VT_VECTOR"));
  594. break;
  595. case VT_ARRAY: // SAFEARRAY*
  596. strcpy(pszText,TEXT("VT_ARRAY"));
  597. break;
  598. case VT_BYREF: // void* for local use
  599. strcpy(pszText,TEXT("VT_BYREF"));
  600. break;
  601. case VT_BSTR_BLOB: // Reserved for system use
  602. strcpy(pszText,TEXT("VT_BSTR_BLOB"));
  603. break;
  604. case VT_VECTOR|VT_I4:
  605. strcpy(pszText,TEXT("VT_VECTOR | VT_I4"));
  606. break;
  607. case VT_VECTOR | VT_UI1:
  608. strcpy(pszText,TEXT("VT_VECTOR | VT_UI1"));
  609. break;
  610. default: // unknown type detected!!
  611. strcpy(pszText,TEXT("VT_UNKNOWNTYPE"));
  612. break;
  613. }
  614. return TRUE;
  615. }
  616. /**************************************************************************\
  617. * CWIAPropListCtrl::Resize()
  618. *
  619. * Resizes the list control to specified changes in dx, and dy values
  620. *
  621. *
  622. * Arguments:
  623. *
  624. * dx - change in Width of parent frame
  625. * dy - change in Height of parent frame
  626. *
  627. * Return Value:
  628. *
  629. * none
  630. *
  631. * History:
  632. *
  633. * 2/14/1999 Original Version
  634. *
  635. \**************************************************************************/
  636. void CWIAPropListCtrl::Resize(int dx, int dy)
  637. {
  638. RECT ListBoxRect;
  639. GetWindowRect(&ListBoxRect);
  640. CWnd* pFrm = GetParent();
  641. if (pFrm != NULL)
  642. pFrm->ScreenToClient(&ListBoxRect);
  643. ListBoxRect.right += dx;
  644. ListBoxRect.bottom += dy;
  645. MoveWindow(&ListBoxRect);
  646. }
  647. /////////////////////////////////////////////////////////////////////////////
  648. // CWIATreeCtrl
  649. /**************************************************************************\
  650. * CWIATreeCtrl::CWIATreeCtrl()
  651. *
  652. * Constructor for CWIATreeCtrl class
  653. *
  654. *
  655. * Arguments:
  656. *
  657. * none
  658. *
  659. * Return Value:
  660. *
  661. * none
  662. *
  663. * History:
  664. *
  665. * 2/14/1999 Original Version
  666. *
  667. \**************************************************************************/
  668. CWIATreeCtrl::CWIATreeCtrl()
  669. {
  670. }
  671. /**************************************************************************\
  672. * CWIATreeCtrl::~CWIATreeCtrl()
  673. *
  674. * Destructor for the CWIATreeCtrl class
  675. *
  676. *
  677. * Arguments:
  678. *
  679. * none
  680. *
  681. * Return Value:
  682. *
  683. * none
  684. *
  685. * History:
  686. *
  687. * 2/14/1999 Original Version
  688. *
  689. \**************************************************************************/
  690. CWIATreeCtrl::~CWIATreeCtrl()
  691. {
  692. }
  693. BEGIN_MESSAGE_MAP(CWIATreeCtrl, CTreeCtrl)
  694. //{{AFX_MSG_MAP(CWIATreeCtrl)
  695. // NOTE - the ClassWizard will add and remove mapping macros here.
  696. //}}AFX_MSG_MAP
  697. END_MESSAGE_MAP()
  698. /////////////////////////////////////////////////////////////////////////////
  699. // CWIATreeCtrl message handlers
  700. void CWIATreeCtrl::InitHeaders()
  701. {
  702. // initialize the tree control
  703. //m_ItemTree.SetImageList(((CWIATestApp*)pApp)->GetApplicationImageList(),TVSIL_NORMAL);
  704. }
  705. /**************************************************************************\
  706. * CWIATreeCtrl::BuildItemTree()
  707. *
  708. * Constructs a Tree display of the Active Tree list which contains, Item pointers
  709. *
  710. *
  711. * Arguments:
  712. *
  713. * pActiveTreeList - list of IWiaItem* pointers
  714. *
  715. * Return Value:
  716. *
  717. * none
  718. *
  719. * History:
  720. *
  721. * 2/14/1999 Original Version
  722. *
  723. \**************************************************************************/
  724. BOOL CWIATreeCtrl::BuildItemTree(CPtrList *pActiveTreeList)
  725. {
  726. DeleteAllItems();
  727. //
  728. // Start at head of the ActiveTree list
  729. //
  730. m_CurrentPosition = pActiveTreeList->GetHeadPosition();
  731. Construct(pActiveTreeList, TVI_ROOT,0);
  732. //
  733. // select the Root item
  734. //
  735. SelectItem(GetRootItem());
  736. return TRUE;
  737. }
  738. /**************************************************************************\
  739. * CWIATreeCtrl::Construct()
  740. *
  741. * Build the actual tree in display form
  742. *
  743. *
  744. * Arguments:
  745. *
  746. * pActiveTreeList - list of IWiaItem* pointers
  747. * hParent - handle of Parent tree item
  748. * ParentID - Parent's ID...which level does the item belong to???
  749. *
  750. * Return Value:
  751. *
  752. * none
  753. *
  754. * History:
  755. *
  756. * 2/14/1999 Original Version
  757. *
  758. \**************************************************************************/
  759. BOOL CWIATreeCtrl::Construct(CPtrList *pActiveTreeList, HTREEITEM hParent, int ParentID)
  760. {
  761. IWiaItem* pIWiaItem = NULL;
  762. WIAITEMTREENODE* pWiaItemTreeNode = NULL;
  763. IWiaPropertyStorage *pIWiaPropStg;
  764. HRESULT hResult = S_OK;
  765. HTREEITEM hTree = NULL;
  766. IEnumWiaItem* pEnumItem = NULL;
  767. TV_INSERTSTRUCT tv;
  768. tv.hParent = hParent;
  769. tv.hInsertAfter = TVI_LAST;
  770. tv.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_PARAM;
  771. tv.item.hItem = NULL;
  772. tv.item.state = TVIS_EXPANDED;
  773. tv.item.stateMask = TVIS_STATEIMAGEMASK;
  774. tv.item.cchTextMax = 6;
  775. tv.item.cChildren = 0;
  776. tv.item.lParam = 0;
  777. //
  778. // save current position in list
  779. //
  780. tv.item.lParam = (LPARAM)m_CurrentPosition;
  781. pWiaItemTreeNode = (WIAITEMTREENODE*)pActiveTreeList->GetNext(m_CurrentPosition);
  782. pIWiaItem = pWiaItemTreeNode->pIWiaItem;
  783. ParentID = pWiaItemTreeNode->ParentID;
  784. if (pIWiaItem == NULL)
  785. return FALSE;
  786. CHAR szTemp[ MAX_PATH ];
  787. BSTR bstrFullItemName = NULL;
  788. //
  789. // get item's name and add it to the tree
  790. //
  791. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  792. if (hResult == S_OK) {
  793. hResult = ReadPropStr(WIA_IPA_FULL_ITEM_NAME, pIWiaPropStg, &bstrFullItemName);
  794. if (hResult != S_OK) {
  795. StressStatus("* ReadPropStr(WIA_IPA_FULL_ITEM_NAME) Failed",hResult);
  796. bstrFullItemName = ::SysAllocString(L"Uninitialized");
  797. }
  798. pIWiaPropStg->Release();
  799. } else {
  800. StressStatus("* QueryInterface(IDD_IWiaPropertyStorage) Failed",hResult);
  801. return FALSE;
  802. }
  803. WideCharToMultiByte(CP_ACP,0,bstrFullItemName,-1,szTemp,MAX_PATH,NULL,NULL);
  804. tv.item.pszText = szTemp;
  805. hTree = InsertItem(&tv);
  806. HTREEITEM ParentLevel[50];
  807. ParentLevel[ParentID] = hTree;
  808. while (m_CurrentPosition) {
  809. //
  810. // save current position in list
  811. //
  812. tv.item.lParam = (LPARAM)m_CurrentPosition;
  813. pWiaItemTreeNode = (WIAITEMTREENODE*)pActiveTreeList->GetNext(m_CurrentPosition);
  814. pIWiaItem = pWiaItemTreeNode->pIWiaItem;
  815. ParentID = pWiaItemTreeNode->ParentID;
  816. if (pIWiaItem == NULL)
  817. return FALSE;
  818. CHAR szTemp[ MAX_PATH ];
  819. BSTR bstrFullItemName = NULL;
  820. //
  821. // get item's name and add it to the tree
  822. //
  823. hResult = pIWiaItem->QueryInterface(IID_IWiaPropertyStorage,(void **)&pIWiaPropStg);
  824. if (hResult == S_OK) {
  825. hResult = ReadPropStr(WIA_IPA_FULL_ITEM_NAME, pIWiaPropStg, &bstrFullItemName);
  826. if (hResult != S_OK) {
  827. StressStatus("* ReadPropStr(WIA_IPA_FULL_ITEM_NAME) Failed",hResult);
  828. bstrFullItemName = ::SysAllocString(L"Uninitialized");
  829. }
  830. pIWiaPropStg->Release();
  831. } else {
  832. StressStatus("* QueryInterface(IDD_IWiaPropertyStorage) Failed",hResult);
  833. return FALSE;
  834. }
  835. WideCharToMultiByte(CP_ACP,0,bstrFullItemName,-1,szTemp,MAX_PATH,NULL,NULL);
  836. tv.item.pszText = szTemp;
  837. tv.hParent = ParentLevel[ParentID];
  838. hTree = InsertItem(&tv);
  839. // find out if the item is a folder, if it is,
  840. // ask for child items...
  841. long lType = 0;
  842. pIWiaItem->GetItemType(&lType);
  843. if (lType & WiaItemTypeFolder) {
  844. if (pIWiaItem->EnumChildItems(&pEnumItem) == S_OK) {
  845. ParentLevel[ParentID+1] = hTree;
  846. }
  847. }
  848. }
  849. return FALSE;
  850. }
  851. /**************************************************************************\
  852. * CWIATreeCtrl::DestroyItemTree()
  853. *
  854. * Destroys the display, and Active Tree list
  855. *
  856. *
  857. * Arguments:
  858. *
  859. * pActiveTreeList - list of IWiaItem* pointers
  860. *
  861. * Return Value:
  862. *
  863. * none
  864. *
  865. * History:
  866. *
  867. * 2/14/1999 Original Version
  868. *
  869. \**************************************************************************/
  870. void CWIATreeCtrl::DestroyItemTree(CPtrList* pActiveTreeList)
  871. {
  872. if (pActiveTreeList->GetCount() == 0)
  873. return;
  874. SelectItem(GetRootItem());
  875. POSITION Position = pActiveTreeList->GetHeadPosition();
  876. IWiaItem* pIWiaItem = NULL;
  877. while (Position) {
  878. WIAITEMTREENODE* pWiaItemTreeNode = (WIAITEMTREENODE*)pActiveTreeList->GetNext(Position);
  879. pIWiaItem = pWiaItemTreeNode->pIWiaItem;
  880. pIWiaItem->Release();
  881. }
  882. pActiveTreeList->RemoveAll();
  883. DeleteAllItems( );
  884. }
  885. /**************************************************************************\
  886. * CWIATreeCtrl::GetSelectedIWiaItem()
  887. *
  888. * returns the selected IWiaItem* pointer in the tree
  889. *
  890. *
  891. * Arguments:
  892. *
  893. * pActiveTreeList - list of IWiaItem* pointers
  894. *
  895. * Return Value:
  896. *
  897. * none
  898. *
  899. * History:
  900. *
  901. * 2/14/1999 Original Version
  902. *
  903. \**************************************************************************/
  904. IWiaItem* CWIATreeCtrl::GetSelectedIWiaItem(CPtrList* pActiveTreeList)
  905. {
  906. HTREEITEM hTreeItem = GetSelectedItem();
  907. if (hTreeItem != NULL) {
  908. //
  909. // we have a valid hTreeItem
  910. //
  911. POSITION Position = (POSITION)GetItemData(hTreeItem);
  912. if (Position) {
  913. //
  914. // we have a POSITION
  915. //
  916. IWiaItem* pIWiaItem = NULL;
  917. if (Position) {
  918. WIAITEMTREENODE* pWiaItemTreeNode = (WIAITEMTREENODE*)pActiveTreeList->GetAt(Position);
  919. if (pWiaItemTreeNode != NULL) {
  920. pIWiaItem = pWiaItemTreeNode->pIWiaItem;
  921. if (pIWiaItem != NULL) {
  922. //
  923. // a valid item is found
  924. //
  925. return pIWiaItem;
  926. }
  927. } else
  928. return NULL;
  929. } else
  930. return NULL;
  931. }
  932. } else
  933. MessageBox("Please select an Item","WIATest Status",MB_OK);
  934. return NULL;
  935. }
  936. /**************************************************************************\
  937. * CWIATreeCtrl::GetRootIWiaItem()
  938. *
  939. * Returns the ROOT item from the pActiveTreeList
  940. *
  941. *
  942. * Arguments:
  943. *
  944. * pActiveTreeList - list of IWiaItem* pointers
  945. *
  946. * Return Value:
  947. *
  948. * none
  949. *
  950. * History:
  951. *
  952. * 2/14/1999 Original Version
  953. *
  954. \**************************************************************************/
  955. IWiaItem* CWIATreeCtrl::GetRootIWiaItem(CPtrList* pActiveTreeList)
  956. {
  957. HTREEITEM hTreeItem = GetRootItem();
  958. if (hTreeItem != NULL) {
  959. //
  960. // we have a valid hTreeItem
  961. //
  962. POSITION Position = (POSITION)GetItemData(hTreeItem);
  963. if (Position) {
  964. //
  965. // we have a POSITION
  966. //
  967. IWiaItem* pIWiaItem = NULL;
  968. if (Position) {
  969. WIAITEMTREENODE* pWiaItemTreeNode = (WIAITEMTREENODE*)pActiveTreeList->GetAt(Position);
  970. if (pWiaItemTreeNode != NULL) {
  971. pIWiaItem = pWiaItemTreeNode->pIWiaItem;
  972. if (pIWiaItem != NULL) {
  973. //
  974. // a valid item is found
  975. //
  976. return pIWiaItem;
  977. }
  978. } else
  979. return NULL;
  980. } else
  981. return NULL;
  982. }
  983. }
  984. return NULL;
  985. }
  986. /////////////////////////////////////////////////////////////////////////////
  987. // CWIADeviceComboBox
  988. /**************************************************************************\
  989. * CWIADeviceComboBox::CWIADeviceComboBox
  990. *
  991. * Constructor for the CWIADeviceComboBox class
  992. *
  993. *
  994. * Arguments:
  995. *
  996. * none
  997. *
  998. * Return Value:
  999. *
  1000. * none
  1001. *
  1002. * History:
  1003. *
  1004. * 2/14/1999 Original Version
  1005. *
  1006. \**************************************************************************/
  1007. CWIADeviceComboBox::CWIADeviceComboBox()
  1008. {
  1009. }
  1010. /**************************************************************************\
  1011. * CWIADeviceComboBox::~CWIADeviceComboBox()
  1012. *
  1013. * Destructor for the CWIAPropListCtrl class
  1014. *
  1015. *
  1016. * Arguments:
  1017. *
  1018. * none
  1019. *
  1020. * Return Value:
  1021. *
  1022. * none
  1023. *
  1024. * History:
  1025. *
  1026. * 2/14/1999 Original Version
  1027. *
  1028. \**************************************************************************/
  1029. CWIADeviceComboBox::~CWIADeviceComboBox()
  1030. {
  1031. }
  1032. /**************************************************************************\
  1033. * CWIADeviceComboBox::AddDevice()
  1034. *
  1035. * Add a Device ID to the Device ComboBox
  1036. *
  1037. *
  1038. * Arguments:
  1039. *
  1040. * DeviceIndex - position to place the Device ID in the combo box
  1041. * DeviceName - Name of the Device
  1042. * ServerName - Name of the server, (local or other) of the device
  1043. * bstrDeviceID - Device ID
  1044. *
  1045. * Return Value:
  1046. *
  1047. * none
  1048. *
  1049. * History:
  1050. *
  1051. * 2/14/1999 Original Version
  1052. *
  1053. \**************************************************************************/
  1054. void CWIADeviceComboBox::AddDeviceID(int DeviceIndex, BSTR DeviceName, BSTR ServerName,BSTR bstrDeviceID)
  1055. {
  1056. //
  1057. // report no WIA devices found if -1 is passed as the DeviceIndex param
  1058. //
  1059. if (DeviceIndex == -1)
  1060. InsertString(0,"< No WIA Devices Found >");
  1061. else {
  1062. //
  1063. // add WIA device name, and ID to combobox
  1064. //
  1065. InsertString(DeviceIndex,(CString)DeviceName + " ( " + (CString)ServerName + " )");
  1066. SetItemDataPtr(DeviceIndex,(LPVOID)bstrDeviceID);
  1067. }
  1068. }
  1069. BEGIN_MESSAGE_MAP(CWIADeviceComboBox, CComboBox)
  1070. //{{AFX_MSG_MAP(CWIADeviceComboBox)
  1071. // NOTE - the ClassWizard will add and remove mapping macros here.
  1072. //}}AFX_MSG_MAP
  1073. END_MESSAGE_MAP()
  1074. /////////////////////////////////////////////////////////////////////////////
  1075. // CWIADeviceComboBox message handlers
  1076. /**************************************************************************\
  1077. * CWIADeviceComboBox::GetCurrentDeviceID()
  1078. *
  1079. * Returns the currently selected device ID from the combo box
  1080. *
  1081. *
  1082. * Arguments:
  1083. *
  1084. * none
  1085. *
  1086. * Return Value:
  1087. *
  1088. * BSTR - DeviceID
  1089. *
  1090. * History:
  1091. *
  1092. * 2/14/1999 Original Version
  1093. *
  1094. \**************************************************************************/
  1095. BSTR CWIADeviceComboBox::GetCurrentDeviceID()
  1096. {
  1097. int ComboIndex = GetCurSel();
  1098. return(BSTR)GetItemDataPtr(ComboIndex);
  1099. }
  1100. /**************************************************************************\
  1101. * CWIADeviceComboBox::GetCurrentDeviceName()
  1102. *
  1103. * Returns the currently selected device's Name
  1104. *
  1105. *
  1106. * Arguments:
  1107. *
  1108. * none
  1109. *
  1110. * Return Value:
  1111. *
  1112. * CString - device name in CString format
  1113. *
  1114. * History:
  1115. *
  1116. * 2/14/1999 Original Version
  1117. *
  1118. \**************************************************************************/
  1119. CString CWIADeviceComboBox::GetCurrentDeviceName()
  1120. {
  1121. int ComboIndex = GetCurSel();
  1122. return GetDeviceName(ComboIndex);
  1123. }
  1124. /**************************************************************************\
  1125. * CWIADeviceComboBox::GetDeviceName()
  1126. *
  1127. * Returns the target device's Name
  1128. *
  1129. *
  1130. * Arguments:
  1131. *
  1132. * Comboindex - Position in the combo box of the target device
  1133. *
  1134. * Return Value:
  1135. *
  1136. * CString - device name in CString format
  1137. *
  1138. * History:
  1139. *
  1140. * 2/14/1999 Original Version
  1141. *
  1142. \**************************************************************************/
  1143. CString CWIADeviceComboBox::GetDeviceName(int ComboIndex)
  1144. {
  1145. CString DeviceName;
  1146. GetLBText(ComboIndex,DeviceName);
  1147. return DeviceName;
  1148. }
  1149. /**************************************************************************\
  1150. * CWIADeviceComboBox::SetCurrentSelFromID()
  1151. *
  1152. * Sets the combo selection based on the target ID
  1153. * note: this is used for command line only
  1154. *
  1155. *
  1156. * Arguments:
  1157. *
  1158. * CmdLine - Command Line containing Device ID
  1159. *
  1160. * Return Value:
  1161. *
  1162. * none
  1163. *
  1164. * History:
  1165. *
  1166. * 2/14/1999 Original Version
  1167. *
  1168. \**************************************************************************/
  1169. void CWIADeviceComboBox::SetCurrentSelFromID(CString CmdLine)
  1170. {
  1171. //
  1172. // find the specified Device ID
  1173. //
  1174. int DeviceCount = GetCount();
  1175. int ComboIndex = 0;
  1176. BSTR bstrDeviceID;
  1177. CString DeviceID;
  1178. if (DeviceCount > 0) {
  1179. for (int i = 0;i<DeviceCount;i++) {
  1180. bstrDeviceID = (BSTR)GetItemDataPtr(i);
  1181. DeviceID = bstrDeviceID;
  1182. if (DeviceID == CmdLine)
  1183. ComboIndex = i;
  1184. }
  1185. //
  1186. // ComboIndex will be zero if none of
  1187. // the DeviceIDs match
  1188. // Zero is the first Device in the combo box
  1189. //
  1190. SetCurSel(ComboIndex);
  1191. }
  1192. }
  1193. /////////////////////////////////////////////////////////////////////////////
  1194. // CWIAClipboardFormatComboBox
  1195. /**************************************************************************\
  1196. * CWIAClipboardFormatComboBox::CWIAClipboardFormatComboBox()
  1197. *
  1198. * Constructor for the CWIAClipboardFormatComboBox class
  1199. *
  1200. * Arguments:
  1201. *
  1202. * none
  1203. *
  1204. * Return Value:
  1205. *
  1206. * none
  1207. *
  1208. * History:
  1209. *
  1210. * 2/14/1999 Original Version
  1211. *
  1212. \**************************************************************************/
  1213. CWIAClipboardFormatComboBox::CWIAClipboardFormatComboBox()
  1214. {
  1215. }
  1216. /**************************************************************************\
  1217. * CWIAClipboardFormatComboBox::~CWIAClipboardFormatComboBox()
  1218. *
  1219. * Destructor for the CWIAClipboardFormatComboBox class
  1220. *
  1221. * Arguments:
  1222. *
  1223. * none
  1224. *
  1225. * Return Value:
  1226. *
  1227. * none
  1228. *
  1229. * History:
  1230. *
  1231. * 2/14/1999 Original Version
  1232. *
  1233. \**************************************************************************/
  1234. CWIAClipboardFormatComboBox::~CWIAClipboardFormatComboBox()
  1235. {
  1236. }
  1237. BEGIN_MESSAGE_MAP(CWIAClipboardFormatComboBox, CComboBox)
  1238. //{{AFX_MSG_MAP(CWIAClipboardFormatComboBox)
  1239. // NOTE - the ClassWizard will add and remove mapping macros here.
  1240. //}}AFX_MSG_MAP
  1241. END_MESSAGE_MAP()
  1242. /////////////////////////////////////////////////////////////////////////////
  1243. // CWIAClipboardFormatComboBox message handlers
  1244. /**************************************************************************\
  1245. * CWIAClipboardFormatComboBox::InitClipboardFormats()
  1246. *
  1247. * Enumerates the supported clipboard formats, and populates the combo
  1248. * box with these values. (filtering is based on the Tymed param)
  1249. *
  1250. * Arguments:
  1251. *
  1252. * pWIAFormatInfo -
  1253. * Tymed - Filter TYMED_ value
  1254. *
  1255. * Return Value:
  1256. *
  1257. * none
  1258. *
  1259. * History:
  1260. *
  1261. * 2/14/1999 Original Version
  1262. *
  1263. \**************************************************************************/
  1264. void CWIAClipboardFormatComboBox::InitClipboardFormats(CPtrList* pSupportedFormatList,LONG Tymed)
  1265. {
  1266. //
  1267. // save current format
  1268. //
  1269. GUID CurrentClipboardFormat;
  1270. if (pSupportedFormatList != NULL)
  1271. CurrentClipboardFormat = GetCurrentClipboardFormat();
  1272. int i = 0;
  1273. //
  1274. // nuke all entries
  1275. //
  1276. ResetContent( );
  1277. if (pSupportedFormatList == NULL) {
  1278. //
  1279. // Add WiaImgFmt_BMP some default value
  1280. //
  1281. InsertString(0,TEXT("WiaImgFmt_BMP(default)"));
  1282. SetItemDataPtr(0,(void*)&WiaImgFmt_BMP);
  1283. } else {
  1284. POSITION Position = pSupportedFormatList->GetHeadPosition();
  1285. while (Position) {
  1286. WIA_FORMAT_INFO* pfe = (WIA_FORMAT_INFO*)pSupportedFormatList->GetNext(Position);
  1287. if (Tymed == pfe->lTymed) {
  1288. InsertString(i,ConvertClipboardFormatToCString(pfe->guidFormatID));
  1289. SetItemDataPtr(i,(void*)GetGUIDPtr(pfe->guidFormatID));
  1290. i++;
  1291. }
  1292. }
  1293. }
  1294. SetClipboardFormat(CurrentClipboardFormat);
  1295. }
  1296. /**************************************************************************\
  1297. * CWIAClipboardFormatComboBox::GetCurrentClipboardFormat()
  1298. *
  1299. * Returns the currently selected clipboard format from the combo box
  1300. *
  1301. * Arguments:
  1302. *
  1303. * none
  1304. *
  1305. * Return Value:
  1306. *
  1307. * USHORT - Currently selected clipboard format
  1308. *
  1309. * History:
  1310. *
  1311. * 2/14/1999 Original Version
  1312. *
  1313. \**************************************************************************/
  1314. GUID CWIAClipboardFormatComboBox::GetCurrentClipboardFormat()
  1315. {
  1316. int ComboIndex = GetCurSel();
  1317. return *((GUID*)GetItemDataPtr(ComboIndex));
  1318. }
  1319. /**************************************************************************\
  1320. * CWIAClipboardFormatComboBox::ConvertClipboardFormatToCString()
  1321. *
  1322. * Converts a Clipboard format to a CString value for display only
  1323. *
  1324. * Arguments:
  1325. *
  1326. * ClipboardFormat - Clipboardformat to convert
  1327. *
  1328. * Return Value:
  1329. *
  1330. * CString - converted Clipboardformat in CString format
  1331. *
  1332. * History:
  1333. *
  1334. * 2/14/1999 Original Version
  1335. *
  1336. \**************************************************************************/
  1337. CString CWIAClipboardFormatComboBox::ConvertClipboardFormatToCString(GUID ClipboardFormat)
  1338. {
  1339. if(ClipboardFormat == WiaImgFmt_UNDEFINED)
  1340. return "WiaImgFmt_UNDEFINED";
  1341. else if(ClipboardFormat == WiaImgFmt_MEMORYBMP)
  1342. return "WiaImgFmt_MEMORYBMP";
  1343. else if(ClipboardFormat == WiaImgFmt_BMP)
  1344. return "WiaImgFmt_BMP";
  1345. else if(ClipboardFormat == WiaImgFmt_EMF)
  1346. return "WiaImgFmt_EMF";
  1347. else if(ClipboardFormat == WiaImgFmt_WMF)
  1348. return "WiaImgFmt_WMF";
  1349. else if(ClipboardFormat == WiaImgFmt_JPEG)
  1350. return "WiaImgFmt_JPEG";
  1351. else if(ClipboardFormat == WiaImgFmt_PNG)
  1352. return "WiaImgFmt_PNG";
  1353. else if(ClipboardFormat == WiaImgFmt_GIF)
  1354. return "WiaImgFmt_GIF";
  1355. else if(ClipboardFormat == WiaImgFmt_TIFF)
  1356. return "WiaImgFmt_TIFF";
  1357. else if(ClipboardFormat == WiaImgFmt_EXIF)
  1358. return "WiaImgFmt_EXIF";
  1359. else if(ClipboardFormat == WiaImgFmt_PHOTOCD)
  1360. return "WiaImgFmt_PHOTOCD";
  1361. else if(ClipboardFormat == WiaImgFmt_FLASHPIX)
  1362. return "WiaImgFmt_FLASHPIX";
  1363. else
  1364. return "** UNKNOWN **";
  1365. }
  1366. /**************************************************************************\
  1367. * CWIAClipboardFormatComboBox::GetGUIDPtr()
  1368. *
  1369. * Converts a GUID format to a pointer to the constant
  1370. *
  1371. * Arguments:
  1372. *
  1373. * guidIn - GUID to convert
  1374. *
  1375. * Return Value:
  1376. *
  1377. * GUID* - pointer to a GUID constant
  1378. *
  1379. * History:
  1380. *
  1381. * 2/14/1999 Original Version
  1382. *
  1383. \**************************************************************************/
  1384. const GUID* CWIAClipboardFormatComboBox::GetGUIDPtr(GUID guidIn)
  1385. {
  1386. if(guidIn == WiaImgFmt_UNDEFINED)
  1387. return &WiaImgFmt_UNDEFINED;
  1388. else if(guidIn == WiaImgFmt_MEMORYBMP)
  1389. return &WiaImgFmt_MEMORYBMP;
  1390. else if(guidIn == WiaImgFmt_BMP)
  1391. return &WiaImgFmt_BMP;
  1392. else if(guidIn == WiaImgFmt_EMF)
  1393. return &WiaImgFmt_EMF;
  1394. else if(guidIn == WiaImgFmt_WMF)
  1395. return &WiaImgFmt_WMF;
  1396. else if(guidIn == WiaImgFmt_JPEG)
  1397. return &WiaImgFmt_JPEG;
  1398. else if(guidIn == WiaImgFmt_PNG)
  1399. return &WiaImgFmt_PNG;
  1400. else if(guidIn == WiaImgFmt_GIF)
  1401. return &WiaImgFmt_GIF;
  1402. else if(guidIn == WiaImgFmt_TIFF)
  1403. return &WiaImgFmt_TIFF;
  1404. else if(guidIn == WiaImgFmt_EXIF)
  1405. return &WiaImgFmt_EXIF;
  1406. else if(guidIn == WiaImgFmt_PHOTOCD)
  1407. return &WiaImgFmt_PHOTOCD;
  1408. else if(guidIn == WiaImgFmt_FLASHPIX)
  1409. return &WiaImgFmt_FLASHPIX;
  1410. return (GUID*)&GUID_NULL;
  1411. }
  1412. /**************************************************************************\
  1413. * CWIAClipboardFormatComboBox::SetClipboardFormat()
  1414. *
  1415. * Attempts to set the current clipboard format value in the combo box,
  1416. * if it can't be found the first item is set to default (index 0)
  1417. *
  1418. * Arguments:
  1419. *
  1420. * CF_VALUE - Clipboard format to set
  1421. *
  1422. * Return Value:
  1423. *
  1424. * none
  1425. *
  1426. * History:
  1427. *
  1428. * 2/14/1999 Original Version
  1429. *
  1430. \**************************************************************************/
  1431. void CWIAClipboardFormatComboBox::SetClipboardFormat(GUID CF_VALUE)
  1432. {
  1433. int NumItems = GetCount();
  1434. int Index = 0;
  1435. BOOL bFound = FALSE;
  1436. if (NumItems >0) {
  1437. while (Index < NumItems) {
  1438. if (CF_VALUE == *(GUID*)GetItemDataPtr(Index)) {
  1439. SetCurSel(Index);
  1440. bFound = TRUE;
  1441. }
  1442. Index++;
  1443. }
  1444. if (!bFound)
  1445. SetCurSel(0);
  1446. } else
  1447. StressStatus("* No WIA Supported Formats in format listbox");
  1448. }
  1449. /////////////////////////////////////////////////////////////////////////////
  1450. // CWIATymedComboBox
  1451. /**************************************************************************\
  1452. * CWIATymedComboBox::CWIATymedComboBox()
  1453. *
  1454. * Constructor for the CWIATymedComboBox class
  1455. *
  1456. * Arguments:
  1457. *
  1458. * none
  1459. *
  1460. * Return Value:
  1461. *
  1462. * none
  1463. *
  1464. * History:
  1465. *
  1466. * 2/14/1999 Original Version
  1467. *
  1468. \**************************************************************************/
  1469. CWIATymedComboBox::CWIATymedComboBox()
  1470. {
  1471. }
  1472. /**************************************************************************\
  1473. * CWIATymedComboBox::~CWIATymedComboBox()
  1474. *
  1475. * Destructor for the CWIATymedComboBox class
  1476. *
  1477. * Arguments:
  1478. *
  1479. * none
  1480. *
  1481. * Return Value:
  1482. *
  1483. * none
  1484. *
  1485. * History:
  1486. *
  1487. * 2/14/1999 Original Version
  1488. *
  1489. \**************************************************************************/
  1490. CWIATymedComboBox::~CWIATymedComboBox()
  1491. {
  1492. }
  1493. BEGIN_MESSAGE_MAP(CWIATymedComboBox, CComboBox)
  1494. //{{AFX_MSG_MAP(CWIATymedComboBox)
  1495. // NOTE - the ClassWizard will add and remove mapping macros here.
  1496. //}}AFX_MSG_MAP
  1497. END_MESSAGE_MAP()
  1498. /////////////////////////////////////////////////////////////////////////////
  1499. // CWIATymedComboBox message handlers
  1500. /**************************************************************************\
  1501. * CWIATymedComboBox::GetCurrentTymed()
  1502. *
  1503. * Returns the currently selected TYMED value in the combo box
  1504. *
  1505. * Arguments:
  1506. *
  1507. * none
  1508. *
  1509. * Return Value:
  1510. *
  1511. * DWORD - selected TYMED value
  1512. *
  1513. * History:
  1514. *
  1515. * 2/14/1999 Original Version
  1516. *
  1517. \**************************************************************************/
  1518. DWORD CWIATymedComboBox::GetCurrentTymed()
  1519. {
  1520. int ComboIndex = GetCurSel();
  1521. return(DWORD)GetItemData(ComboIndex);
  1522. }
  1523. /**************************************************************************\
  1524. * CWIATymedComboBox::InitTymedComboBox()
  1525. *
  1526. * Initialize the TymedComboBox with supported values
  1527. *
  1528. * Arguments:
  1529. *
  1530. * none
  1531. *
  1532. * Return Value:
  1533. *
  1534. * none
  1535. *
  1536. * History:
  1537. *
  1538. * 2/14/1999 Original Version
  1539. *
  1540. \**************************************************************************/
  1541. void CWIATymedComboBox::InitTymedComboBox()
  1542. {
  1543. //
  1544. // initialize the combo box with possible
  1545. // tymed combinations
  1546. //
  1547. InsertString(0,"TYMED_FILE");
  1548. SetItemData(0,TYMED_FILE);
  1549. InsertString(1,"TYMED_CALLBACK");
  1550. SetItemData(1,TYMED_CALLBACK);
  1551. //
  1552. // Set Default selection to first entry
  1553. //
  1554. SetCurSel(0);
  1555. }