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.

1390 lines
33 KiB

  1. // PropEdit.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "WIATest.h"
  5. #include "PropEdit.h"
  6. #include "wtdb.h" // WIATEST Database of flags and constants
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CPropEdit dialog
  14. /**************************************************************************\
  15. * CPropEdit::CPropEdit()
  16. *
  17. * Constructor for Property Edit dialog - Default type
  18. *
  19. *
  20. * Arguments:
  21. *
  22. * pParent - Parent Window
  23. *
  24. * Return Value:
  25. *
  26. * none
  27. *
  28. * History:
  29. *
  30. * 2/14/1999 Original Version
  31. *
  32. \**************************************************************************/
  33. CPropEdit::CPropEdit(CWnd* pParent /*=NULL*/)
  34. : CDialog(CPropEdit::IDD, pParent)
  35. {
  36. //{{AFX_DATA_INIT(CPropEdit)
  37. m_EditString = _T("");
  38. m_strPropName = _T("");
  39. //}}AFX_DATA_INIT
  40. }
  41. /**************************************************************************\
  42. * CPropEdit::DoDataExchange()
  43. *
  44. * Handles control message maps to the correct member variables
  45. *
  46. *
  47. * Arguments:
  48. *
  49. * pDX - DataExchange object
  50. *
  51. * Return Value:
  52. *
  53. * none
  54. *
  55. * History:
  56. *
  57. * 2/14/1999 Original Version
  58. *
  59. \**************************************************************************/
  60. void CPropEdit::DoDataExchange(CDataExchange* pDX)
  61. {
  62. CDialog::DoDataExchange(pDX);
  63. //{{AFX_DATA_MAP(CPropEdit)
  64. DDX_Control(pDX, IDOK, m_ButtonOk);
  65. DDX_Control(pDX, IDCANCEL, m_ButtonCancel);
  66. DDX_Text(pDX, IDC_EDITPROP, m_EditString);
  67. DDX_Text(pDX, IDC_PROP_NAME, m_strPropName);
  68. //}}AFX_DATA_MAP
  69. }
  70. BEGIN_MESSAGE_MAP(CPropEdit, CDialog)
  71. //{{AFX_MSG_MAP(CPropEdit)
  72. //}}AFX_MSG_MAP
  73. END_MESSAGE_MAP()
  74. /////////////////////////////////////////////////////////////////////////////
  75. // CPropEdit message handlers
  76. /**************************************************************************\
  77. * CPropEdit::SetPropertyName()
  78. *
  79. * Sets the property name string
  80. *
  81. *
  82. * Arguments:
  83. *
  84. * PropName - Property Name
  85. *
  86. * Return Value:
  87. *
  88. * none
  89. *
  90. * History:
  91. *
  92. * 2/14/1999 Original Version
  93. *
  94. \**************************************************************************/
  95. void CPropEdit::SetPropertyName(CString PropName)
  96. {
  97. m_strPropName = PropName;
  98. }
  99. /**************************************************************************\
  100. * CPropEdit::SetPropertyValue()
  101. *
  102. * Sets the property value string
  103. *
  104. *
  105. * Arguments:
  106. *
  107. * PropValue - Property Value
  108. *
  109. * Return Value:
  110. *
  111. * none
  112. *
  113. * History:
  114. *
  115. * 2/14/1999 Original Version
  116. *
  117. \**************************************************************************/
  118. void CPropEdit::SetPropertyValue(CString PropValue)
  119. {
  120. m_EditString = PropValue;
  121. }
  122. /**************************************************************************\
  123. * CPropEdit::SetPropertyType()
  124. *
  125. * Sets the property Type
  126. *
  127. *
  128. * Arguments:
  129. *
  130. * PropType - Property type
  131. *
  132. * Return Value:
  133. *
  134. * none
  135. *
  136. * History:
  137. *
  138. * 2/14/1999 Original Version
  139. *
  140. \**************************************************************************/
  141. void CPropEdit::SetPropertyType(USHORT PropType)
  142. {
  143. m_VT = PropType;
  144. }
  145. /////////////////////////////////////////////////////////////////////////////
  146. // CPropEditRange dialog
  147. /**************************************************************************\
  148. * CPropEditRange::CPropEditRange()
  149. *
  150. * Constructor for Property Edit dialog - RANGE type
  151. *
  152. *
  153. * Arguments:
  154. *
  155. * pParent - Parent Window
  156. *
  157. * Return Value:
  158. *
  159. * none
  160. *
  161. * History:
  162. *
  163. * 2/14/1999 Original Version
  164. *
  165. \**************************************************************************/
  166. CPropEditRange::CPropEditRange(CWnd* pParent /*=NULL*/)
  167. : CDialog(CPropEditRange::IDD, pParent)
  168. {
  169. //{{AFX_DATA_INIT(CPropEditRange)
  170. m_EditString = _T("");
  171. m_strPropName = _T("");
  172. m_Increment = _T("none");
  173. m_Maximum = _T("none");
  174. m_Minimum = _T("none");
  175. m_Nominal = _T("none");
  176. //}}AFX_DATA_INIT
  177. }
  178. /**************************************************************************\
  179. * CPropEditRange::DoDataExchange()
  180. *
  181. * Handles control message maps to the correct member variables
  182. *
  183. *
  184. * Arguments:
  185. *
  186. * pDX - DataExchange object
  187. *
  188. * Return Value:
  189. *
  190. * none
  191. *
  192. * History:
  193. *
  194. * 2/14/1999 Original Version
  195. *
  196. \**************************************************************************/
  197. void CPropEditRange::DoDataExchange(CDataExchange* pDX)
  198. {
  199. CDialog::DoDataExchange(pDX);
  200. //{{AFX_DATA_MAP(CPropEditRange)
  201. DDX_Control(pDX, IDOK, m_ButtonOk);
  202. DDX_Control(pDX, IDCANCEL, m_ButtonCancel);
  203. DDX_Text(pDX, IDC_EDITPROP, m_EditString);
  204. DDX_Text(pDX, IDC_PROP_NAME, m_strPropName);
  205. DDX_Text(pDX, IDC_INC, m_Increment);
  206. DDX_Text(pDX, IDC_MAX, m_Maximum);
  207. DDX_Text(pDX, IDC_MIN, m_Minimum);
  208. DDX_Text(pDX, IDC_NOM, m_Nominal);
  209. //}}AFX_DATA_MAP
  210. }
  211. BEGIN_MESSAGE_MAP(CPropEditRange, CDialog)
  212. //{{AFX_MSG_MAP(CPropEditRange)
  213. ON_WM_CLOSE()
  214. ON_WM_DESTROY()
  215. //}}AFX_MSG_MAP
  216. END_MESSAGE_MAP()
  217. /////////////////////////////////////////////////////////////////////////////
  218. // CPropEditRange message handlers
  219. /**************************************************************************\
  220. * CPropEdit::SetRangeValues()
  221. *
  222. * Sets the property Range Values
  223. *
  224. *
  225. * Arguments:
  226. *
  227. * Min - Minimum value
  228. * Max - Maximum value
  229. * Nom - Nominal value
  230. * Inc - Increment Value
  231. *
  232. * Return Value:
  233. *
  234. * none
  235. *
  236. * History:
  237. *
  238. * 2/14/1999 Original Version
  239. *
  240. \**************************************************************************/
  241. BOOL CPropEditRange::SetRangeValues(int Min, int Max, int Nom, int Inc)
  242. {
  243. m_Minimum.Format("%d",Min);
  244. m_Maximum.Format("%d",Max);
  245. m_Nominal.Format("%d",Nom);
  246. m_Increment.Format("%d",Inc);
  247. return TRUE;
  248. }
  249. /**************************************************************************\
  250. * CPropEdit::SetRangeValues()
  251. *
  252. * Sets the property Range Values
  253. *
  254. *
  255. * Arguments:
  256. *
  257. * Min - Minimum value
  258. * Max - Maximum value
  259. * Nom - Nominal value
  260. * Inc - Increment Value
  261. *
  262. * Return Value:
  263. *
  264. * none
  265. *
  266. * History:
  267. *
  268. * 2/14/1999 Original Version
  269. *
  270. \**************************************************************************/
  271. BOOL CPropEditRange::SetRangeValues(float Min, float Max, float Nom, float Inc)
  272. {
  273. m_Minimum.Format("%3.5f",Min);
  274. m_Maximum.Format("%3.5f",Max);
  275. m_Nominal.Format("%3.5f",Nom);
  276. m_Increment.Format("%3.5f",Inc);
  277. return TRUE;
  278. }
  279. /**************************************************************************\
  280. * CPropEditRange::SetPropertyName()
  281. *
  282. * Sets the property name string
  283. *
  284. *
  285. * Arguments:
  286. *
  287. * PropName - Property Name
  288. *
  289. * Return Value:
  290. *
  291. * none
  292. *
  293. * History:
  294. *
  295. * 2/14/1999 Original Version
  296. *
  297. \**************************************************************************/
  298. void CPropEditRange::SetPropertyName(CString PropName)
  299. {
  300. m_strPropName = PropName;
  301. }
  302. /**************************************************************************\
  303. * CPropEditRange::SetPropertyValue()
  304. *
  305. * Sets the property value string
  306. *
  307. *
  308. * Arguments:
  309. *
  310. * PropValue - Property Value
  311. *
  312. * Return Value:
  313. *
  314. * none
  315. *
  316. * History:
  317. *
  318. * 2/14/1999 Original Version
  319. *
  320. \**************************************************************************/
  321. void CPropEditRange::SetPropertyValue(CString PropValue)
  322. {
  323. m_EditString = PropValue;
  324. }
  325. /**************************************************************************\
  326. * CPropEditRange::SetPropertyType()
  327. *
  328. * Sets the property Type
  329. *
  330. *
  331. * Arguments:
  332. *
  333. * PropType - Property type
  334. *
  335. * Return Value:
  336. *
  337. * none
  338. *
  339. * History:
  340. *
  341. * 2/14/1999 Original Version
  342. *
  343. \**************************************************************************/
  344. void CPropEditRange::SetPropertyType(USHORT PropType)
  345. {
  346. m_VT = PropType;
  347. }
  348. /////////////////////////////////////////////////////////////////////////////
  349. // CPropEditList dialog
  350. /**************************************************************************\
  351. * CPropEditList::CPropEditList()
  352. *
  353. * Constructor for Property Edit dialog - LIST type
  354. *
  355. *
  356. * Arguments:
  357. *
  358. * pParent - Parent Window
  359. *
  360. * Return Value:
  361. *
  362. * none
  363. *
  364. * History:
  365. *
  366. * 2/14/1999 Original Version
  367. *
  368. \**************************************************************************/
  369. CPropEditList::CPropEditList(CWnd* pParent /*=NULL*/)
  370. : CDialog(CPropEditList::IDD, pParent)
  371. {
  372. //{{AFX_DATA_INIT(CPropEditList)
  373. m_EditString = _T("");
  374. m_strPropName = _T("");
  375. m_CurrentElementNum = 0;
  376. m_nElements = 0;
  377. m_pArray = NULL;
  378. //}}AFX_DATA_INIT
  379. }
  380. /**************************************************************************\
  381. * CPropEditList::DoDataExchange()
  382. *
  383. * Handles control message maps to the correct member variables
  384. *
  385. *
  386. * Arguments:
  387. *
  388. * pDX - DataExchange object
  389. *
  390. * Return Value:
  391. *
  392. * none
  393. *
  394. * History:
  395. *
  396. * 2/14/1999 Original Version
  397. *
  398. \**************************************************************************/
  399. void CPropEditList::DoDataExchange(CDataExchange* pDX)
  400. {
  401. CDialog::DoDataExchange(pDX);
  402. //{{AFX_DATA_MAP(CPropEditList)
  403. DDX_Control(pDX, IDC_LIST_LISTCTRL, m_ListValueListBox);
  404. DDX_Control(pDX, IDC_NUMLISTVALUES, m_NumListValueDisplay);
  405. DDX_Control(pDX, IDOK, m_ButtonOk);
  406. DDX_Control(pDX, IDCANCEL, m_ButtonCancel);
  407. DDX_Text(pDX, IDC_EDITPROP, m_EditString);
  408. DDX_Text(pDX, IDC_PROP_NAME, m_strPropName);
  409. //}}AFX_DATA_MAP
  410. }
  411. BEGIN_MESSAGE_MAP(CPropEditList, CDialog)
  412. //{{AFX_MSG_MAP(CPropEditList)
  413. ON_WM_CLOSE()
  414. ON_WM_DESTROY()
  415. ON_NOTIFY(NM_DBLCLK, IDC_LIST_LISTCTRL, OnDblclkListListctrl)
  416. ON_NOTIFY(NM_CLICK, IDC_LIST_LISTCTRL, OnClickListListctrl)
  417. //}}AFX_MSG_MAP
  418. END_MESSAGE_MAP()
  419. /////////////////////////////////////////////////////////////////////////////
  420. // CPropEditList message handlers
  421. /**************************************************************************\
  422. * CPropEditList::SetListValue()
  423. *
  424. * Sets the current list value in UINT array
  425. *
  426. *
  427. * Arguments:
  428. *
  429. * ListValue - List value to enter into UINT array
  430. *
  431. * Return Value:
  432. *
  433. * none
  434. *
  435. * History:
  436. *
  437. * 2/14/1999 Original Version
  438. *
  439. \**************************************************************************/
  440. BOOL CPropEditList::SetListValue(int ListValue)
  441. {
  442. //m_pUINTArray[m_CurrentElementNum] = ListValue;
  443. //m_CurrentElementNum++;
  444. return TRUE;
  445. }
  446. /**************************************************************************\
  447. * CPropEditList::SetArray()
  448. *
  449. * Sets the array bounds for the list data
  450. *
  451. *
  452. * Arguments:
  453. *
  454. * pArray - pointer to Array
  455. * nElements - Number of elements in the array
  456. *
  457. * Return Value:
  458. *
  459. * none
  460. *
  461. * History:
  462. *
  463. * 2/14/1999 Original Version
  464. *
  465. \**************************************************************************/
  466. BOOL CPropEditList::SetArray(BYTE *pArray, int nElements)
  467. {
  468. m_nElements = nElements;
  469. m_pArray = pArray;
  470. return TRUE;
  471. }
  472. /**************************************************************************\
  473. * CPropEditList::DisplayListValues()
  474. *
  475. * Displays list values to dialog listbox
  476. *
  477. *
  478. * Arguments:
  479. *
  480. * none
  481. *
  482. * Return Value:
  483. *
  484. * status
  485. *
  486. * History:
  487. *
  488. * 2/14/1999 Original Version
  489. *
  490. \**************************************************************************/
  491. BOOL CPropEditList::DisplayListValues()
  492. {
  493. CString Value = "";
  494. Value.Format("Total List Values = %d",m_nElements);
  495. m_NumListValueDisplay.SetWindowText(Value);
  496. int NumEntries = WiatestDatabase[0].nItems;
  497. BOOL bFoundName = FALSE;
  498. //
  499. // Search for known property in data base
  500. //
  501. for (int CurrentEntry = 1;CurrentEntry <= NumEntries;CurrentEntry++) {
  502. if (m_strPropName == (CString)(WiatestDatabase[CurrentEntry].pName)) {
  503. bFoundName = TRUE;
  504. int Index = 0;
  505. CString outStr = "";
  506. m_CurrentEntry = CurrentEntry;
  507. }
  508. }
  509. if (!bFoundName) {
  510. //
  511. // Name was not found..so display the actual values in the list
  512. //
  513. // AfxMessageBox(m_strPropName + " was not found in wtdb.h data base file...");
  514. for (UINT nElem = 0;nElem < (UINT)m_nElements; nElem++) {
  515. Value = "";
  516. switch (m_VT) {
  517. case VT_I1:
  518. case VT_I2:
  519. case VT_I4:
  520. case VT_I8:
  521. case VT_UI1:
  522. case VT_UI2:
  523. case VT_UI4:
  524. case VT_UI8:
  525. case VT_INT:
  526. Value.Format("%d",((INT*)m_pArray)[WIA_LIST_VALUES + nElem]);
  527. break;
  528. case VT_R4:
  529. case VT_R8:
  530. Value.Format("%3.3f",((float*)m_pArray)[WIA_LIST_VALUES + nElem]);
  531. break;
  532. case VT_BSTR:
  533. Value.Format("%ws",((BSTR*)m_pArray)[WIA_LIST_VALUES + nElem]);
  534. break;
  535. case VT_CLSID:
  536. {
  537. /*UCHAR *pwszUUID = NULL;
  538. UuidToStringA(&((GUID*)(m_pArray))[WIA_LIST_VALUES + nElem],&pwszUUID);
  539. Value.Format(ConvertGUIDListValueToCString(((GUID*)(m_pArray))[WIA_LIST_VALUES + nElem])+" %s",pwszUUID);
  540. RpcStringFree(&pwszUUID);*/
  541. //_asm int 3;
  542. //Value = ConvertGUIDListValueToCString((GUID*)(m_pArray)[WIA_LIST_VALUES + nElem]);
  543. Value = ConvertGUIDListValueToCString(((GUID*)(m_pArray))[WIA_LIST_VALUES + nElem]);
  544. }
  545. break;
  546. case VT_UINT:
  547. default:
  548. Value.Format("%d",((UINT*)m_pArray)[WIA_LIST_VALUES + nElem]);
  549. break;
  550. }
  551. LV_ITEM lvitem;
  552. lvitem.mask = LVIF_TEXT | LVIF_PARAM;
  553. lvitem.iItem = nElem;
  554. lvitem.iSubItem = 0;
  555. lvitem.pszText = Value.GetBuffer(Value.GetLength());
  556. lvitem.iImage = NULL;
  557. lvitem.lParam = 0;
  558. m_ListValueListBox.InsertItem(&lvitem);
  559. }
  560. } else {
  561. Value = "";
  562. for (UINT nElem = 0;nElem < (UINT)m_nElements; nElem++) {
  563. Value = "";
  564. Value.Format("%d",((UINT*)m_pArray)[WIA_LIST_VALUES + nElem]);
  565. LV_ITEM lvitem;
  566. CString InValue = ConvertListValueToCString(((UINT*)m_pArray)[WIA_LIST_VALUES + nElem]);
  567. lvitem.mask = LVIF_TEXT | LVIF_PARAM;
  568. lvitem.iItem = nElem;
  569. lvitem.iSubItem = 0;
  570. lvitem.pszText = InValue.GetBuffer(InValue.GetLength());
  571. lvitem.iImage = NULL;
  572. lvitem.lParam = 0;
  573. m_ListValueListBox.InsertItem(&lvitem);
  574. lvitem.iSubItem = 1;
  575. lvitem.mask = LVIF_TEXT;
  576. lvitem.pszText = Value.GetBuffer(Value.GetLength());
  577. m_ListValueListBox.SetItem(&lvitem);
  578. }
  579. }
  580. m_ListValueListBox.SetColumnWidth(0, LVSCW_AUTOSIZE);
  581. return TRUE;
  582. }
  583. /**************************************************************************\
  584. * CPropEditList::OnInitDialog()
  585. *
  586. * Initializes the Command dialog's controls/display
  587. *
  588. *
  589. * Arguments:
  590. *
  591. * none
  592. *
  593. * Return Value:
  594. *
  595. * status
  596. *
  597. * History:
  598. *
  599. * 2/14/1999 Original Version
  600. *
  601. \**************************************************************************/
  602. BOOL CPropEditList::OnInitDialog()
  603. {
  604. CDialog::OnInitDialog();
  605. LVCOLUMN lv;
  606. int i = 0;
  607. // initialize item property list control column headers
  608. // Property name
  609. lv.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
  610. lv.fmt = LVCFMT_LEFT ;
  611. lv.cx = 100;
  612. lv.pszText = "Constant";
  613. lv.cchTextMax = 0;
  614. lv.iSubItem = 0;
  615. lv.iImage = 0;
  616. lv.iOrder = 0;
  617. i = m_ListValueListBox.InsertColumn(0,&lv);
  618. // Property Value (current)
  619. lv.cx = 125;
  620. lv.iOrder = 1;
  621. lv.iSubItem = 1;
  622. lv.pszText = "Value";
  623. i = m_ListValueListBox.InsertColumn(1,&lv);
  624. HFONT hFixedFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
  625. if (hFixedFont != NULL)
  626. m_ListValueListBox.SendMessage(WM_SETFONT,(WPARAM)hFixedFont,0);
  627. if (m_nElements > 0)
  628. DisplayListValues();
  629. return TRUE; // return TRUE unless you set the focus to a control
  630. // EXCEPTION: OCX Property Pages should return FALSE
  631. }
  632. /**************************************************************************\
  633. * CPropEditList::OnClose()
  634. *
  635. * Handles closing of the Property LIST edit dialog
  636. *
  637. *
  638. * Arguments:
  639. *
  640. * none
  641. *
  642. * Return Value:
  643. *
  644. * void
  645. *
  646. * History:
  647. *
  648. * 2/14/1999 Original Version
  649. *
  650. \**************************************************************************/
  651. void CPropEditList::OnClose()
  652. {
  653. CDialog::OnClose();
  654. }
  655. /**************************************************************************\
  656. * CPropEditList::OnDestroy()
  657. *
  658. * Handles the destruction of the dialog data arrays
  659. *
  660. *
  661. * Arguments:
  662. *
  663. * none
  664. *
  665. * Return Value:
  666. *
  667. * void
  668. *
  669. * History:
  670. *
  671. * 2/14/1999 Original Version
  672. *
  673. \**************************************************************************/
  674. void CPropEditList::OnDestroy()
  675. {
  676. CDialog::OnDestroy();
  677. }
  678. /**************************************************************************\
  679. * CPropEditList::OnDblclkListListctrl()
  680. *
  681. * Handles Double click message from List control
  682. *
  683. *
  684. * Arguments:
  685. *
  686. * pNMHDR - Header info
  687. * pResult - Operation result
  688. *
  689. * Return Value:
  690. *
  691. * void
  692. *
  693. * History:
  694. *
  695. * 2/14/1999 Original Version
  696. *
  697. \**************************************************************************/
  698. void CPropEditList::OnDblclkListListctrl(NMHDR* pNMHDR, LRESULT* pResult)
  699. {
  700. int SelIndex = m_ListValueListBox.GetNextItem( -1, LVNI_ALL | LVNI_SELECTED);
  701. if ( SelIndex != -1 ) {
  702. switch (m_VT) {
  703. case VT_I1:
  704. case VT_I2:
  705. case VT_I4:
  706. case VT_I8:
  707. case VT_UI1:
  708. case VT_UI2:
  709. case VT_UI4:
  710. case VT_UI8:
  711. case VT_INT:
  712. m_EditString.Format("%d",((INT*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  713. break;
  714. case VT_R4:
  715. case VT_R8:
  716. m_EditString.Format("%3.3f",((float*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  717. break;
  718. case VT_BSTR:
  719. m_EditString.Format("%ws",((BSTR*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  720. break;
  721. case VT_CLSID:
  722. {
  723. UCHAR *pwszUUID = NULL;
  724. UuidToStringA(&((GUID*)(m_pArray))[WIA_LIST_VALUES + SelIndex],&pwszUUID);
  725. m_EditString.Format("%s",pwszUUID);
  726. RpcStringFree(&pwszUUID);
  727. }
  728. break;
  729. case VT_UINT:
  730. default:
  731. m_EditString.Format("%d",((UINT*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  732. break;
  733. }
  734. //m_EditString.Format("%d",m_pUINTArray[SelIndex]);
  735. UpdateData(FALSE);
  736. }
  737. OnOK();
  738. *pResult = 0;
  739. }
  740. /**************************************************************************\
  741. * CPropEditList::OnClickListListctrl()
  742. *
  743. * Handles Double click message from List control
  744. *
  745. *
  746. * Arguments:
  747. *
  748. * pNMHDR - Header info
  749. * pResult - Operation result
  750. *
  751. * Return Value:
  752. *
  753. * void
  754. *
  755. * History:
  756. *
  757. * 2/14/1999 Original Version
  758. *
  759. \**************************************************************************/
  760. void CPropEditList::OnClickListListctrl(NMHDR* pNMHDR, LRESULT* pResult)
  761. {
  762. int SelIndex = m_ListValueListBox.GetNextItem( -1, LVNI_ALL | LVNI_SELECTED);
  763. if ( SelIndex != -1 ) {
  764. switch (m_VT) {
  765. case VT_I1:
  766. case VT_I2:
  767. case VT_I4:
  768. case VT_I8:
  769. case VT_UI1:
  770. case VT_UI2:
  771. case VT_UI4:
  772. case VT_UI8:
  773. case VT_INT:
  774. m_EditString.Format("%d",((INT*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  775. break;
  776. case VT_R4:
  777. case VT_R8:
  778. m_EditString.Format("%3.3f",((float*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  779. break;
  780. case VT_BSTR:
  781. m_EditString.Format("%ws",((BSTR*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  782. break;
  783. case VT_CLSID:
  784. {
  785. UCHAR *pwszUUID = NULL;
  786. UuidToStringA(&((GUID*)(m_pArray))[WIA_LIST_VALUES + SelIndex],&pwszUUID);
  787. m_EditString.Format("%s",pwszUUID);
  788. RpcStringFree(&pwszUUID);
  789. }
  790. break;
  791. case VT_UINT:
  792. default:
  793. m_EditString.Format("%d",((UINT*)m_pArray)[WIA_LIST_VALUES + SelIndex]);
  794. break;
  795. }
  796. //m_EditString.Format("%d",m_pUINTArray[SelIndex]);
  797. UpdateData(FALSE);
  798. }
  799. *pResult = 0;
  800. }
  801. /**************************************************************************\
  802. * CPropEditList::SetPropertyName()
  803. *
  804. * Sets the property name string
  805. *
  806. *
  807. * Arguments:
  808. *
  809. * PropName - Property Name
  810. *
  811. * Return Value:
  812. *
  813. * none
  814. *
  815. * History:
  816. *
  817. * 2/14/1999 Original Version
  818. *
  819. \**************************************************************************/
  820. void CPropEditList::SetPropertyName(CString PropName)
  821. {
  822. m_strPropName = PropName;
  823. }
  824. /**************************************************************************\
  825. * CPropEditList::SetPropertyValue()
  826. *
  827. * Sets the property value string
  828. *
  829. *
  830. * Arguments:
  831. *
  832. * PropValue - Property Value
  833. *
  834. * Return Value:
  835. *
  836. * none
  837. *
  838. * History:
  839. *
  840. * 2/14/1999 Original Version
  841. *
  842. \**************************************************************************/
  843. void CPropEditList::SetPropertyValue(CString PropValue)
  844. {
  845. m_EditString = PropValue;
  846. }
  847. /**************************************************************************\
  848. * CPropEditList::SetPropertyType()
  849. *
  850. * Sets the property Type
  851. *
  852. *
  853. * Arguments:
  854. *
  855. * PropType - Property type
  856. *
  857. * Return Value:
  858. *
  859. * none
  860. *
  861. * History:
  862. *
  863. * 2/14/1999 Original Version
  864. *
  865. \**************************************************************************/
  866. void CPropEditList::SetPropertyType(USHORT PropType)
  867. {
  868. m_VT = PropType;
  869. }
  870. /**************************************************************************\
  871. * CPropEditList::ConvertListValueToCString()
  872. *
  873. * Converts a list value to a CString for display
  874. *
  875. *
  876. * Arguments:
  877. *
  878. * Value - List Value to convert
  879. *
  880. * Return Value:
  881. *
  882. * CString - converted List value in CString format
  883. *
  884. * History:
  885. *
  886. * 2/14/1999 Original Version
  887. *
  888. \**************************************************************************/
  889. CString CPropEditList::ConvertListValueToCString(UINT Value)
  890. {
  891. CString sFlag = "";
  892. for (int i = 0;i<WiatestDatabase[m_CurrentEntry].nItems;i++) {
  893. if (Value == WiatestDatabase[m_CurrentEntry].pData[i])
  894. sFlag = (CString)WiatestDatabase[m_CurrentEntry].pDataNames[i];
  895. }
  896. return sFlag;
  897. }
  898. /**************************************************************************\
  899. * CPropEditList::ConvertGUIDListValueToCString()
  900. *
  901. * Converts a list value to a CString for display
  902. *
  903. *
  904. * Arguments:
  905. *
  906. * Value - List Value to convert
  907. *
  908. * Return Value:
  909. *
  910. * CString - converted List value in CString format
  911. *
  912. * History:
  913. *
  914. * 2/14/1999 Original Version
  915. *
  916. \**************************************************************************/
  917. CString CPropEditList::ConvertGUIDListValueToCString(GUID guidValue)
  918. {
  919. if (guidValue == WiaImgFmt_UNDEFINED)
  920. return "WiaImgFmt_UNDEFINED";
  921. else if (guidValue == WiaImgFmt_MEMORYBMP)
  922. return "WiaImgFmt_MEMORYBMP";
  923. else if (guidValue == WiaImgFmt_BMP)
  924. return "WiaImgFmt_BMP";
  925. else if (guidValue == WiaImgFmt_EMF)
  926. return "WiaImgFmt_EMF";
  927. else if (guidValue == WiaImgFmt_WMF)
  928. return "WiaImgFmt_WMF";
  929. else if (guidValue == WiaImgFmt_JPEG)
  930. return "WiaImgFmt_JPEG";
  931. else if (guidValue == WiaImgFmt_PNG)
  932. return "WiaImgFmt_PNG";
  933. else if (guidValue == WiaImgFmt_GIF)
  934. return "WiaImgFmt_GIF";
  935. else if (guidValue == WiaImgFmt_TIFF)
  936. return "WiaImgFmt_TIFF";
  937. else if (guidValue == WiaImgFmt_EXIF)
  938. return "WiaImgFmt_EXIF";
  939. else if (guidValue == WiaImgFmt_PHOTOCD)
  940. return "WiaImgFmt_PHOTOCD";
  941. else if (guidValue == WiaImgFmt_FLASHPIX)
  942. return "WiaImgFmt_FLASHPIX";
  943. else
  944. return "** UNKNOWN **";
  945. }
  946. /////////////////////////////////////////////////////////////////////////////
  947. // CPropEditFlags dialog
  948. /**************************************************************************\
  949. * CPropEditFlags::CPropEditFlags()
  950. *
  951. * Constructor for Property Edit dialog - FLAGS type
  952. *
  953. *
  954. * Arguments:
  955. *
  956. * pParent - Parent Window
  957. *
  958. * Return Value:
  959. *
  960. * none
  961. *
  962. * History:
  963. *
  964. * 2/14/1999 Original Version
  965. *
  966. \**************************************************************************/
  967. CPropEditFlags::CPropEditFlags(CWnd* pParent /*=NULL*/)
  968. : CDialog(CPropEditFlags::IDD, pParent)
  969. {
  970. //{{AFX_DATA_INIT(CPropEditFlags)
  971. m_EditString = _T("");
  972. m_strPropName = _T("");
  973. //}}AFX_DATA_INIT
  974. }
  975. /**************************************************************************\
  976. * CPropEditFlags::DoDataExchange()
  977. *
  978. * Handles control message maps to the correct member variables
  979. *
  980. *
  981. * Arguments:
  982. *
  983. * pDX - DataExchange object
  984. *
  985. * Return Value:
  986. *
  987. * none
  988. *
  989. * History:
  990. *
  991. * 2/14/1999 Original Version
  992. *
  993. \**************************************************************************/
  994. void CPropEditFlags::DoDataExchange(CDataExchange* pDX)
  995. {
  996. CDialog::DoDataExchange(pDX);
  997. //{{AFX_DATA_MAP(CPropEditFlags)
  998. DDX_Control(pDX, IDC_FLAGS_LISTCTRL, m_FlagValueListBox);
  999. DDX_Control(pDX, IDC_CURRENTFLAGSTR, m_CurrentFlagValue);
  1000. DDX_Control(pDX, IDOK, m_ButtonOk);
  1001. DDX_Control(pDX, IDCANCEL, m_ButtonCancel);
  1002. DDX_Text(pDX, IDC_EDITPROP, m_EditString);
  1003. DDX_Text(pDX, IDC_PROP_NAME, m_strPropName);
  1004. //}}AFX_DATA_MAP
  1005. }
  1006. BEGIN_MESSAGE_MAP(CPropEditFlags, CDialog)
  1007. //{{AFX_MSG_MAP(CPropEditFlags)
  1008. ON_WM_CLOSE()
  1009. ON_WM_DESTROY()
  1010. ON_NOTIFY(NM_CLICK, IDC_FLAGS_LISTCTRL, OnClickFlagsListctrl)
  1011. //}}AFX_MSG_MAP
  1012. END_MESSAGE_MAP()
  1013. /////////////////////////////////////////////////////////////////////////////
  1014. // CPropEditFlags message handlers
  1015. /**************************************************************************\
  1016. * CPropEditFlags::OnInitDialog()
  1017. *
  1018. * Initializes the Command dialog's controls/display
  1019. *
  1020. *
  1021. * Arguments:
  1022. *
  1023. * none
  1024. *
  1025. * Return Value:
  1026. *
  1027. * status
  1028. *
  1029. * History:
  1030. *
  1031. * 2/14/1999 Original Version
  1032. *
  1033. \**************************************************************************/
  1034. BOOL CPropEditFlags::OnInitDialog()
  1035. {
  1036. CDialog::OnInitDialog();
  1037. LVCOLUMN lv;
  1038. int i = 0;
  1039. // initialize item property list control column headers
  1040. // Property name
  1041. lv.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
  1042. lv.fmt = LVCFMT_LEFT ;
  1043. lv.cx = 100;
  1044. lv.pszText = "Constant";
  1045. lv.cchTextMax = 0;
  1046. lv.iSubItem = 0;
  1047. lv.iImage = 0;
  1048. lv.iOrder = 0;
  1049. i = m_FlagValueListBox.InsertColumn(0,&lv);
  1050. // Property Value (current)
  1051. lv.cx = 125;
  1052. lv.iOrder = 1;
  1053. lv.iSubItem = 1;
  1054. lv.pszText = "Value";
  1055. i = m_FlagValueListBox.InsertColumn(1,&lv);
  1056. HFONT hFixedFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
  1057. if (hFixedFont != NULL)
  1058. m_FlagValueListBox.SendMessage(WM_SETFONT,(WPARAM)hFixedFont,0);
  1059. InitPossibleFlagValues();
  1060. m_CurrentFlagValue.SetWindowText(ConvertFlagToCString(m_CurrentValue));
  1061. m_EditString.Format("0x%08X",m_CurrentValue);
  1062. UpdateData(FALSE);
  1063. return TRUE; // return TRUE unless you set the focus to a control
  1064. // EXCEPTION: OCX Property Pages should return FALSE
  1065. }
  1066. /**************************************************************************\
  1067. * CPropEditFlags::OnClose()
  1068. *
  1069. * Handles closing of the Property FLAGS edit dialog
  1070. *
  1071. *
  1072. * Arguments:
  1073. *
  1074. * none
  1075. *
  1076. * Return Value:
  1077. *
  1078. * void
  1079. *
  1080. * History:
  1081. *
  1082. * 2/14/1999 Original Version
  1083. *
  1084. \**************************************************************************/
  1085. void CPropEditFlags::OnClose()
  1086. {
  1087. CDialog::OnClose();
  1088. }
  1089. /**************************************************************************\
  1090. * CPropEditFlags::OnDestroy()
  1091. *
  1092. * Handles the destruction of the dialog data arrays
  1093. *
  1094. *
  1095. * Arguments:
  1096. *
  1097. * none
  1098. *
  1099. * Return Value:
  1100. *
  1101. * void
  1102. *
  1103. * History:
  1104. *
  1105. * 2/14/1999 Original Version
  1106. *
  1107. \**************************************************************************/
  1108. void CPropEditFlags::OnDestroy()
  1109. {
  1110. CDialog::OnDestroy();
  1111. }
  1112. /**************************************************************************\
  1113. * CPropEditFlags::SetPropertyName()
  1114. *
  1115. * Sets the property name string
  1116. *
  1117. *
  1118. * Arguments:
  1119. *
  1120. * PropName - Property Name
  1121. *
  1122. * Return Value:
  1123. *
  1124. * none
  1125. *
  1126. * History:
  1127. *
  1128. * 2/14/1999 Original Version
  1129. *
  1130. \**************************************************************************/
  1131. void CPropEditFlags::SetPropertyName(CString PropName)
  1132. {
  1133. m_strPropName = PropName;
  1134. }
  1135. /**************************************************************************\
  1136. * CPropEditFlags::SetPropertyValue()
  1137. *
  1138. * Sets the property value string
  1139. *
  1140. *
  1141. * Arguments:
  1142. *
  1143. * PropValue - Property Value
  1144. *
  1145. * Return Value:
  1146. *
  1147. * none
  1148. *
  1149. * History:
  1150. *
  1151. * 2/14/1999 Original Version
  1152. *
  1153. \**************************************************************************/
  1154. void CPropEditFlags::SetPropertyValue(CString PropValue)
  1155. {
  1156. m_EditString = PropValue;
  1157. sscanf(m_EditString.GetBuffer(20),"%li",&m_CurrentValue);
  1158. }
  1159. /**************************************************************************\
  1160. * CPropEditFlags::SetPropertyType()
  1161. *
  1162. * Sets the property Type
  1163. *
  1164. *
  1165. * Arguments:
  1166. *
  1167. * PropType - Property type
  1168. *
  1169. * Return Value:
  1170. *
  1171. * none
  1172. *
  1173. * History:
  1174. *
  1175. * 2/14/1999 Original Version
  1176. *
  1177. \**************************************************************************/
  1178. void CPropEditFlags::SetPropertyType(USHORT PropType)
  1179. {
  1180. m_VT = PropType;
  1181. }
  1182. /**************************************************************************\
  1183. * CPropEditFlags::SetPropID()
  1184. *
  1185. * Sets the property ID
  1186. *
  1187. *
  1188. * Arguments:
  1189. *
  1190. * iProp - Property ID
  1191. *
  1192. * Return Value:
  1193. *
  1194. * none
  1195. *
  1196. * History:
  1197. *
  1198. * 2/14/1999 Original Version
  1199. *
  1200. \**************************************************************************/
  1201. void CPropEditFlags::SetPropID(USHORT iProp)
  1202. {
  1203. m_PropID = iProp;
  1204. }
  1205. /**************************************************************************\
  1206. * CPropEditFlags::InitPossibleFlagsValues()
  1207. *
  1208. * Displays the Possible flag values to be used for setting
  1209. *
  1210. *
  1211. * Arguments:
  1212. *
  1213. * none
  1214. *
  1215. * Return Value:
  1216. *
  1217. * none
  1218. *
  1219. * History:
  1220. *
  1221. * 2/14/1999 Original Version
  1222. *
  1223. \**************************************************************************/
  1224. void CPropEditFlags::InitPossibleFlagValues()
  1225. {
  1226. int NumEntries = WiatestDatabase[0].nItems;
  1227. BOOL bFoundName = FALSE;
  1228. for (int CurrentEntry = 1;CurrentEntry <= NumEntries;CurrentEntry++) {
  1229. if (m_strPropName == (CString)(WiatestDatabase[CurrentEntry].pName)) {
  1230. bFoundName = TRUE;
  1231. int Index = 0;
  1232. CString InValue = "";
  1233. CString Value = "";
  1234. m_CurrentEntry = CurrentEntry;
  1235. while (Index <= WiatestDatabase[CurrentEntry].nItems-1) {
  1236. InValue = ConvertFlagToCString(WiatestDatabase[CurrentEntry].pData[Index]);
  1237. Value = "";
  1238. Value.Format("0x%08X",WiatestDatabase[CurrentEntry].pData[Index]);
  1239. LV_ITEM lvitem;
  1240. lvitem.mask = LVIF_TEXT | LVIF_PARAM;
  1241. lvitem.iItem = Index;
  1242. lvitem.iSubItem = 0;
  1243. lvitem.pszText = InValue.GetBuffer(InValue.GetLength());
  1244. lvitem.iImage = NULL;
  1245. lvitem.lParam = 0;
  1246. m_FlagValueListBox.InsertItem(&lvitem);
  1247. lvitem.iSubItem = 1;
  1248. lvitem.mask = LVIF_TEXT;
  1249. lvitem.pszText = Value.GetBuffer(Value.GetLength());
  1250. m_FlagValueListBox.SetItem(&lvitem);
  1251. Index++;
  1252. }
  1253. }
  1254. }
  1255. if (!bFoundName)
  1256. AfxMessageBox(m_strPropName + " was not found in wtdb.h data base file...");
  1257. m_FlagValueListBox.SetColumnWidth(0, LVSCW_AUTOSIZE);
  1258. }
  1259. /**************************************************************************\
  1260. * CPropEditFlags::ConvertFlagToCString()
  1261. *
  1262. * Converts a Flag value to a CString for display
  1263. *
  1264. *
  1265. * Arguments:
  1266. *
  1267. * flag - Flag Value to convert
  1268. *
  1269. * Return Value:
  1270. *
  1271. * CString - converted Flag value in CString format
  1272. *
  1273. * History:
  1274. *
  1275. * 2/14/1999 Original Version
  1276. *
  1277. \**************************************************************************/
  1278. CString CPropEditFlags::ConvertFlagToCString(DWORD flag)
  1279. {
  1280. CString sFlag = "";
  1281. for (int i = 0;i<WiatestDatabase[m_CurrentEntry].nItems;i++) {
  1282. if (flag & WiatestDatabase[m_CurrentEntry].pData[i])
  1283. sFlag += (CString)WiatestDatabase[m_CurrentEntry].pDataNames[i] + " | ";
  1284. }
  1285. //
  1286. // check for unknown flags
  1287. //
  1288. if (sFlag.GetLength() == 0) {
  1289. //
  1290. // last check...since 0 can be counted as FALSE causing the
  1291. // if() to fail, this is a check for the first entry (just in case
  1292. // the flag's value is 0)
  1293. //
  1294. if (flag == WiatestDatabase[m_CurrentEntry].pData[0])
  1295. sFlag = (CString)WiatestDatabase[m_CurrentEntry].pDataNames[0] + " | ";
  1296. else
  1297. sFlag.Format("UNKNOWN Flag = %d ",flag);
  1298. }
  1299. sFlag = sFlag.Left(sFlag.GetLength()-3);
  1300. return sFlag;
  1301. }
  1302. /**************************************************************************\
  1303. * CPropEditFlags::OnClickFlagsListctrl()
  1304. *
  1305. * Handles click message to list control, selecting a flag to be used
  1306. *
  1307. *
  1308. * Arguments:
  1309. *
  1310. * pNMHDR - Header information
  1311. * pResult - Result value
  1312. *
  1313. * Return Value:
  1314. *
  1315. * none
  1316. *
  1317. * History:
  1318. *
  1319. * 2/14/1999 Original Version
  1320. *
  1321. \**************************************************************************/
  1322. void CPropEditFlags::OnClickFlagsListctrl(NMHDR* pNMHDR, LRESULT* pResult)
  1323. {
  1324. m_CurrentValue = 0;
  1325. int i = m_FlagValueListBox.GetNextItem( -1, LVNI_ALL | LVNI_SELECTED);
  1326. while ( i != -1 ) {
  1327. m_CurrentValue = m_CurrentValue | WiatestDatabase[m_CurrentEntry].pData[i];
  1328. i = m_FlagValueListBox.GetNextItem( i, LVNI_ALL | LVNI_SELECTED);
  1329. }
  1330. m_CurrentFlagValue.SetWindowText(ConvertFlagToCString(m_CurrentValue));
  1331. m_EditString.Format("0x%08X",m_CurrentValue);
  1332. UpdateData(FALSE);
  1333. *pResult = 0;
  1334. }