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.

1487 lines
46 KiB

  1. /*******************************************************************************
  2. **
  3. ** MODULE: USER.C
  4. **
  5. ** DESCRIPTION: Routines for getting user input for the different Entities
  6. **
  7. **
  8. **
  9. ** AUTHOR: John Pierce.
  10. **
  11. **
  12. **
  13. ** CREATED: 02/29/96
  14. **
  15. ** HISTORY:
  16. **
  17. ** Date Author Reason
  18. ** ----------------------------------------------------------------------
  19. ** 02/29/96 John Pierce (johnpi) Took over dev from Dan
  20. **
  21. **
  22. ** (C) C O P Y R I G H T M I C R O S O F T C O R P 1 9 9 5 - 1 9 9 6.
  23. **
  24. ** A L L R I G H T S R E S E R V E D .
  25. **
  26. *******************************************************************************/
  27. #include <windows.h>
  28. #include <string.h>
  29. #include <stdio.h> // for sscanf()
  30. #include "..\include\dt.h"
  31. #include "..\include\dtrc.h"
  32. #define MAX_USAGE_PAGES 8
  33. char szUsagePage[MAX_USAGE_PAGES][20] = {
  34. "Undefiend", // 0
  35. "GenericDesktop", // 1
  36. "Vehicle", // 2
  37. "VR", // 3
  38. "Sport", // 4
  39. "Game", // 5
  40. "Consumer", // 6
  41. "Keyboard" }; // 7
  42. /*******************************************************************************
  43. **
  44. ** UINT AddString( HANDLE hListBox, char * szString, int Index )
  45. **
  46. ** DESCRIPTION: Add string "string" to list box hListBox. If flag gfInsert
  47. ** is TRUE, insert string at current position in hListBox
  48. **
  49. **
  50. ** PARAMETERS: hListBox Handle to the Desc window
  51. ** szString String to add
  52. ** Index Pos. to add string. If = DONT_CARE get Pos. from
  53. ** Current Selection, otherwise insert at Index
  54. **
  55. ** RETURNS: Index of string that was added to hListbox
  56. **
  57. *******************************************************************************/
  58. LRESULT AddString(HANDLE hListBox,char * szString)
  59. {
  60. int Index=-1;
  61. if( gfInsert )
  62. {
  63. Index = SendMessage(hListBox,LB_GETCURSEL,0,0);
  64. SendMessage(hListBox,LB_INSERTSTRING,(WPARAM)Index,(LPARAM)szString);
  65. return Index;
  66. }
  67. else
  68. {
  69. Index = SendMessage(hListBox,LB_INSERTSTRING,(WPARAM)Index,(LPARAM)szString);
  70. SendMessage(hListBox,LB_SETCURSEL,Index,0);
  71. return Index;
  72. }
  73. }
  74. /*******************************************************************************
  75. **
  76. ** void GetBogusVal( HANDLE hDescListBox, int nEntity
  77. **
  78. ** DESCRIPTION: Get user input for a bogus Item
  79. **
  80. ** PARAMETERS: hDescListBox Handle to the Desc window
  81. ** hHexListBox Handle to the Hex window
  82. ** nEntity Not used
  83. **
  84. ** RETURNS:
  85. **
  86. *******************************************************************************/
  87. void GetBogusVal( HANDLE hDescListBox, int nEntity)
  88. {
  89. PITEM_INFO pItemInfo;
  90. char szBuff[128],szTmp[4];
  91. LRESULT Index,rc;
  92. BYTE *pb;
  93. int i,NumBytes;
  94. rc = DialogBox( ghInst,"EditBoxDlg",ghWnd , EditBoxDlgProc);
  95. if( rc == TRUE )
  96. {
  97. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  98. {
  99. pItemInfo->bTag = (BYTE)gEditVal;
  100. rc = DialogBox( ghInst,"EditBoxDlg",ghWnd , EditBoxDlgProc);
  101. if( rc == TRUE )
  102. {
  103. pItemInfo->bTag = Entity[nEntity];
  104. if( gEditVal < 0 ) // Handle negative numbers differently
  105. {
  106. if( gEditVal > -0x100 )
  107. {
  108. pItemInfo->bTag |= 0x01;
  109. NumBytes = 1;
  110. }
  111. else if (gEditVal > -0x10000 )
  112. {
  113. pItemInfo->bTag |= 0x02;
  114. NumBytes = 2;
  115. }
  116. else
  117. {
  118. pItemInfo->bTag |= 0x03;
  119. NumBytes = 4;
  120. }
  121. }
  122. else // Number is not negative
  123. {
  124. if( (DWORD)gEditVal < 0x80 )
  125. {
  126. pItemInfo->bTag |= 0x01;
  127. NumBytes = 1;
  128. }
  129. else if ( (DWORD)gEditVal < 0x8000 )
  130. {
  131. pItemInfo->bTag |= 0x02;
  132. NumBytes = 2;
  133. }
  134. else
  135. {
  136. pItemInfo->bTag |= 0x03;
  137. NumBytes = 4;
  138. }
  139. }
  140. }
  141. gwReportDescLen += NumBytes + 1; // +1 for Item tag byte
  142. wsprintf(szBuff,"UNDEFINED_TAG\t%02X ",pItemInfo->bTag);
  143. pb = (BYTE *) &gEditVal;
  144. for( i=0;i<NumBytes;i++ )
  145. {
  146. pItemInfo->bParam[i] = *pb++;
  147. wsprintf(szTmp,"%02X ",pItemInfo->bParam[i]);
  148. strcat(szBuff,szTmp);
  149. }
  150. Index = AddString(hDescListBox,szBuff);
  151. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  152. }
  153. else
  154. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  155. }
  156. }
  157. /*******************************************************************************
  158. **
  159. ** void GetUsagePageVal( HANDLE hDescListBox, int nEntity
  160. **
  161. ** DESCRIPTION: Get user input for a UsagePage Tag
  162. **
  163. ** PARAMETERS: hDescListBox Handle to the Desc window
  164. ** hHexListBox Handle to the Hex window
  165. ** nEntity Not used
  166. **
  167. ** RETURNS:
  168. **
  169. *******************************************************************************/
  170. void GetUsagePageVal( HANDLE hDescListBox, int nEntity)
  171. {
  172. PITEM_INFO pItemInfo;
  173. char szBuff[128];
  174. LRESULT Index,rc;
  175. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_USAGEPAGE),ghWnd , UsagePageDlgProc);
  176. if( rc == TRUE )
  177. {
  178. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  179. {
  180. pItemInfo->bTag = USAGE_PAGE;
  181. pItemInfo->bTag |= 0x01; // 1 BYTE of param info
  182. pItemInfo->bParam[0] = gUsagePageVal;
  183. wsprintf(szBuff,"USAGE_PAGE (%s)\t%02X %02X",szUsagePage[gUsagePageVal],
  184. pItemInfo->bTag,gUsagePageVal);
  185. Index = AddString(hDescListBox,szBuff);
  186. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  187. gwReportDescLen += 2; // Tag + Data
  188. }
  189. else
  190. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  191. }
  192. }
  193. /*******************************************************************************
  194. **
  195. ** void GetInputFromEditBoxSigned( HANDLE hDescListBox, int nEntity
  196. **
  197. ** DESCRIPTION: Generic routine to get signed numeric user input from an edit field
  198. **
  199. **
  200. ** PARAMETERS: hDescListBox Handle to the Desc window
  201. ** hHexListBox Handle to the Hex window
  202. ** nEntity Entity that we are getting value for
  203. **
  204. ** RETURNS:
  205. **
  206. *******************************************************************************/
  207. void GetInputFromEditBoxSigned( HANDLE hDescListBox, int nEntity)
  208. {
  209. PITEM_INFO pItemInfo;
  210. char szBuff[128],szTmp[3];
  211. int i;
  212. LRESULT Index,rc;
  213. BYTE *pb;
  214. rc = DialogBox( ghInst,"EditBoxDlg",ghWnd , EditBoxDlgProc);
  215. if( rc == TRUE )
  216. {
  217. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  218. {
  219. int NumBytes=0;
  220. pItemInfo->bTag = Entity[nEntity];
  221. if( gEditVal < 0 ) // Handle negative numbers differently
  222. {
  223. if( gEditVal > 0xffffff01 )
  224. {
  225. pItemInfo->bTag |= 0x01;
  226. NumBytes = 1;
  227. }
  228. else if (gEditVal > 0xffff0001 )
  229. {
  230. pItemInfo->bTag |= 0x02;
  231. NumBytes = 2;
  232. }
  233. else
  234. {
  235. pItemInfo->bTag |= 0x03;
  236. NumBytes = 4;
  237. }
  238. }
  239. else // Number is not negative
  240. {
  241. if( (DWORD)gEditVal < 0x80 ) // if the hi bit is set, we must
  242. { // add an upper byte of 0 so the
  243. pItemInfo->bTag |= 0x01; // numbers remain positive
  244. NumBytes = 1;
  245. }
  246. else if ( (DWORD)gEditVal < 0x8000 )
  247. {
  248. pItemInfo->bTag |= 0x02;
  249. NumBytes = 2;
  250. }
  251. else
  252. {
  253. pItemInfo->bTag |= 0x03;
  254. NumBytes = 4;
  255. }
  256. }
  257. gwReportDescLen += NumBytes + 1; // +1 for Item Tag byte
  258. wsprintf(szBuff,"%s (%d)\t%02X ",szEntity[nEntity],gEditVal,pItemInfo->bTag);
  259. pb = (BYTE *) &gEditVal;
  260. for( i=0;i<NumBytes;i++ )
  261. {
  262. pItemInfo->bParam[i] = *pb++;
  263. wsprintf(szTmp,"%02X ",pItemInfo->bParam[i]);
  264. strcat(szBuff,szTmp);
  265. }
  266. Index = AddString(hDescListBox,szBuff);
  267. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  268. }
  269. else
  270. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  271. }//end if(rc == TRUE)
  272. }
  273. /*******************************************************************************
  274. **
  275. ** void GetInputFromEditBoxUnSigned( HANDLE hDescListBox, int nEntity
  276. **
  277. ** DESCRIPTION: Generic routine to get unsigned numeric user input from
  278. ** an edit field
  279. **
  280. **
  281. ** PARAMETERS: hDescListBox Handle to the Desc window
  282. ** hHexListBox Handle to the Hex window
  283. ** nEntity Entity that we are getting value for
  284. **
  285. ** RETURNS:
  286. **
  287. *******************************************************************************/
  288. void GetInputFromEditBoxUnSigned( HANDLE hDescListBox, int nEntity)
  289. {
  290. PITEM_INFO pItemInfo;
  291. char szBuff[128],szTmp[3];
  292. int i;
  293. LRESULT Index,rc;
  294. BYTE *pb;
  295. rc = DialogBox( ghInst,"EditBoxDlg",ghWnd , EditBoxDlgProc);
  296. if( rc == TRUE )
  297. {
  298. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  299. {
  300. int NumBytes=0;
  301. pItemInfo->bTag = Entity[nEntity];
  302. if( (DWORD)gEditVal < 0x100 )
  303. {
  304. pItemInfo->bTag |= 0x01;
  305. NumBytes = 1;
  306. }
  307. else if ( (DWORD)gEditVal < 0x10000 )
  308. {
  309. pItemInfo->bTag |= 0x02;
  310. NumBytes = 2;
  311. }
  312. else
  313. {
  314. pItemInfo->bTag |= 0x03;
  315. NumBytes = 4;
  316. }
  317. gwReportDescLen += NumBytes + 1; // +1 for Item Tag byte
  318. wsprintf(szBuff,"%s (%d)\t%02X ",szEntity[nEntity],gEditVal,pItemInfo->bTag);
  319. pb = (BYTE *) &gEditVal;
  320. for( i=0;i<NumBytes;i++ )
  321. {
  322. pItemInfo->bParam[i] = *pb++;
  323. wsprintf(szTmp,"%02X ",pItemInfo->bParam[i]);
  324. strcat(szBuff,szTmp);
  325. }
  326. Index = AddString(hDescListBox,szBuff);
  327. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  328. }
  329. else
  330. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  331. }//end if(rc == TRUE)
  332. }
  333. /*******************************************************************************
  334. **
  335. ** void GetCollectionVal( HANDLE hDescListBox,int nEntity)
  336. **
  337. ** DESCRIPTION: Get user input for a Collection Tag
  338. **
  339. **
  340. ** PARAMETERS: hDescListBox Handle to the Desc window
  341. ** hHexListBox Handle to the Hex window
  342. ** nEntity Not used
  343. **
  344. ** RETURNS:
  345. **
  346. *******************************************************************************/
  347. void GetCollectionVal( HANDLE hDescListBox, int nEntity)
  348. {
  349. PITEM_INFO pItemInfo;
  350. char szBuff[128];
  351. LRESULT Index,rc;
  352. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_COLLECTION),ghWnd , CollectionDlgProc);
  353. if( rc == TRUE )
  354. {
  355. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  356. {
  357. pItemInfo->bTag = COLLECTION;
  358. pItemInfo->bTag |= 0x01; // Collection has 1 parm
  359. pItemInfo->bParam[0] = gCollectionVal;
  360. wsprintf(szBuff,"COLLECTION (%s)\t%02X %02X",(pItemInfo->bParam[0]) ? "Application" : "Linked",
  361. pItemInfo->bTag,pItemInfo->bParam[0]);
  362. Index = AddString(hDescListBox,szBuff);
  363. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  364. gwReportDescLen += 2; // Tag + Data
  365. }
  366. else
  367. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  368. }//end if(rc == TRUE)
  369. }
  370. /*******************************************************************************
  371. **
  372. ** void GetEndCollectionVal( HANDLE hDescListBox, int nEntity)
  373. **
  374. ** DESCRIPTION: Fills in the PITEM_INFO struct with a EndCollection tag value
  375. **
  376. **
  377. ** PARAMETERS: hDescListBox Handle to the Desc window
  378. ** hHexListBox Handle to the Hex window
  379. ** nEntity Not used
  380. **
  381. ** RETURNS:
  382. **
  383. *******************************************************************************/
  384. void GetEndCollectionVal( HANDLE hDescListBox, int nEntity)
  385. {
  386. PITEM_INFO pItemInfo;
  387. char szBuff[128];
  388. LRESULT Index,rc;
  389. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  390. {
  391. pItemInfo->bTag = END_COLLECTION;
  392. wsprintf(szBuff,"END_COLLECTION\t%02X",END_COLLECTION);
  393. Index = AddString(hDescListBox,szBuff);
  394. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  395. gwReportDescLen++; // +1 for Item Tag byte
  396. }
  397. else
  398. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  399. }
  400. /*******************************************************************************
  401. **
  402. ** void GetInputVal( HANDLE hDescListBox, int nEntity)
  403. **
  404. ** DESCRIPTION: Get user input for a Input tag
  405. **
  406. **
  407. ** PARAMETERS: hDescListBox Handle to the Desc window
  408. ** hHexListBox Handle to the Hex window
  409. ** nEntity Not used
  410. **
  411. ** RETURNS:
  412. **
  413. *******************************************************************************/
  414. void GetInputVal( HANDLE hDescListBox, int nEntity)
  415. {
  416. PITEM_INFO pItemInfo;
  417. char szBuff[128];
  418. LRESULT Index,rc;
  419. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_OUTPUT),ghWnd , MainItemDlgProc);
  420. if( rc == TRUE )
  421. {
  422. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  423. {
  424. pItemInfo->bTag = INPUT;
  425. if( HIBYTE(gMainItemVal) )
  426. pItemInfo->bTag |= 0x02;
  427. else
  428. pItemInfo->bTag |= 0x01;
  429. pItemInfo->bParam[0] = LOBYTE(gMainItemVal);
  430. pItemInfo->bParam[1] = HIBYTE(gMainItemVal);
  431. if( HIBYTE(gMainItemVal))
  432. {
  433. wsprintf(szBuff,"INPUT (%d)\t%02X %02X %02X",gMainItemVal,pItemInfo->bTag,pItemInfo->bParam[1],
  434. pItemInfo->bParam[0] );
  435. gwReportDescLen += 3;
  436. }
  437. else
  438. {
  439. wsprintf(szBuff,"INPUT (%d)\t%02X %02X",gMainItemVal,pItemInfo->bTag,pItemInfo->bParam[0]);
  440. gwReportDescLen += 2;
  441. }
  442. Index = AddString(hDescListBox,szBuff);
  443. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  444. }
  445. else
  446. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  447. }
  448. }
  449. /*******************************************************************************
  450. **
  451. ** void GetOutputVal( HANDLE hDescListBox, int nEntity)
  452. **
  453. ** DESCRIPTION: Get user input for a Output Tag
  454. **
  455. **
  456. ** PARAMETERS: hDescListBox Handle to the Desc window
  457. ** hHexListBox Handle to the Hex window
  458. ** nEntity Not used
  459. **
  460. ** RETURNS:
  461. **
  462. *******************************************************************************/
  463. void GetOutputVal( HANDLE hDescListBox, int nEntity)
  464. {
  465. PITEM_INFO pItemInfo;
  466. char szBuff[128];
  467. LRESULT Index,rc;
  468. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_OUTPUT),ghWnd , MainItemDlgProc);
  469. if( rc == TRUE )
  470. {
  471. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  472. {
  473. pItemInfo->bTag = OUTPUT;
  474. if( HIBYTE(gMainItemVal) )
  475. pItemInfo->bTag |= 0x02;
  476. else
  477. pItemInfo->bTag |= 0x01;
  478. pItemInfo->bParam[0] = LOBYTE(gMainItemVal);
  479. pItemInfo->bParam[1] = HIBYTE(gMainItemVal);
  480. if( HIBYTE(gMainItemVal))
  481. {
  482. wsprintf(szBuff,"OUTPUT (%d)\t%02X %02X %02X",gMainItemVal,pItemInfo->bTag,pItemInfo->bParam[1],
  483. pItemInfo->bParam[0] );
  484. gwReportDescLen += 3;
  485. }
  486. else
  487. {
  488. wsprintf(szBuff,"OUTPUT (%d)\t%02X %02X",gMainItemVal,pItemInfo->bTag,pItemInfo->bParam[0]);
  489. gwReportDescLen += 2;
  490. }
  491. Index = AddString(hDescListBox,szBuff);
  492. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  493. }
  494. else
  495. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  496. }
  497. }
  498. /*******************************************************************************
  499. **
  500. ** void GetFeatVal( HANDLE hDescListBox, int nEntity)
  501. **
  502. ** DESCRIPTION: Get user input for a Feature Tag
  503. **
  504. **
  505. ** PARAMETERS: hDescListBox Handle to the Desc window
  506. ** hHexListBox Handle to the Hex window
  507. ** nEntity Not used
  508. **
  509. ** RETURNS:
  510. **
  511. *******************************************************************************/
  512. void GetFeatVal( HANDLE hDescListBox, int nEntity)
  513. {
  514. PITEM_INFO pItemInfo;
  515. char szBuff[128];
  516. LRESULT Index,rc;
  517. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_OUTPUT),ghWnd , MainItemDlgProc);
  518. if( rc == TRUE )
  519. {
  520. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  521. {
  522. pItemInfo->bTag = FEATURE;
  523. if( HIBYTE(gMainItemVal) )
  524. pItemInfo->bTag |= 0x02;
  525. else
  526. pItemInfo->bTag |= 0x01;
  527. pItemInfo->bParam[0] = LOBYTE(gMainItemVal);
  528. pItemInfo->bParam[1] = HIBYTE(gMainItemVal);
  529. if( HIBYTE(gMainItemVal))
  530. {
  531. wsprintf(szBuff,"FEATURE (%d)\t%02X %02X %02X",gMainItemVal,pItemInfo->bTag,pItemInfo->bParam[1],
  532. pItemInfo->bParam[0] );
  533. gwReportDescLen += 3;
  534. }
  535. else
  536. {
  537. wsprintf(szBuff,"FEATURE (%d)\t%02X %02X",gMainItemVal,pItemInfo->bTag,pItemInfo->bParam[0]);
  538. gwReportDescLen += 2;
  539. }
  540. Index = AddString(hDescListBox,szBuff);
  541. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  542. }
  543. else
  544. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  545. }
  546. }
  547. /*******************************************************************************
  548. **
  549. ** void GetExponentVal( HANDLE hDescListBox, HANDLE hHexListBox int nEntity)
  550. **
  551. ** DESCRIPTION: Get user input for a Exponent Tag
  552. **
  553. **
  554. ** PARAMETERS: hDescListBox Handle to the Desc window
  555. ** hHexListBox Handle to the Hex window
  556. ** nEntity Not used
  557. **
  558. ** RETURNS:
  559. **
  560. *******************************************************************************/
  561. void GetExponentVal( HANDLE hDescListBox, int nEntity)
  562. {
  563. PITEM_INFO pItemInfo;
  564. char szBuff[128];
  565. LRESULT Index,rc;
  566. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_EXPONENT),ghWnd , ExponentDlgProc);
  567. if( rc == TRUE )
  568. {
  569. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  570. {
  571. pItemInfo->bTag = UNIT_EXPONENT;
  572. pItemInfo->bTag |= 0x01; // 1 BYTE of param info
  573. pItemInfo->bParam[0] = gExpVal;
  574. wsprintf(szBuff,"UNIT_EXPONENT (%d)\t%02X %02X",gExpVal,pItemInfo->bTag,pItemInfo->bParam[0]);
  575. Index = AddString(hDescListBox,szBuff);
  576. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  577. gwReportDescLen += 2;
  578. }
  579. else
  580. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  581. }
  582. }
  583. /*******************************************************************************
  584. **
  585. ** void GetUnitsVal( HANDLE hDescListBox, int nEntity)
  586. **
  587. ** DESCRIPTION: Get user input for a Units Tag
  588. **
  589. **
  590. ** PARAMETERS: hDescListBox Handle to the Desc window
  591. ** hHexListBox Handle to the Hex window
  592. ** nEntity Not used
  593. **
  594. ** RETURNS:
  595. **
  596. *******************************************************************************/
  597. void GetUnitsVal( HANDLE hDescListBox, int nEntity)
  598. {
  599. PITEM_INFO pItemInfo;
  600. char szBuff[128];
  601. LRESULT Index,rc;
  602. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_UNIT),ghWnd , UnitDlgProc);
  603. if( rc == TRUE )
  604. {
  605. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  606. {
  607. pItemInfo->bTag = UNIT;
  608. pItemInfo->bTag |= 0x02; // 2 BYTE of param info
  609. pItemInfo->bParam[0] = LOBYTE(gUnitVal);
  610. pItemInfo->bParam[1] = HIBYTE(gUnitVal);
  611. wsprintf(szBuff,"UNIT (%d)\t%02X %02X %02X",gExpVal,pItemInfo->bTag,pItemInfo->bParam[0],
  612. pItemInfo->bParam[1] );
  613. Index = AddString(hDescListBox,szBuff);
  614. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  615. gwReportDescLen += 2;
  616. }
  617. else
  618. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  619. }
  620. }
  621. /*******************************************************************************
  622. **
  623. ** void GetPushVal( HANDLE hDescListBox, HANDLE hHexListBox int nEntity)
  624. **
  625. ** DESCRIPTION: Creates a ITEM_INFO struct, fills it with a tag value for
  626. ** PUSH, Send a textual representation to the Desc Window, and
  627. ** and a Hex representation to the Hex Window. Store the pointer
  628. ** to the structure in column 2 of the Hex Window.
  629. **
  630. ** PARAMETERS: hDescListBox Handle to the Desc window
  631. ** hHexListBox Handle to the Hex window
  632. ** nEntity Not used
  633. **
  634. **
  635. ** RETURNS:
  636. **
  637. *******************************************************************************/
  638. void GetPushVal( HANDLE hDescListBox, int nEntity)
  639. {
  640. PITEM_INFO pItemInfo;
  641. char szBuff[128];
  642. LRESULT Index,rc;
  643. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  644. {
  645. pItemInfo->bTag = PUSH;
  646. wsprintf(szBuff,"PUSH\t%02X",PUSH);
  647. Index = AddString(hDescListBox,szBuff);
  648. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  649. gwReportDescLen++;
  650. }
  651. else
  652. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  653. }
  654. /*******************************************************************************
  655. **
  656. ** void GetPopVal( HANDLE hDescListBox, int nEntity)
  657. **
  658. ** DESCRIPTION: Creates a ITEM_INFO struct, fills it with a tag value for
  659. ** POP, Send a textual representation to the Desc Window, and
  660. ** and a Hex representation to the Hex Window. Store the pointer
  661. ** to the structure in the ItemData for the item.
  662. **
  663. ** PARAMETERS: hDescListBox Handle to the Desc window
  664. ** hHexListBox Handle to the Hex window
  665. ** nEntity Not used
  666. **
  667. ** RETURNS:
  668. **
  669. *******************************************************************************/
  670. void GetPopVal( HANDLE hDescListBox, int Entity )
  671. {
  672. PITEM_INFO pItemInfo;
  673. char szBuff[128];
  674. LRESULT Index,rc;
  675. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  676. {
  677. pItemInfo->bTag = POP;
  678. wsprintf(szBuff,"POP\t%02X",POP);
  679. Index = AddString(hDescListBox,szBuff);
  680. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  681. gwReportDescLen++;
  682. }
  683. else
  684. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  685. }
  686. /*******************************************************************************
  687. **
  688. ** void GetSetDelimiterVal( HANDLE hDescListBox,int nEntity)
  689. **
  690. ** DESCRIPTION: Get user input for a SetDelimiter Tag
  691. **
  692. **
  693. ** PARAMETERS: hDescListBox Handle to the Desc window
  694. ** nEntity Not used
  695. **
  696. ** RETURNS:
  697. **
  698. *******************************************************************************/
  699. void GetSetDelimiterVal( HANDLE hDescListBox, int nEntity)
  700. {
  701. PITEM_INFO pItemInfo;
  702. char szBuff[128];
  703. LRESULT Index,rc;
  704. rc = DialogBox( ghInst,MAKEINTRESOURCE(IDD_SETDELIMITER),ghWnd , SetDelimiterDlgProc);
  705. if( rc == TRUE )
  706. {
  707. if( pItemInfo = (PITEM_INFO) GlobalAlloc(GPTR,sizeof(ITEM_INFO)) )
  708. {
  709. pItemInfo->bTag = SET_DELIMITER;
  710. pItemInfo->bTag |= 0x01; // SetDelimiter has 1 param
  711. pItemInfo->bParam[0] = gSetDelimiterVal;
  712. wsprintf(szBuff,"SET_DELIMITER (%s)\t%02X %02X",(pItemInfo->bParam[0]) ? "Close" : "Open",
  713. pItemInfo->bTag,pItemInfo->bParam[0]);
  714. Index = AddString(hDescListBox,szBuff);
  715. rc = SendMessage(hDescListBox,LB_SETITEMDATA,Index,(LPARAM) pItemInfo);
  716. gwReportDescLen += 2;
  717. }
  718. else
  719. MessageBox(NULL,"GlobalAlloc() Failed!","DT Error",MB_OK);
  720. }//end if(rc == TRUE)
  721. }
  722. /********************************************************************************
  723. ** D I A L O G B O X P R O C's **
  724. ********************************************************************************/
  725. /*******************************************************************************
  726. **
  727. ** BOOL APIENTRY SetDelimiterDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  728. **
  729. ** DESCRIPTION: Dialog box proc for SetDelimiter items
  730. **
  731. **
  732. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  733. **
  734. **
  735. ** RETURNS:
  736. **
  737. *******************************************************************************/
  738. BOOL CALLBACK SetDelimiterDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  739. {
  740. switch(msg)
  741. {
  742. case WM_INITDIALOG:
  743. gSetDelimiterVal = 0;
  744. SendMessage(GetDlgItem(hDlg,IDC_DELIMITOPEN),BM_SETCHECK,TRUE,0);
  745. return TRUE;
  746. case WM_COMMAND:
  747. switch( wParam )
  748. {
  749. case IDC_DELIMITOPEN:
  750. gSetDelimiterVal = 0x00;
  751. return TRUE;
  752. case IDC_DELIMITCLOSE:
  753. gSetDelimiterVal = 0x01;
  754. return TRUE;
  755. case IDOK:
  756. EndDialog(hDlg,TRUE);
  757. return TRUE;
  758. case IDCANCEL:
  759. EndDialog(hDlg,FALSE);
  760. return TRUE;
  761. }
  762. default:
  763. return FALSE;
  764. }
  765. return FALSE;
  766. }
  767. /*******************************************************************************
  768. **
  769. ** BOOL APIENTRY EditBoxDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  770. **
  771. ** DESCRIPTION: Dialog box proc for Edit box input
  772. **
  773. **
  774. **
  775. **
  776. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  777. **
  778. **
  779. ** RETURNS:
  780. **
  781. *******************************************************************************/
  782. #define MAX_INTEGER 12 //"-2147483648\0"
  783. #define MAX_HEX 9 // Number bits in a DWORD + \0
  784. int INT_MAX = 2147483647;
  785. int INT_MIN = -2147483647;
  786. BOOL CALLBACK EditBoxDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  787. {
  788. BOOL Status;
  789. static HWND hwndEdit;
  790. char szNumber[MAX_INTEGER];
  791. static int nBase = IDC_BASE10;
  792. static int nStringLen = MAX_INTEGER;
  793. switch(msg)
  794. {
  795. case WM_INITDIALOG:
  796. gEditVal = 0;
  797. hwndEdit = GetDlgItem(hDlg,IDC_EDIT1);
  798. SendDlgItemMessage(hDlg,nBase,BM_SETCHECK,TRUE,0);
  799. SetFocus(hwndEdit);
  800. return FALSE;
  801. case WM_COMMAND:
  802. switch( wParam )
  803. {
  804. case IDOK:
  805. Status = GetDlgItemText(hDlg,IDC_EDIT1,szNumber,nStringLen);
  806. if( Status <= nStringLen - 1 )
  807. {
  808. if( nBase == IDC_BASE10 )
  809. gEditVal = atoi(szNumber);
  810. else
  811. sscanf(szNumber,"%8x",&gEditVal);
  812. if( (gEditVal <= INT_MAX) && (gEditVal >= INT_MIN) )
  813. {
  814. EndDialog(hDlg,TRUE);
  815. return TRUE;
  816. }
  817. }
  818. SetFocus(hwndEdit);
  819. SendMessage(hwndEdit,EM_SETSEL,0,-1);
  820. return TRUE;
  821. case IDC_BASE10:
  822. nBase = IDC_BASE10;
  823. SetFocus(hwndEdit);
  824. nStringLen = MAX_INTEGER;
  825. return TRUE;
  826. case IDC_BASE16:
  827. nBase = IDC_BASE16;
  828. SetFocus(hwndEdit);
  829. nStringLen = MAX_HEX;
  830. return TRUE;
  831. case IDCANCEL:
  832. EndDialog(hDlg,FALSE);
  833. return TRUE;
  834. }
  835. default:
  836. return FALSE;
  837. }
  838. return FALSE;
  839. }
  840. /*******************************************************************************
  841. **
  842. ** BOOL APIENTRY CollectionDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  843. **
  844. ** DESCRIPTION: Dialog box proc for Collection entities
  845. **
  846. **
  847. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  848. **
  849. **
  850. ** RETURNS:
  851. **
  852. *******************************************************************************/
  853. BOOL CALLBACK CollectionDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  854. {
  855. switch(msg)
  856. {
  857. case WM_INITDIALOG:
  858. gCollectionVal = 0;
  859. SendMessage(GetDlgItem(hDlg,IDC_LINKED),BM_SETCHECK,TRUE,0);
  860. return TRUE;
  861. case WM_COMMAND:
  862. switch( wParam )
  863. {
  864. case IDC_LINKED:
  865. gCollectionVal = 0x00;
  866. return TRUE;
  867. case IDC_APPLICATION:
  868. gCollectionVal = 0x01;
  869. return TRUE;
  870. case IDC_DATALINK:
  871. gCollectionVal = 0x02;
  872. return TRUE;
  873. case IDOK:
  874. EndDialog(hDlg,TRUE);
  875. return TRUE;
  876. case IDCANCEL:
  877. EndDialog(hDlg,FALSE);
  878. return TRUE;
  879. }
  880. default:
  881. return FALSE;
  882. }
  883. return FALSE;
  884. }
  885. /*******************************************************************************
  886. **
  887. ** BOOL CALLBACK InputDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  888. **
  889. ** DESCRIPTION: Dialog box proc for Input entities
  890. **
  891. **
  892. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  893. **
  894. **
  895. ** RETURNS:
  896. **
  897. *******************************************************************************/
  898. /****
  899. BOOL CALLBACK InputDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  900. {
  901. switch(msg)
  902. {
  903. case WM_INITDIALOG:
  904. gInputVal = 0;
  905. SendMessage(GetDlgItem(hDlg,IDC_DATA), BM_SETCHECK,TRUE,0);
  906. SendMessage(GetDlgItem(hDlg,IDC_ARRAY), BM_SETCHECK,TRUE,0);
  907. SendMessage(GetDlgItem(hDlg,IDC_ABSOLUTE), BM_SETCHECK,TRUE,0);
  908. SendMessage(GetDlgItem(hDlg,IDC_NOWRAP), BM_SETCHECK,TRUE,0);
  909. SendMessage(GetDlgItem(hDlg,IDC_LINEAR), BM_SETCHECK,TRUE,0);
  910. SendMessage(GetDlgItem(hDlg,IDC_PREFSTATE), BM_SETCHECK,TRUE,0);
  911. SendMessage(GetDlgItem(hDlg,IDC_NULL), BM_SETCHECK,TRUE,0);
  912. SendMessage(GetDlgItem(hDlg,IDC_NONVOL), BM_SETCHECK,TRUE,0);
  913. SendMessage(GetDlgItem(hDlg,IDC_BITFIELD), BM_SETCHECK,TRUE,0);
  914. return TRUE;
  915. case WM_COMMAND:
  916. switch( LOWORD(wParam) )
  917. {
  918. // These represent bit values of 0, so clear
  919. // the bit which corresponds to the number in wParam
  920. // after subtracting 0x1000
  921. case IDC_DATA:
  922. case IDC_ARRAY:
  923. case IDC_ABSOLUTE:
  924. case IDC_NOWRAP:
  925. case IDC_LINEAR:
  926. case IDC_PREFSTATE:
  927. case IDC_NULL:
  928. case IDC_NONVOL:
  929. case IDC_BITFIELD:
  930. gInputVal &= (wParam - 0x1000);
  931. return TRUE;
  932. // These represent bit values of 1, so set
  933. // the bit which corresponds to the number in wParam
  934. // after subtracting 0x1000
  935. case IDC_CONST:
  936. case IDC_VARIABLE:
  937. case IDC_RELATIVE:
  938. case IDC_WRAP:
  939. case IDC_NONLINEAR:
  940. case IDC_NOPREF:
  941. case IDC_NONULL:
  942. case IDC_BUFFERED:
  943. gInputVal |= (wParam - 0x1000);
  944. return TRUE;
  945. case IDOK:
  946. EndDialog(hDlg,TRUE);
  947. return TRUE;
  948. case IDCANCEL:
  949. EndDialog(hDlg,FALSE);
  950. return TRUE;
  951. }
  952. default:
  953. return FALSE;
  954. }
  955. return FALSE;
  956. }
  957. ***/
  958. /*******************************************************************************
  959. **
  960. ** BOOL CALLBACK MainItemDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  961. **
  962. ** DESCRIPTION: Dialog box proc for Input entities
  963. **
  964. **
  965. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  966. **
  967. **
  968. ** RETURNS:
  969. **
  970. *******************************************************************************/
  971. BOOL CALLBACK MainItemDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  972. {
  973. switch(msg)
  974. {
  975. case WM_INITDIALOG:
  976. gMainItemVal = 0;
  977. SendMessage(GetDlgItem(hDlg,IDC_DATA), BM_SETCHECK,TRUE,0);
  978. SendMessage(GetDlgItem(hDlg,IDC_ARRAY), BM_SETCHECK,TRUE,0);
  979. SendMessage(GetDlgItem(hDlg,IDC_ABSOLUTE), BM_SETCHECK,TRUE,0);
  980. SendMessage(GetDlgItem(hDlg,IDC_NOWRAP), BM_SETCHECK,TRUE,0);
  981. SendMessage(GetDlgItem(hDlg,IDC_LINEAR), BM_SETCHECK,TRUE,0);
  982. SendMessage(GetDlgItem(hDlg,IDC_PREFSTATE), BM_SETCHECK,TRUE,0);
  983. SendMessage(GetDlgItem(hDlg,IDC_NULL), BM_SETCHECK,TRUE,0);
  984. SendMessage(GetDlgItem(hDlg,IDC_NONVOL), BM_SETCHECK,TRUE,0);
  985. SendMessage(GetDlgItem(hDlg,IDC_BITFIELD), BM_SETCHECK,TRUE,0);
  986. return TRUE;
  987. case WM_COMMAND:
  988. switch( LOWORD(wParam) )
  989. {
  990. // These represent bit values of 0, so clear
  991. // the bit which corresponds to the number in wParam
  992. // after subtracting 0x1000
  993. case IDC_DATA:
  994. case IDC_ARRAY:
  995. case IDC_ABSOLUTE:
  996. case IDC_NOWRAP:
  997. case IDC_LINEAR:
  998. case IDC_PREFSTATE:
  999. case IDC_NULL:
  1000. case IDC_NONVOL:
  1001. case IDC_BITFIELD:
  1002. gMainItemVal &= (wParam - 0x1000);
  1003. return TRUE;
  1004. // These represent bit values of 1, so set
  1005. // the bit which corresponds to the number in wParam
  1006. // after subtracting 0x1000
  1007. case IDC_CONST:
  1008. case IDC_VARIABLE:
  1009. case IDC_RELATIVE:
  1010. case IDC_WRAP:
  1011. case IDC_NONLINEAR:
  1012. case IDC_NOPREF:
  1013. case IDC_NONULL:
  1014. case IDC_VOL:
  1015. case IDC_BUFFERED:
  1016. gMainItemVal |= (wParam - 0x1000);
  1017. return TRUE;
  1018. case IDOK:
  1019. EndDialog(hDlg,TRUE);
  1020. return TRUE;
  1021. case IDCANCEL:
  1022. EndDialog(hDlg,FALSE);
  1023. return TRUE;
  1024. }
  1025. default:
  1026. return FALSE;
  1027. }
  1028. return FALSE;
  1029. }
  1030. /*******************************************************************************
  1031. **
  1032. ** BOOL CALLBACK UnitDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  1033. **
  1034. ** DESCRIPTION: Dialog box proc for Unit entities
  1035. **
  1036. **
  1037. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  1038. **
  1039. **
  1040. ** RETURNS:
  1041. **
  1042. *******************************************************************************/
  1043. BOOL CALLBACK UnitDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  1044. {
  1045. switch(msg)
  1046. {
  1047. case WM_INITDIALOG:
  1048. gUnitVal = 0;
  1049. SendMessage(GetDlgItem(hDlg,IDC_SYSNONE),BM_SETCHECK,TRUE,0);
  1050. SendMessage(GetDlgItem(hDlg,IDC_ZERO1),BM_SETCHECK,TRUE,0);
  1051. SendMessage(GetDlgItem(hDlg,IDC_ZERO2),BM_SETCHECK,TRUE,0);
  1052. SendMessage(GetDlgItem(hDlg,IDC_ZERO3),BM_SETCHECK,TRUE,0);
  1053. return TRUE;
  1054. case WM_COMMAND:
  1055. switch( LOWORD(wParam) )
  1056. {
  1057. case IDC_SYSNONE:
  1058. case IDC_SILIN:
  1059. case IDC_SIROT:
  1060. case IDC_ENGLIN:
  1061. case IDC_ENGROT:
  1062. case IDC_ELECTRIC:
  1063. case IDC_TEMP:
  1064. case IDC_LUMINOSITY:
  1065. case IDC_TBD:
  1066. case IDC_VENDOR:
  1067. case IDC_TBD1:
  1068. case IDC_TBD2:
  1069. case IDC_TBD3:
  1070. case IDC_TBD4:
  1071. case IDC_TBD5:
  1072. case IDC_TBD6:
  1073. gUnitVal |= (LOWORD(wParam) - IDC_SYSNONE);
  1074. return TRUE;
  1075. // Length Nibble
  1076. case IDC_ZERO1:
  1077. case IDC_ONE1:
  1078. case IDC_TWO1:
  1079. case IDC_THREE1:
  1080. case IDC_FOUR1:
  1081. case IDC_FIVE1:
  1082. case IDC_SIX1:
  1083. case IDC_SEVEN1:
  1084. case IDC_NEGEIGHT1:
  1085. case IDC_NEGSEVEN1:
  1086. case IDC_NEGSIX1:
  1087. case IDC_NEGFIVE1:
  1088. case IDC_NEGFOUR1:
  1089. case IDC_NEGTHREE1:
  1090. case IDC_NEGTWO1:
  1091. case IDC_NEGONE1:
  1092. gUnitVal |= ((LOWORD(wParam) - IDC_ZERO3) << 4);
  1093. return TRUE;
  1094. // Mass - Nibble2
  1095. case IDC_ZERO2:
  1096. case IDC_ONE2:
  1097. case IDC_TWO2:
  1098. case IDC_THREE2:
  1099. case IDC_FOUR2:
  1100. case IDC_FIVE2:
  1101. case IDC_SIX2:
  1102. case IDC_SEVEN2:
  1103. case IDC_NEGEIGHT2:
  1104. case IDC_NEGSEVEN2:
  1105. case IDC_NEGSIX2:
  1106. case IDC_NEGFIVE2:
  1107. case IDC_NEGFOUR2:
  1108. case IDC_NEGTHREE2:
  1109. case IDC_NEGTWO2:
  1110. case IDC_NEGONE2:
  1111. gUnitVal |= ((LOWORD(wParam) - IDC_ZERO3) << 8);
  1112. return TRUE;
  1113. // Time - Nibble3
  1114. case IDC_ZERO3:
  1115. case IDC_ONE3:
  1116. case IDC_TWO3:
  1117. case IDC_THREE3:
  1118. case IDC_FOUR3:
  1119. case IDC_FIVE3:
  1120. case IDC_SIX3:
  1121. case IDC_SEVEN3:
  1122. case IDC_NEGEIGHT3:
  1123. case IDC_NEGSEVEN3:
  1124. case IDC_NEGSIX3:
  1125. case IDC_NEGFIVE3:
  1126. case IDC_NEGFOUR3:
  1127. case IDC_NEGTHREE3:
  1128. case IDC_NEGTWO3:
  1129. case IDC_NEGONE3:
  1130. gUnitVal |= ((LOWORD(wParam) - IDC_ZERO3) << 12);
  1131. return TRUE;
  1132. case IDOK:
  1133. EndDialog(hDlg,TRUE);
  1134. return TRUE;
  1135. case IDCANCEL:
  1136. EndDialog(hDlg,FALSE);
  1137. return TRUE;
  1138. }
  1139. default:
  1140. return FALSE;
  1141. }
  1142. return FALSE;
  1143. }
  1144. /*******************************************************************************
  1145. **
  1146. ** BOOL CALLBACK ExponentDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  1147. **
  1148. ** DESCRIPTION: Dialog box proc for Exponent entities
  1149. **
  1150. **
  1151. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  1152. **
  1153. **
  1154. ** RETURNS:
  1155. **
  1156. *******************************************************************************/
  1157. BOOL CALLBACK ExponentDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  1158. {
  1159. switch(msg)
  1160. {
  1161. case WM_INITDIALOG:
  1162. gExpVal = 0;
  1163. SendMessage(GetDlgItem(hDlg,IDC_ZERO),BM_SETCHECK,TRUE,0);
  1164. return TRUE;
  1165. case WM_COMMAND:
  1166. switch( LOWORD(wParam) )
  1167. {
  1168. //
  1169. // Exponent. Lower byte represents code
  1170. case IDC_ZERO:
  1171. case IDC_ONE:
  1172. case IDC_TWO:
  1173. case IDC_THREE:
  1174. case IDC_FOUR:
  1175. case IDC_FIVE:
  1176. case IDC_SIX:
  1177. case IDC_SEVEN:
  1178. case IDC_NEGEIGHT:
  1179. case IDC_NEGSEVEN:
  1180. case IDC_NEGSIX:
  1181. case IDC_NEGFIVE:
  1182. case IDC_NEGFOUR:
  1183. case IDC_NEGTHREE:
  1184. case IDC_NEGTWO:
  1185. case IDC_NEGONE:
  1186. gExpVal = (wParam - 0x4000);
  1187. return TRUE;
  1188. case IDOK:
  1189. EndDialog(hDlg,TRUE);
  1190. return TRUE;
  1191. case IDCANCEL:
  1192. EndDialog(hDlg,FALSE);
  1193. return TRUE;
  1194. }
  1195. default:
  1196. return FALSE;
  1197. }
  1198. return FALSE;
  1199. }
  1200. /*******************************************************************************
  1201. **
  1202. ** BOOL CALLBACK UsagePageDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARM lPram)
  1203. **
  1204. ** DESCRIPTION: Dialog box proc for UsagePage entities
  1205. **
  1206. **
  1207. ** PARAMETERS: Your standard Dialog box proc parms, plus....
  1208. **
  1209. **
  1210. ** RETURNS:
  1211. **
  1212. *******************************************************************************/
  1213. BOOL CALLBACK UsagePageDlgProc( HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
  1214. {
  1215. static HWND hwndListBox;
  1216. int i;
  1217. switch(msg)
  1218. {
  1219. case WM_INITDIALOG:
  1220. hwndListBox = GetDlgItem(hDlg,IDC_LIST1);
  1221. gUsagePageVal = 0;
  1222. for(i=0;i<MAX_USAGE_PAGES;i++)
  1223. SendMessage(hwndListBox,LB_ADDSTRING,0,(LPARAM)szUsagePage[i]);
  1224. SendMessage(hwndListBox,LB_SETCURSEL,0,0);
  1225. SetFocus(hwndListBox);
  1226. return TRUE;
  1227. case WM_COMMAND:
  1228. switch( LOWORD(wParam) )
  1229. {
  1230. case IDC_LIST1:
  1231. if( HIWORD(wParam) == LBN_DBLCLK )
  1232. {
  1233. gUsagePageVal = (BYTE) SendMessage(hwndListBox,LB_GETCURSEL,0,0);
  1234. EndDialog(hDlg,TRUE);
  1235. }
  1236. if( HIWORD(wParam) == LBN_SELCHANGE )
  1237. gUsagePageVal = (BYTE) SendMessage(hwndListBox,LB_GETCURSEL,0,0);
  1238. return TRUE;
  1239. case IDOK:
  1240. EndDialog(hDlg,TRUE);
  1241. return TRUE;
  1242. case IDCANCEL:
  1243. EndDialog(hDlg,FALSE);
  1244. return TRUE;
  1245. }
  1246. default:
  1247. return FALSE;
  1248. }
  1249. return FALSE;
  1250. }