Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1968 lines
62 KiB

  1. /******************************************************************************
  2. stillvue.cpp
  3. Simple test of WDM Still Image Class
  4. Copyright (C) Microsoft Corporation, 1997 - 1999
  5. All rights reserved
  6. Notes:
  7. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  8. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  9. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  10. PURPOSE.
  11. ******************************************************************************/
  12. #define INITGUID
  13. #include "stillvue.h"
  14. #include <dbt.h>
  15. #include <devguid.h>
  16. #include <pnpmgr.h>
  17. #include "stivar.h" // stillvue local includes
  18. //
  19. // defined in wsti.cpp
  20. //
  21. extern WCHAR szFriendlyName[];
  22. extern WCHAR szInternalName[];
  23. extern DWORD dwStiTotal;
  24. extern PSTI_DEVICE_INFORMATION pStiInfoPtr;
  25. /******************************************************************************
  26. BOOL CommandParse(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  27. Handle user menu commands.
  28. ******************************************************************************/
  29. BOOL CommandParse(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  30. {
  31. HRESULT hres = STI_OK;
  32. DWORD dwSize = 0,
  33. dwType = 0,
  34. dwPriority = STI_TRACE_ERROR,
  35. EscapeFunction = 0,
  36. dwNumberOfBytes = 0;
  37. WCHAR szMessage[] = L"Sti Compliance Test message";
  38. WCHAR szDevKey[LONGSTRING];
  39. char lpInData[LONGSTRING],
  40. lpOutData[LONGSTRING];
  41. int nReturn = 0; // generic return value
  42. BOOL bReturn;
  43. //
  44. // Set the InATest semaphore
  45. //
  46. nInATestSemaphore = 1;
  47. switch(wParam)
  48. {
  49. // IStillImage Interfaces
  50. case IDM_CREATE_INSTANCE:
  51. hres = StiCreateInstance(&bReturn);
  52. DisplayLogPassFail(bReturn);
  53. break;
  54. case IDM_GET_DEVLIST:
  55. hres = StiEnum(&bReturn);
  56. DisplayLogPassFail(bReturn);
  57. break;
  58. case IDM_CREATE_DEV:
  59. if (bAuto)
  60. hres = StiSelect(hWnd,AUTO,&bReturn);
  61. else
  62. hres = StiSelect(hWnd,MANUAL,&bReturn);
  63. DisplayLogPassFail(bReturn);
  64. break;
  65. case IDM_GET_DEVINFO:
  66. hres = StiGetDeviceInfo(szInternalName,&bReturn);
  67. DisplayLogPassFail(bReturn);
  68. break;
  69. case IDM_GET_DEVVAL:
  70. hres = StiGetDeviceValue(szInternalName,
  71. STI_DEVICE_VALUE_TWAIN_NAME,(LPBYTE) lpInData,
  72. &dwType,DWORD(LONGSTRING),&bReturn);
  73. hres = StiGetDeviceValue(szInternalName,
  74. STI_DEVICE_VALUE_ISIS_NAME,(LPBYTE) lpInData,
  75. &dwType,DWORD(LONGSTRING),&bReturn);
  76. hres = StiGetDeviceValue(szInternalName,
  77. STI_DEVICE_VALUE_ICM_PROFILE,(LPBYTE) lpInData,
  78. &dwType,DWORD(LONGSTRING),&bReturn);
  79. DisplayLogPassFail(bReturn);
  80. break;
  81. case IDM_SET_DEVVAL:
  82. //
  83. // Store a dummy registry key and value
  84. //
  85. wcscpy(szDevKey,L"StiTestRegKey");
  86. strcpy(lpOutData,"This is a bland statement");
  87. dwType = REG_SZ;
  88. dwSize = strlen(lpOutData);
  89. //
  90. // set the value and then retrieve it
  91. //
  92. hres = StiSetDeviceValue(szInternalName,
  93. szDevKey,(LPBYTE) lpOutData,dwType,dwSize,&bReturn);
  94. hres = StiGetDeviceValue(szInternalName,
  95. szDevKey,(LPBYTE) lpOutData,&dwType,DWORD(LONGSTRING),&bReturn);
  96. DisplayLogPassFail(bReturn);
  97. break;
  98. case IDM_REGISTER_LAUNCH:
  99. hres = StiRegister(hWnd,hThisInstance,ON,&bReturn);
  100. DisplayLogPassFail(bReturn);
  101. break;
  102. case IDM_UNREGISTER_LAUNCH:
  103. hres = StiRegister(hWnd,hThisInstance,OFF,&bReturn);
  104. DisplayLogPassFail(bReturn);
  105. break;
  106. case IDM_ENABLE_HWNOTIF:
  107. //
  108. // Change Hw notification to inverse
  109. //
  110. nHWState = 0;
  111. hres = StiEnableHwNotification(szInternalName,&nHWState,&bReturn);
  112. DisplayLogPassFail(bReturn);
  113. if (nHWState == 0)
  114. nHWState = 1;
  115. else
  116. nHWState = 0;
  117. hres = StiEnableHwNotification(szInternalName,&nHWState,&bReturn);
  118. DisplayLogPassFail(bReturn);
  119. break;
  120. case IDM_GET_HWNOTIF:
  121. //
  122. // Look at the current HW notification state
  123. //
  124. nHWState = PEEK;
  125. hres = StiEnableHwNotification(szInternalName,&nHWState,&bReturn);
  126. DisplayLogPassFail(bReturn);
  127. break;
  128. case IDM_REFRESH_DEVBUS:
  129. hres = StiRefresh(szInternalName,&bReturn);
  130. DisplayLogPassFail(bReturn);
  131. break;
  132. case IDM_WRITE_ERRORLOG:
  133. for (;lParam >= 1;lParam--)
  134. hres = StiWriteErrLog(dwPriority,szMessage,&bReturn);
  135. DisplayLogPassFail(bReturn);
  136. break;
  137. case IDM_IMAGE_RELEASE:
  138. hres = StiImageRelease(&bReturn);
  139. DisplayLogPassFail(bReturn);
  140. break;
  141. // IStillImage_Device Interfaces
  142. case IDM_GET_STATUS_A:
  143. nReturn = STI_DEVSTATUS_ONLINE_STATE;
  144. hres = StiGetStatus(nReturn,&bReturn);
  145. DisplayLogPassFail(bReturn);
  146. break;
  147. case IDM_GET_STATUS_B:
  148. nReturn = STI_DEVSTATUS_EVENTS_STATE;
  149. hres = StiGetStatus(nReturn,&bReturn);
  150. DisplayLogPassFail(bReturn);
  151. break;
  152. case IDM_GET_STATUS_C:
  153. nReturn = STI_DEVSTATUS_ONLINE_STATE | STI_DEVSTATUS_EVENTS_STATE;
  154. hres = StiGetStatus(nReturn,&bReturn);
  155. DisplayLogPassFail(bReturn);
  156. break;
  157. case IDM_GET_CAPS:
  158. hres = StiGetCaps(&bReturn);
  159. DisplayLogPassFail(bReturn);
  160. break;
  161. case IDM_DEVICERESET:
  162. hres = StiReset(&bReturn);
  163. DisplayLogPassFail(bReturn);
  164. break;
  165. case IDM_DIAGNOSTIC:
  166. hres = StiDiagnostic(&bReturn);
  167. DisplayLogPassFail(bReturn);
  168. break;
  169. case IDM_GET_LASTERRINFO:
  170. hres = StiGetLastErrorInfo(&bReturn);
  171. DisplayLogPassFail(bReturn);
  172. DisplayOutput("");
  173. break;
  174. case IDM_SUBSCRIBE:
  175. hres = StiSubscribe(&bReturn);
  176. DisplayLogPassFail(bReturn);
  177. break;
  178. case IDM_UNSUBSCRIBE:
  179. nUnSubscribe = 0;
  180. DisplayOutput("");
  181. break;
  182. case IDM_ESCAPE_A:
  183. //
  184. // Set up the Escape command parameters
  185. //
  186. EscapeFunction = 0;
  187. strcpy(lpInData,"This is a bland statement");
  188. hres = StiEscape(EscapeFunction,&lpInData[0],&bReturn);
  189. DisplayLogPassFail(bReturn);
  190. break;
  191. case IDM_RAWREADDATA_A:
  192. //
  193. // Set up the RawReadData command parameters
  194. //
  195. ZeroMemory(lpInData,LONGSTRING);
  196. dwNumberOfBytes = 16;
  197. hres = StiRawReadData(lpInData,&dwNumberOfBytes,&bReturn);
  198. DisplayLogPassFail(bReturn);
  199. break;
  200. case IDM_RAWWRITEDATA_A:
  201. //
  202. // Set up the RawReadData command parameters
  203. //
  204. strcpy(lpOutData,"The eagle flies high");
  205. dwNumberOfBytes = strlen(lpOutData);
  206. hres = StiRawWriteData(lpOutData,dwNumberOfBytes,&bReturn);
  207. DisplayLogPassFail(bReturn);
  208. break;
  209. case IDM_RAWREADCOMMAND_A:
  210. //
  211. // Set up the RawReadCommand command parameters
  212. //
  213. ZeroMemory(lpInData,LONGSTRING);
  214. dwNumberOfBytes = 16;
  215. hres = StiRawReadCommand(lpInData,&dwNumberOfBytes,&bReturn);
  216. DisplayLogPassFail(bReturn);
  217. break;
  218. case IDM_RAWWRITECOMMAND_A:
  219. //
  220. // Set up the RawWriteCommand command parameters
  221. //
  222. strcpy(lpOutData,"Jack and Jill went up the hill");
  223. dwNumberOfBytes = strlen(lpOutData);
  224. hres = StiRawWriteCommand(lpOutData,dwNumberOfBytes,&bReturn);
  225. DisplayLogPassFail(bReturn);
  226. break;
  227. case IDM_DEVICE_RELEASE:
  228. hres = StiDeviceRelease(&bReturn);
  229. DisplayLogPassFail(bReturn);
  230. break;
  231. case IDM_NEXT_DEVICE:
  232. hres = NextStiDevice();
  233. DisplayLogPassFail(bReturn);
  234. break;
  235. case IDM_LAMPON:
  236. StiLamp(ON);
  237. break;
  238. case IDM_LAMPOFF:
  239. StiLamp(OFF);
  240. break;
  241. case IDM_SCAN:
  242. hres = StiScan(hWnd);
  243. break;
  244. case IDM_SHOWDIB:
  245. hres = DisplayScanDIB(hWnd);
  246. break;
  247. case IDM_COMPLIANCE:
  248. //
  249. // assign a test suite and start the automated test timer
  250. //
  251. pSuite = nComplianceSuite;
  252. nMaxCount = 3;
  253. nTimeScan = 10;
  254. nTimeNext = 1;
  255. bAuto = StartAutoTimer(hWnd);
  256. break;
  257. case IDM_SHIPCRIT:
  258. //
  259. // assign a test suite and start the automated test timer
  260. //
  261. pSuite = nShipcritSuite;
  262. nMaxCount = 200;
  263. nTimeScan = 10;
  264. nTimeNext = 1;
  265. bAuto = StartAutoTimer(hWnd);
  266. break;
  267. case IDM_PAUSE:
  268. // toggle pausing automation (if running) on/off
  269. if (! nPause) {
  270. DisplayOutput("..pausing automated test..");
  271. nPause = 1;
  272. }
  273. else {
  274. DisplayOutput("Resuming automated test");
  275. nPause = 0;
  276. }
  277. break;
  278. case IDM_AUTO:
  279. // toggle the automation on/off
  280. if (bAuto) {
  281. // stop the auto timer and the stress tests
  282. KillTimer(hWnd,TIMER_ONE);
  283. bAuto = FALSE;
  284. EnableMenuItem(hMenu, IDM_PAUSE, MF_DISABLED);
  285. DisplayOutput("Ending the tests");
  286. }
  287. else {
  288. // start the auto timer and the stress tests
  289. LoadString(hThisInstance,IDS_APPNAME,pszStr1,MEDSTRING);
  290. if (! SetTimer(hWnd,TIMER_ONE,nTimeNext * nTimeMultiplier,NULL))
  291. ErrorMsg((HWND) NULL,"Too many clocks or timers!",pszStr1,TRUE);
  292. else {
  293. bAuto = TRUE;
  294. EnableMenuItem(hMenu, IDM_PAUSE, MF_ENABLED);
  295. DisplayOutput("Starting the Sti Compliance tests");
  296. pSuite = nComplianceSuite;
  297. //
  298. // initialize NT Logging
  299. //
  300. NTLogInit();
  301. }
  302. }
  303. break;
  304. case IDM_SETTINGS:
  305. bReturn = fDialog(IDD_SETTINGS, hWnd, (FARPROC) Settings);
  306. // implement the settings if user pressed OK
  307. if (bReturn != FALSE)
  308. {
  309. if (nTTNext != nTimeNext) {
  310. nTimeNext = nTTNext;
  311. DisplayOutput("Test interval changed to %d seconds",nTimeNext);
  312. }
  313. if (nTTScan != nTimeScan) {
  314. nTimeScan = nTTScan;
  315. DisplayOutput("Scan interval changed to %d seconds",
  316. nTimeScan * nTimeNext);
  317. }
  318. if (nTTMax != nMaxCount) {
  319. nMaxCount = nTTMax;
  320. DisplayOutput("Test loops changed to %d (0 is forever)",
  321. nMaxCount);
  322. }
  323. }
  324. break;
  325. case IDM_HELP:
  326. Help();
  327. break;
  328. default:
  329. break;
  330. }
  331. //
  332. // Clear the InATest semaphore
  333. //
  334. nInATestSemaphore = 0;
  335. // always return 0
  336. return 0;
  337. }
  338. /******************************************************************************
  339. BOOL TimerParse(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  340. Each timer tick, decide whether to run the next test, repeat a prior test,
  341. end testing, or shut everything down.
  342. ******************************************************************************/
  343. BOOL TimerParse(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  344. {
  345. HRESULT hres = STI_OK; // generic Sti return value
  346. int nReturn = 0, // generic return value
  347. *pTest; // pointer to the test suite to run
  348. BOOL bResume = TRUE, // reset timer flag
  349. bReturn = TRUE; // dialog box return value
  350. static int nDeviceNumber = 1; // current device
  351. static int nCountdown = nTimeScan; // WM_TIMER ticks until next scan
  352. static DWORD dwOut = 0;
  353. //
  354. // Don't start a test if paused or running a test currently.
  355. //
  356. //
  357. if ((nInTimerSemaphore)||(nInATestSemaphore)||(nPause))
  358. return 0;
  359. //
  360. // Suspend the timer while running this test.
  361. // Set Flag to reset timer
  362. // Set the nInTimerSemaphore
  363. // Set the current test ID
  364. //
  365. KillTimer(hWnd,TIMER_ONE);
  366. bResume = TRUE;
  367. nInTimerSemaphore = 1;
  368. nTestID = nNextTest;
  369. //
  370. // point to the next test in the current suite to run
  371. //
  372. pTest = pSuite + nNextTest;
  373. switch (*pTest)
  374. {
  375. case NONE:
  376. nNextTest++;
  377. break;
  378. case HELP:
  379. nNextTest++;
  380. break;
  381. case COMPLIANCE:
  382. //
  383. // initialize test structures
  384. //
  385. if (pdevRoot == NULL) {
  386. InitPrivateList(&pdevRoot,pSuite);
  387. pdevPtr = pdevRoot;
  388. }
  389. //
  390. // if this is COMPLIANCE test, ask user to confirm test
  391. //
  392. bResume = ComplianceDialog(hWnd);
  393. nNextTest++;
  394. break;
  395. case SHIPCRIT:
  396. //
  397. // initialize test structures
  398. //
  399. if (pdevRoot == NULL) {
  400. InitPrivateList(&pdevRoot,pSuite);
  401. pdevPtr = pdevRoot;
  402. }
  403. nNextTest++;
  404. break;
  405. case ERRORLOG:
  406. nNextTest++;
  407. break;
  408. case TEST:
  409. nNextTest++;
  410. break;
  411. case tBeginningOfTest:
  412. DisplayOutput("Begin Testing test, loop %d, device %d",nTestCount,nDeviceNumber);
  413. tlLog(hNTLog,TL_LOG,"Begin Testing test, loop %d, device %d",nTestCount,nDeviceNumber);
  414. nNextTest++;
  415. break;
  416. case tCreateInstance:
  417. DisplayOutput("CreateInstance test, loop %d, device %d",nTestCount,nDeviceNumber);
  418. tlLog(hNTLog,TL_LOG,"CreateInstance test, loop %d, device %d",nTestCount,nDeviceNumber);
  419. DisplayOutput("%S (%S) is being tested",
  420. pdevPtr->szLocalName,pdevPtr->szInternalName);
  421. tlLog(hNTLog,TL_LOG,"%S (%S) is being tested",
  422. pdevPtr->szLocalName,pdevPtr->szInternalName);
  423. DisplayOutput("");
  424. PostMessage(hWnd,WM_COMMAND,IDM_CREATE_INSTANCE,0);
  425. nNextTest++;
  426. break;
  427. case tGetDeviceList:
  428. DisplayOutput("GetDeviceList test, loop %d, device %d",nTestCount,nDeviceNumber);
  429. tlLog(hNTLog,TL_LOG,"GetDeviceList test, loop %d, device %d",nTestCount,nDeviceNumber);
  430. PostMessage(hWnd,WM_COMMAND,IDM_GET_DEVLIST,0);
  431. nNextTest++;
  432. break;
  433. case tCreateDevice:
  434. DisplayOutput("CreateDevice test (Device ONLINE), loop %d, device %d",nTestCount,nDeviceNumber);
  435. tlLog(hNTLog,TL_LOG,
  436. "CreateDevice test (Device ONLINE), loop %d, device %d",nTestCount,nDeviceNumber);
  437. //
  438. // Call Sti with device
  439. //
  440. nNameOnly = 0;
  441. PostMessage(hWnd,WM_COMMAND,IDM_CREATE_DEV,0);
  442. nNextTest++;
  443. break;
  444. case tSelectDeviceName:
  445. DisplayOutput("SelectDeviceName test (Device OFFLINE), "\
  446. "loop %d, device %d",nTestCount,nDeviceNumber);
  447. tlLog(hNTLog,TL_LOG,"SelectDeviceName test (Device OFFLINE),"\
  448. "loop %d, device %d",nTestCount,nDeviceNumber);
  449. //
  450. // Call Sti with device name only
  451. //
  452. nNameOnly = 1;
  453. PostMessage(hWnd,WM_COMMAND,IDM_CREATE_DEV,0);
  454. nNextTest++;
  455. break;
  456. case tGetDeviceInfo:
  457. DisplayOutput("GetDeviceInfo test, loop %d, device %d",nTestCount,nDeviceNumber);
  458. tlLog(hNTLog,TL_LOG,"GetDeviceInfo test, loop %d, device %d",nTestCount,nDeviceNumber);
  459. PostMessage(hWnd,WM_COMMAND,IDM_GET_DEVINFO,0);
  460. nNextTest++;
  461. break;
  462. case tGetDeviceValue:
  463. DisplayOutput("GetDeviceValue test, loop %d, device %d",nTestCount,nDeviceNumber);
  464. tlLog(hNTLog,TL_LOG,"GetDeviceValue test, loop %d, device %d",nTestCount,nDeviceNumber);
  465. PostMessage(hWnd,WM_COMMAND,IDM_GET_DEVVAL,0);
  466. nNextTest++;
  467. break;
  468. case tSetDeviceValue:
  469. DisplayOutput("SetDeviceValue test, loop %d, device %d",nTestCount,nDeviceNumber);
  470. tlLog(hNTLog,TL_LOG,"SetDeviceValue test, loop %d, device %d",nTestCount,nDeviceNumber);
  471. PostMessage(hWnd,WM_COMMAND,IDM_SET_DEVVAL,0);
  472. nNextTest++;
  473. break;
  474. case tRegisterLaunchApplication:
  475. DisplayOutput("RegisterLaunchApplication test, loop %d, device %d",nTestCount,nDeviceNumber);
  476. tlLog(hNTLog,TL_LOG,"RegisterLaunchApplication test, loop %d, device %d",nTestCount,nDeviceNumber);
  477. PostMessage(hWnd,WM_COMMAND,IDM_REGISTER_LAUNCH,0);
  478. nNextTest++;
  479. break;
  480. case tUnRegisterLaunchApplication:
  481. DisplayOutput("UnRegisterLaunchApplication test, loop %d, device %d",nTestCount,nDeviceNumber);
  482. tlLog(hNTLog,TL_LOG,"UnRegisterLaunchApplication test, loop %d, device %d",nTestCount,nDeviceNumber);
  483. PostMessage(hWnd,WM_COMMAND,IDM_UNREGISTER_LAUNCH,0);
  484. nNextTest++;
  485. break;
  486. case tEnableHwNotifications:
  487. DisplayOutput("EnableHwNotifications test, loop %d, device %d",nTestCount,nDeviceNumber);
  488. tlLog(hNTLog,TL_LOG,"EnableHwNotifications test, "\
  489. "loop %d, device %d",nTestCount,nDeviceNumber);
  490. PostMessage(hWnd,WM_COMMAND,IDM_ENABLE_HWNOTIF,0);
  491. nNextTest++;
  492. break;
  493. case tGetHwNotificationState:
  494. DisplayOutput("GetHwNotificationState test, loop %d, device %d",nTestCount,nDeviceNumber);
  495. tlLog(hNTLog,TL_LOG,"GetHwNotificationState test, "\
  496. "loop %d, device %d",nTestCount,nDeviceNumber);
  497. PostMessage(hWnd,WM_COMMAND,IDM_GET_HWNOTIF,0);
  498. nNextTest++;
  499. break;
  500. case tWriteToErrorLog:
  501. DisplayOutput("WriteToErrorLog test, loop %d, device %d",nTestCount,nDeviceNumber);
  502. tlLog(hNTLog,TL_LOG,"WriteToErrorLog test, loop %d, device %d",nTestCount,nDeviceNumber);
  503. PostMessage(hWnd,WM_COMMAND,IDM_WRITE_ERRORLOG,0);
  504. nNextTest++;
  505. break;
  506. case tWriteToErrorLogBig:
  507. DisplayOutput("WriteToErrorLog test, Variation 1, "\
  508. "loop %d, device %d",nTestCount,nDeviceNumber);
  509. tlLog(hNTLog,TL_LOG,"WriteToErrorLog test, Variation 1, "\
  510. "loop %d, device %d",nTestCount,nDeviceNumber);
  511. PostMessage(hWnd,WM_COMMAND,IDM_WRITE_ERRORLOG,100);
  512. nNextTest++;
  513. break;
  514. case tGetStatusA:
  515. DisplayOutput("GetStatus (Online) test, loop %d, device %d",nTestCount,nDeviceNumber);
  516. tlLog(hNTLog,TL_LOG,"GetStatus test, loop %d, device %d",nTestCount,nDeviceNumber);
  517. PostMessage(hWnd,WM_COMMAND,IDM_GET_STATUS_A,0);
  518. nNextTest++;
  519. break;
  520. case tGetStatusB:
  521. DisplayOutput("GetStatus (Event) test, loop %d, device %d",nTestCount,nDeviceNumber);
  522. tlLog(hNTLog,TL_LOG,"GetStatus test, loop %d, device %d",nTestCount,nDeviceNumber);
  523. PostMessage(hWnd,WM_COMMAND,IDM_GET_STATUS_B,0);
  524. nNextTest++;
  525. break;
  526. case tGetStatusC:
  527. DisplayOutput("GetStatus (All) test, loop %d, device %d",nTestCount,nDeviceNumber);
  528. tlLog(hNTLog,TL_LOG,"GetStatus test, loop %d, device %d",nTestCount,nDeviceNumber);
  529. PostMessage(hWnd,WM_COMMAND,IDM_GET_STATUS_C,0);
  530. nNextTest++;
  531. break;
  532. case tGetCapabilities:
  533. DisplayOutput("GetCapabilities test, loop %d, device %d",nTestCount,nDeviceNumber);
  534. tlLog(hNTLog,TL_LOG,"GetCapabilities test, loop %d, device %d",nTestCount,nDeviceNumber);
  535. PostMessage(hWnd,WM_COMMAND,IDM_GET_CAPS,0);
  536. nNextTest++;
  537. break;
  538. case tDeviceReset:
  539. DisplayOutput("DeviceReset test, loop %d, device %d",nTestCount,nDeviceNumber);
  540. tlLog(hNTLog,TL_LOG,"DeviceReset test, loop %d, device %d",nTestCount,nDeviceNumber);
  541. PostMessage(hWnd,WM_COMMAND,IDM_DEVICERESET,0);
  542. nNextTest++;
  543. break;
  544. case tDiagnostic:
  545. DisplayOutput("Diagnostic test, loop %d, device %d",nTestCount,nDeviceNumber);
  546. tlLog(hNTLog,TL_LOG,"Diagnostic test, loop %d, device %d",nTestCount,nDeviceNumber);
  547. PostMessage(hWnd,WM_COMMAND,IDM_DIAGNOSTIC,0);
  548. nNextTest++;
  549. break;
  550. case tGetLastInfoError:
  551. DisplayOutput("GetLastInfoError test, loop %d, device %d",nTestCount,nDeviceNumber);
  552. tlLog(hNTLog,TL_LOG,"GetLastInfoError test, loop %d, device %d",nTestCount,nDeviceNumber);
  553. PostMessage(hWnd,WM_COMMAND,IDM_GET_LASTERRINFO,0);
  554. nNextTest++;
  555. break;
  556. case tSubscribe:
  557. DisplayOutput("Subscribe test, loop %d, device %d",nTestCount,nDeviceNumber);
  558. tlLog(hNTLog,TL_LOG,"Subscribe test, loop %d, device %d",nTestCount,nDeviceNumber);
  559. PostMessage(hWnd,WM_COMMAND,IDM_SUBSCRIBE,0);
  560. nNextTest++;
  561. break;
  562. case tUnSubscribe:
  563. DisplayOutput("UnSubscribe test, loop %d, device %d",nTestCount,nDeviceNumber);
  564. tlLog(hNTLog,TL_LOG,"UnSubscribe test, loop %d, device %d",nTestCount,nDeviceNumber);
  565. PostMessage(hWnd,WM_COMMAND,IDM_UNSUBSCRIBE,0);
  566. nNextTest++;
  567. break;
  568. case tEscapeA:
  569. DisplayOutput("Escape (variation A) test, loop %d, device %d",nTestCount,nDeviceNumber);
  570. tlLog(hNTLog,TL_LOG,"Escape test, loop %d, device %d",nTestCount,nDeviceNumber);
  571. PostMessage(hWnd,WM_COMMAND,IDM_ESCAPE_A,0);
  572. nNextTest++;
  573. break;
  574. case tRawReadDataA:
  575. DisplayOutput("RawReadData (variation A) test, loop %d, device %d",nTestCount,nDeviceNumber);
  576. tlLog(hNTLog,TL_LOG,"RawReadData test, loop %d, device %d",nTestCount,nDeviceNumber);
  577. PostMessage(hWnd,WM_COMMAND,IDM_RAWREADDATA_A,0);
  578. nNextTest++;
  579. break;
  580. case tRawWriteDataA:
  581. DisplayOutput("RawWriteData (variation A) test, loop %d, device %d",nTestCount,nDeviceNumber);
  582. tlLog(hNTLog,TL_LOG,"RawWriteData test, loop %d, device %d",nTestCount,nDeviceNumber);
  583. PostMessage(hWnd,WM_COMMAND,IDM_RAWWRITEDATA_A,0);
  584. nNextTest++;
  585. break;
  586. case tRawReadCommandA:
  587. DisplayOutput("RawReadCommand (variation A) test, loop %d, device %d",nTestCount,nDeviceNumber);
  588. tlLog(hNTLog,TL_LOG,"RawReadCommand test, loop %d, device %d",nTestCount,nDeviceNumber);
  589. PostMessage(hWnd,WM_COMMAND,IDM_RAWREADCOMMAND_A,0);
  590. nNextTest++;
  591. break;
  592. case tRawWriteCommandA:
  593. DisplayOutput("RawWriteCommand (variation A) test, loop %d, device %d",nTestCount,nDeviceNumber);
  594. tlLog(hNTLog,TL_LOG,"RawWriteCommand test, loop %d, device %d",nTestCount,nDeviceNumber);
  595. PostMessage(hWnd,WM_COMMAND,IDM_RAWWRITECOMMAND_A,0);
  596. nNextTest++;
  597. break;
  598. case tAcquire:
  599. if (! nICanScan) {
  600. nNextTest++;
  601. } else {
  602. if (nCountdown == nTimeScan) {
  603. nCountdown--;
  604. DisplayOutput("...countdown %d to acquire...",nCountdown);
  605. PostMessage(hWnd,WM_COMMAND,IDM_SCAN,0);
  606. }
  607. else {
  608. if (nCountdown == 0) {
  609. nNextTest++;
  610. nCountdown = nTimeScan;
  611. }
  612. else {
  613. nCountdown--;
  614. DisplayOutput("Acquire test, loop %d, device %d",nTestCount,nDeviceNumber);
  615. tlLog(hNTLog,TL_LOG,"Acquire test, loop %d, device %d",nTestCount,nDeviceNumber);
  616. PostMessage(hWnd,WM_COMMAND,IDM_SHOWDIB,0);
  617. }
  618. }
  619. }
  620. break;
  621. case tReleaseDevice:
  622. DisplayOutput("ReleaseDevice test, loop %d, device %d",nTestCount,nDeviceNumber);
  623. tlLog(hNTLog,TL_LOG,"ReleaseDevice test, loop %d, device %d",nTestCount,nDeviceNumber);
  624. PostMessage(hWnd,WM_COMMAND,IDM_DEVICE_RELEASE,0);
  625. nNextTest++;
  626. break;
  627. case tReleaseSti:
  628. DisplayOutput("ReleaseSti test, loop %d, device %d",nTestCount,nDeviceNumber);
  629. tlLog(hNTLog,TL_LOG,"ReleaseSti test, loop %d, device %d",nTestCount,nDeviceNumber);
  630. PostMessage(hWnd,WM_COMMAND,IDM_IMAGE_RELEASE,0);
  631. nNextTest++;
  632. break;
  633. case tHelp:
  634. PostMessage(hWnd,WM_COMMAND,IDM_HELP,0);
  635. nNextTest++;
  636. break;
  637. case tTest:
  638. DisplayOutput(" Line %d",dwOut++);
  639. nNextTest++;
  640. break;
  641. case tEndOfTest:
  642. //
  643. // Reached the end of test suite
  644. //
  645. DisplayOutput("test loop complete");
  646. tlLog(hNTLog,TL_LOG,"test loop complete");
  647. if (nICanScan) {
  648. DisplayOutput("-> %d loops (%d scans and %d errors) device %d",
  649. nTestCount,nScanCount,pdevPtr->nError,nDeviceNumber);
  650. tlLog(hNTLog,TL_LOG,"-> %d loops (%d scans and %d errors) device %d",
  651. nTestCount,nScanCount,pdevPtr->nError,nDeviceNumber);
  652. } else {
  653. DisplayOutput("-> %d loops (%d errors) device %d",
  654. nTestCount,pdevPtr->nError,nDeviceNumber);
  655. tlLog(hNTLog,TL_LOG,"-> %d loops (%d errors) device %d",
  656. nTestCount,pdevPtr->nError,nDeviceNumber);
  657. }
  658. //
  659. // Have we run requested number of tests per device?
  660. //
  661. if (((nTestCount >= nMaxCount) &&
  662. ((dwStiTotal == (DWORD) (nDeviceNumber)) || (dwStiTotal == 0)) &&
  663. (nMaxCount != 0))) {
  664. DisplayOutput("Requested number of test loops per device "\
  665. "reached");
  666. tlLog(hNTLog,TL_LOG,"Requested number of test loops per "\
  667. "device reached");
  668. //
  669. // shut off timer and turn off automation
  670. //
  671. KillTimer(hWnd,TIMER_ONE);
  672. bAuto = FALSE;
  673. bResume = FALSE;
  674. //
  675. // print the test summary for the devices
  676. //
  677. DisplayOutput("");
  678. tlLog(hNTLog,TL_LOG,"");
  679. if (pdevRoot == NULL) {
  680. DisplayOutput("No valid Still Imaging devices were found");
  681. tlLog(hNTLog,TL_LOG,"No valid Still Imaging devices were found");
  682. } else {
  683. PDEVLOG pD = pdevRoot;
  684. PERRECORD pR = NULL;
  685. BOOL bPF = FALSE;
  686. DisplayOutput("Testing results:");
  687. tlLog(hNTLog,TL_LOG,"Testing results:");
  688. do {
  689. DisplayOutput(" %S (%S)",pD->szLocalName,pD->szInternalName);
  690. tlLog(hNTLog,TL_LOG," %S (%S)",pD->szLocalName,
  691. pD->szInternalName);
  692. for (pR = pD->pRecord;pR->pNext != NULL;pR = pR->pNext) {
  693. if (pR->bFatal && pR->nCount) {
  694. DisplayOutput(" %s failures: %d",
  695. StrFromTable(pR->nTest,StSuiteStrings),
  696. pR->nCount);
  697. tlLog(hNTLog,TL_LOG," %s failures: %d",
  698. StrFromTable(pR->nTest,StSuiteStrings),
  699. pR->nCount);
  700. //
  701. // set the FAIL flag
  702. //
  703. bPF = TRUE;
  704. }
  705. }
  706. if (bPF == TRUE) {
  707. DisplayOutput("FAIL: This device has FAILED the "\
  708. "Still Imaging Compliance test!");
  709. tlLog(hNTLog,TL_LOG,"FAIL: This device has FAILED "\
  710. "the Still Imaging Compliance test!");
  711. } else {
  712. DisplayOutput("PASS: This device has PASSED the "\
  713. "Still Imaging Compliance test!");
  714. tlLog(hNTLog,TL_LOG,"PASS: This device has PASSED "\
  715. "the Still Imaging Compliance test!");
  716. }
  717. // cycle through all devices, BREAK at end of list
  718. if (pD->pNext) {
  719. pD = pD->pNext;
  720. DisplayOutput("");
  721. tlLog(hNTLog,TL_LOG,"");
  722. bPF = FALSE;
  723. } else {
  724. DisplayOutput("");
  725. break;
  726. }
  727. } while (TRUE);
  728. }
  729. //
  730. // free the private lists and close Sti subsystem
  731. //
  732. ClosePrivateList(&pdevRoot);
  733. StiClose(&bReturn);
  734. //
  735. // reset test counters
  736. //
  737. nDeviceNumber = 1;
  738. nNextTest = 0;
  739. nTestCount = 1;
  740. DisplayOutput("End of testing");
  741. tlLog(hNTLog,TL_LOG,"End of testing");
  742. DisplayOutput("");
  743. } else {
  744. //
  745. // Point to first test (past initialization) in list.
  746. //
  747. nNextTest = 2;
  748. //
  749. // select next device in device log
  750. // Note that this list isn't dynamic for PNP changes...
  751. //
  752. nDeviceNumber = NextStiDevice();
  753. //
  754. // increment test pass counter if we're at first device again
  755. //
  756. if ((++nDeviceNumber) == 1)
  757. nTestCount++;
  758. DisplayOutput("");
  759. }
  760. break;
  761. default:
  762. DisplayOutput("");
  763. DisplayOutput("Unimplemented test # %d",*pTest);
  764. DisplayOutput("");
  765. nNextTest++;
  766. break;
  767. }
  768. //
  769. // Resume the timer if the flag is set
  770. //
  771. if (bResume) {
  772. if (! SetTimer(hWnd,TIMER_ONE,nTimeNext * nTimeMultiplier,NULL)) {
  773. LoadString(hThisInstance,IDS_APPNAME,pszStr1,MEDSTRING);
  774. ErrorMsg((HWND) NULL,"Too many clocks or timers!",pszStr1,TRUE);
  775. }
  776. }
  777. //
  778. // Clear the nInTimerSemaphore
  779. //
  780. nInTimerSemaphore = 0;
  781. // always return 0
  782. return 0;
  783. }
  784. /******************************************************************************
  785. int EndTest(HWND hWnd,int nNumTest)
  786. After each test run cleanup.
  787. ******************************************************************************/
  788. int EndTest(HWND hWnd,int nNumTest)
  789. {
  790. int nReturn = 0; // generic return value
  791. BOOL bReturn; // generic return value
  792. // shut off timer
  793. KillTimer(hWnd,TIMER_ONE);
  794. // close any open still imaging devices
  795. StiClose(&bReturn);
  796. // save test stats if more than non-trivial number of tests run
  797. if (nTestCount >= 2)
  798. {
  799. LoadString(hThisInstance,IDS_PRIVINI,pszOut,LONGSTRING);
  800. LoadString(hThisInstance,IDS_PRIVSECTION,pszStr4,LONGSTRING);
  801. _itoa(nTestCount,pszStr2,10);
  802. WritePrivateProfileString(pszStr4,"Last count",pszStr2,pszOut);
  803. _itoa(nScanCount,pszStr2,10);
  804. WritePrivateProfileString(pszStr4,"Last scan",pszStr2,pszOut);
  805. _itoa(nError,pszStr2,10);
  806. WritePrivateProfileString(pszStr4,"Last error",pszStr2,pszOut);
  807. }
  808. DisplayOutput("Testing complete");
  809. DisplayOutput("This run was %d loops (%d scans and %d errors)",
  810. nTestCount,nScanCount,nError);
  811. // reset current line, errors
  812. // nError = nNextLine = 0;
  813. //
  814. // end NT Logging
  815. //
  816. NTLogEnd();
  817. return nReturn;
  818. }
  819. /******************************************************************************
  820. BOOL NTLogInit()
  821. Initialize NT logging
  822. ******************************************************************************/
  823. BOOL NTLogInit()
  824. {
  825. //
  826. // Create the log object. We are specifying that the file be refreshed,
  827. // and that logging be output for variations. The flags also specify that
  828. // only output at SEV2, WARN and PASS levels should be logged.
  829. //
  830. dwNTStyle = TLS_SEV2 | TLS_WARN | TLS_PASS | TLS_VARIATION | TLS_REFRESH |
  831. TLS_TEST;
  832. LoadString(hThisInstance,IDS_NTLOG,pszStr1,LONGSTRING);
  833. hNTLog = tlCreateLog(pszStr1,dwNTStyle);
  834. tlAddParticipant(hNTLog,NULL,0);
  835. return (TRUE);
  836. }
  837. /******************************************************************************
  838. BOOL NTLogEnd()
  839. Terminate NT logging
  840. ******************************************************************************/
  841. BOOL NTLogEnd()
  842. {
  843. tlRemoveParticipant(hNTLog);
  844. tlDestroyLog(hNTLog);
  845. return (TRUE);
  846. }
  847. /******************************************************************************
  848. void Help()
  849. Display help.
  850. ******************************************************************************/
  851. void Help()
  852. {
  853. DisplayOutput("Stillvue command line parameters");
  854. DisplayOutput("");
  855. DisplayOutput("Stillvue -COMPLIANCE");
  856. DisplayOutput(" WHQL external Sti Compliance test");
  857. DisplayOutput("Stillvue -SHIPCRIT");
  858. DisplayOutput(" Internal PSD Sti Compliance test");
  859. DisplayOutput("Stillvue -ERRORLOG");
  860. DisplayOutput(" Errorlog limits test");
  861. // DisplayOutput("Stillvue -EXIT");
  862. // DisplayOutput(" Application will Exit after test completes");
  863. DisplayOutput("Stillvue -NODIALOG");
  864. DisplayOutput(" Don't display opening dialog");
  865. DisplayOutput("Stillvue -HELP");
  866. DisplayOutput(" Display this help");
  867. DisplayOutput("");
  868. /*
  869. DisplayOutput("Stillvue /INF test.inf");
  870. DisplayOutput(" Read test.inf file");
  871. DisplayOutput("Stillvue /LOG test.log");
  872. DisplayOutput(" Write to test.log file");
  873. DisplayOutput("Stillvue /");
  874. DisplayOutput(" ");
  875. */
  876. }
  877. /******************************************************************************
  878. BOOL StartAutoTimer(HWND)
  879. Start the automated test timer
  880. Parameters
  881. Handle to app's window
  882. Return
  883. Return TRUE if successful, else FALSE
  884. ******************************************************************************/
  885. BOOL StartAutoTimer(HWND hWnd)
  886. {
  887. BOOL bAutoTimer = TRUE;
  888. // start the timer to run tests automatically
  889. LoadString(hThisInstance,IDS_APPNAME,pszStr1,MEDSTRING);
  890. if (! SetTimer(hWnd,TIMER_ONE,nTimeNext * nTimeMultiplier,NULL)) {
  891. ErrorMsg((HWND) NULL,"Too many clocks or timers!",pszStr1,TRUE);
  892. bAutoTimer = FALSE;
  893. } else {
  894. EnableMenuItem(hMenu, IDM_PAUSE, MF_ENABLED);
  895. DisplayOutput("Starting the Automated tests");
  896. }
  897. return (bAutoTimer);
  898. }
  899. /******************************************************************************
  900. BOOL ComplianceDialog(HWND)
  901. Call the Compliance test confirmation dialog
  902. Parameters
  903. Handle to app's window
  904. Return
  905. Return TRUE if user pressed OK, else FALSE
  906. ******************************************************************************/
  907. BOOL ComplianceDialog(HWND hWnd)
  908. {
  909. BOOL bReturn = FALSE;
  910. if ((pSuite[0] == COMPLIANCE)&&(bCompDiag == TRUE)) {
  911. bReturn = fDialog(IDD_COMPLIANCE, hWnd, (FARPROC) Compliance);
  912. //
  913. // implement the settings if user pressed OK
  914. //
  915. if (bReturn == FALSE)
  916. {
  917. //
  918. // shut off timer and turn off automation
  919. //
  920. KillTimer(hWnd,TIMER_ONE);
  921. bAuto = FALSE;
  922. //
  923. // free the private lists
  924. //
  925. ClosePrivateList(&pdevRoot);
  926. DisplayOutput("Testing cancelled at user request");
  927. tlLog(hNTLog,TL_LOG,"Testing cancelled at user request");
  928. } else {
  929. DisplayOutput("Testing starting at user request");
  930. tlLog(hNTLog,TL_LOG,"Testing starting at user request");
  931. }
  932. }
  933. return (bReturn);
  934. }
  935. /******************************************************************************
  936. BOOL FAR PASCAL Compliance(HWND,UINT,WPARAM,LPARAM)
  937. OK the Compliance test dialog
  938. Parameters:
  939. The usual dialog box parameters.
  940. Return:
  941. Result of the call.
  942. ******************************************************************************/
  943. BOOL FAR PASCAL Compliance(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  944. {
  945. PDEVLOG pPtr = pdevRoot;
  946. int iIndex = 0;
  947. switch (msg) {
  948. case WM_INITDIALOG:
  949. //
  950. // fill dialog with Sti Device Internal Names
  951. //
  952. if (pPtr == NULL) {
  953. //
  954. // could not find any devices
  955. //
  956. wsprintf(pszStr1,"%s","No Sti devices found!");
  957. iIndex = SendDlgItemMessage(hDlg,IDC_COMPLIANCE_DEV_NAME,
  958. LB_ADDSTRING,0,(LPARAM) (LPCTSTR) pszStr1);
  959. } else {
  960. for (;pPtr->szLocalName;) {
  961. //
  962. // convert UNICODE string to ANSI
  963. //
  964. wsprintf(pszStr1,"%ls",pPtr->szLocalName);
  965. iIndex = SendDlgItemMessage(hDlg,IDC_COMPLIANCE_DEV_NAME,
  966. LB_ADDSTRING,0,(LPARAM) (LPCTSTR) pszStr1);
  967. if (pPtr->pNext)
  968. pPtr = pPtr->pNext;
  969. else
  970. break;
  971. }
  972. }
  973. return TRUE;
  974. case WM_COMMAND:
  975. switch (wParam) {
  976. case IDOK:
  977. EndDialog(hDlg, TRUE);
  978. return TRUE;
  979. case IDCANCEL:
  980. EndDialog(hDlg, FALSE);
  981. return TRUE;
  982. }
  983. }
  984. return FALSE;
  985. }
  986. /******************************************************************************
  987. BOOL FAR PASCAL Settings(HWND,UINT,WPARAM,LPARAM)
  988. Miscellaneous settings dialog
  989. Parameters:
  990. The usual dialog box parameters.
  991. Return:
  992. Result of the call.
  993. ******************************************************************************/
  994. BOOL FAR PASCAL Settings(HWND hDlg,UINT msg,WPARAM wParam,LPARAM lParam)
  995. {
  996. int iIndex;
  997. int iMC[] = { 0,1,10,100,200,300,-1 };
  998. int iTN[] = { 1,2,5,10,20,30,-1 };
  999. int iTS[] = { 10,20,30,60,120,-1 };
  1000. switch (msg) {
  1001. case WM_INITDIALOG:
  1002. //
  1003. // fill the comboboxes
  1004. //
  1005. for (iIndex = 0;iMC[iIndex] != -1;iIndex++) {
  1006. _itoa(iMC[iIndex],pszStr1,10);
  1007. SendDlgItemMessage(hDlg,IDC_MAX_SCAN,
  1008. CB_ADDSTRING,0,(LPARAM) (LPCTSTR) pszStr1);
  1009. }
  1010. for (iIndex = 0;iTN[iIndex] != -1;iIndex++) {
  1011. _itoa(iTN[iIndex],pszStr1,10);
  1012. SendDlgItemMessage(hDlg,IDC_AUTO_SECONDS,
  1013. CB_ADDSTRING,0,(LPARAM) (LPCTSTR) pszStr1);
  1014. }
  1015. for (iIndex = 0;iTS[iIndex] != -1;iIndex++) {
  1016. _itoa(iTS[iIndex],pszStr1,10);
  1017. SendDlgItemMessage(hDlg,IDC_SCAN_SECONDS,
  1018. CB_ADDSTRING,0,(LPARAM) (LPCTSTR) pszStr1);
  1019. }
  1020. //
  1021. // set the combobox to the current setttings
  1022. //
  1023. for (iIndex = 0;iMC[iIndex] != -1;iIndex++) {
  1024. if (nMaxCount == iMC[iIndex])
  1025. break;
  1026. }
  1027. SendDlgItemMessage(hDlg,IDC_MAX_SCAN,CB_SETCURSEL,iIndex,0);
  1028. for (iIndex = 0;iTN[iIndex] != -1;iIndex++) {
  1029. if (nTimeNext == iTN[iIndex])
  1030. break;
  1031. }
  1032. SendDlgItemMessage(hDlg,IDC_AUTO_SECONDS,CB_SETCURSEL,iIndex,0);
  1033. for (iIndex = 0;iTS[iIndex] != -1;iIndex++) {
  1034. if (nTimeScan == iTS[iIndex])
  1035. break;
  1036. }
  1037. SendDlgItemMessage(hDlg,IDC_SCAN_SECONDS,CB_SETCURSEL,iIndex,0);
  1038. return TRUE;
  1039. case WM_COMMAND:
  1040. switch (wParam) {
  1041. case IDOK:
  1042. iIndex = SendDlgItemMessage(hDlg,IDC_MAX_SCAN,CB_GETCURSEL,0,0);
  1043. iIndex = SendDlgItemMessage(hDlg,IDC_MAX_SCAN,
  1044. CB_GETLBTEXT,iIndex,(LPARAM) (LPCTSTR) pszStr1);
  1045. nTTMax = atoi(pszStr1);
  1046. iIndex = SendDlgItemMessage(hDlg,IDC_AUTO_SECONDS,CB_GETCURSEL,0,0);
  1047. iIndex = SendDlgItemMessage(hDlg,IDC_AUTO_SECONDS,
  1048. CB_GETLBTEXT,iIndex,(LPARAM) (LPCTSTR) pszStr1);
  1049. nTTNext = atoi(pszStr1);
  1050. iIndex = SendDlgItemMessage(hDlg,IDC_SCAN_SECONDS,CB_GETCURSEL,0,0);
  1051. iIndex = SendDlgItemMessage(hDlg,IDC_SCAN_SECONDS,
  1052. CB_GETLBTEXT,iIndex,(LPARAM) (LPCTSTR) pszStr1);
  1053. nTTScan = atoi(pszStr1);
  1054. EndDialog(hDlg, TRUE);
  1055. return TRUE;
  1056. case IDCANCEL:
  1057. EndDialog(hDlg, FALSE);
  1058. return TRUE;
  1059. }
  1060. }
  1061. return FALSE;
  1062. }
  1063. /******************************************************************************
  1064. BOOL SizeDiff(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1065. Output redraw handler when window size changes.
  1066. ******************************************************************************/
  1067. BOOL SizeDiff(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1068. {
  1069. RECT rcClient;
  1070. GetClientRect(hWnd,&rcClient);
  1071. SetWindowPos(hLogWindow,NULL,0,0,
  1072. rcClient.right+(GetSystemMetrics(SM_CXBORDER)*2),
  1073. rcClient.bottom+(GetSystemMetrics(SM_CXBORDER)*2),
  1074. SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
  1075. // always return 0
  1076. return 0;
  1077. }
  1078. /******************************************************************************
  1079. BOOL HScroll(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1080. Horizontal scroll handler.
  1081. ******************************************************************************/
  1082. BOOL HScroll(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1083. {
  1084. int iHscrollInc;
  1085. switch (LOWORD (wParam))
  1086. {
  1087. case SB_LINEUP :
  1088. iHscrollInc = -1 ;
  1089. break ;
  1090. case SB_LINEDOWN :
  1091. iHscrollInc = 1 ;
  1092. break ;
  1093. case SB_PAGEUP :
  1094. iHscrollInc = -8 ;
  1095. break ;
  1096. case SB_PAGEDOWN :
  1097. iHscrollInc = 8 ;
  1098. break ;
  1099. case SB_THUMBPOSITION :
  1100. iHscrollInc = HIWORD(wParam) - iHscrollPos ;
  1101. break ;
  1102. default :
  1103. iHscrollInc = 0 ;
  1104. }
  1105. iHscrollInc = max (-iHscrollPos,
  1106. min (iHscrollInc, iHscrollMax - iHscrollPos)) ;
  1107. if (iHscrollInc != 0)
  1108. {
  1109. iHscrollPos += iHscrollInc ;
  1110. ScrollWindow (hWnd, -cxChar * iHscrollInc, 0, NULL, NULL) ;
  1111. SetScrollPos (hWnd, SB_HORZ, iHscrollPos, TRUE) ;
  1112. }
  1113. // always return 0
  1114. return 0;
  1115. }
  1116. /******************************************************************************
  1117. BOOL VScroll(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1118. Vertical scroll handler.
  1119. ******************************************************************************/
  1120. BOOL VScroll(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1121. {
  1122. int iVscrollInc;
  1123. switch (LOWORD (wParam))
  1124. {
  1125. case SB_TOP :
  1126. iVscrollInc = -iVscrollPos ;
  1127. break ;
  1128. case SB_BOTTOM :
  1129. iVscrollInc = iVscrollMax - iVscrollPos ;
  1130. break ;
  1131. case SB_LINEUP :
  1132. iVscrollInc = -1 ;
  1133. break ;
  1134. case SB_LINEDOWN :
  1135. iVscrollInc = 1 ;
  1136. break ;
  1137. case SB_PAGEUP :
  1138. iVscrollInc = min (-1, -cyClient / cyChar) ;
  1139. break ;
  1140. case SB_PAGEDOWN :
  1141. iVscrollInc = max (1, cyClient / cyChar) ;
  1142. break ;
  1143. case SB_THUMBTRACK :
  1144. iVscrollInc = HIWORD (wParam) - iVscrollPos ;
  1145. break ;
  1146. default :
  1147. iVscrollInc = 0 ;
  1148. }
  1149. iVscrollInc = max (-iVscrollPos,
  1150. min (iVscrollInc, iVscrollMax - iVscrollPos)) ;
  1151. if (iVscrollInc != 0)
  1152. {
  1153. iVscrollPos += iVscrollInc ;
  1154. ScrollWindow (hWnd, 0, -cyChar * iVscrollInc, NULL, NULL) ;
  1155. SetScrollPos (hWnd, SB_VERT, iVscrollPos, TRUE) ;
  1156. UpdateWindow (hWnd) ;
  1157. }
  1158. // always return 0
  1159. return 0;
  1160. }
  1161. /******************************************************************************
  1162. BOOL Creation(HWND,UINT,WPARAM,LPARAM)
  1163. Initialization and global allocation.
  1164. Return 0 to continue creation of window, -1 to quit
  1165. ******************************************************************************/
  1166. BOOL Creation(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1167. {
  1168. TEXTMETRIC tm;
  1169. RECT rRect;
  1170. HDC hDC;
  1171. // seed random generator
  1172. srand((unsigned)time(NULL));
  1173. // create the 5 display and utility strings
  1174. if (! ((hLHand[0] = LocalAlloc(LPTR,LONGSTRING)) &&
  1175. (pszOut = (PSTR) LocalLock(hLHand[0]))))
  1176. return -1;
  1177. if (! ((hLHand[1] = LocalAlloc(LPTR,LONGSTRING)) &&
  1178. (pszStr2 = (PSTR) LocalLock(hLHand[1]))))
  1179. return -1;
  1180. if (! ((hLHand[2] = LocalAlloc(LPTR,LONGSTRING)) &&
  1181. (pszStr1 = (PSTR) LocalLock(hLHand[2]))))
  1182. return -1;
  1183. if (! ((hLHand[3] = LocalAlloc(LPTR,LONGSTRING)) &&
  1184. (pszStr3 = (PSTR) LocalLock(hLHand[3]))))
  1185. return -1;
  1186. if (! ((hLHand[4] = LocalAlloc(LPTR,LONGSTRING)) &&
  1187. (pszStr4 = (PSTR) LocalLock(hLHand[4]))))
  1188. return -1;
  1189. // create output display window
  1190. hDC = GetDC(hWnd);
  1191. GetTextMetrics(hDC,&tm);
  1192. cxChar = tm.tmAveCharWidth ;
  1193. cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar / 2 ;
  1194. cyChar = tm.tmHeight + tm.tmExternalLeading ;
  1195. iMaxWidth = 40 * cxChar + 22 * cxCaps ;
  1196. ReleaseDC(hWnd,hDC);
  1197. GetClientRect(hWnd,&rRect);
  1198. if (NULL == (hLogWindow = CreateWindow("LISTBOX",NULL,
  1199. WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
  1200. LBS_NOINTEGRALHEIGHT | LBS_NOSEL,
  1201. 0,0,rRect.right,rRect.bottom,hWnd,NULL,
  1202. (HINSTANCE)GetWindowLong(hWnd,GWL_HINSTANCE),NULL)))
  1203. return -1;
  1204. // create the DIB to display scanned image
  1205. CreateScanDIB(hWnd);
  1206. // return 0 to continue creation of window
  1207. return 0;
  1208. }
  1209. /******************************************************************************
  1210. BOOL Destruction(HWND,UINT,WPARAM,LPARAM)
  1211. Current instance termination routines.
  1212. Free error message buffer, send destroy window message.
  1213. Note that if Creation() fails, pszMessage is 0.
  1214. ******************************************************************************/
  1215. BOOL Destruction(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1216. {
  1217. int x; // loop counter
  1218. LoadString(hThisInstance,IDS_PRIVINI,pszStr2,LONGSTRING);
  1219. LoadString(hThisInstance,IDS_PRIVSECTION,pszStr1,LONGSTRING);
  1220. // save window location
  1221. SaveFinalWindow(hThisInstance,hWnd,pszStr2,pszStr1);
  1222. // free the 5 display and utility strings
  1223. for (x = 0;x < 5;x++)
  1224. {
  1225. LocalUnlock(hLHand[x]);
  1226. LocalFree(hLHand[x]);
  1227. }
  1228. // delete the DIB object
  1229. DeleteScanDIB();
  1230. // free the output and main windows
  1231. DestroyWindow(hLogWindow);
  1232. DestroyWindow(hWnd);
  1233. // always return 0
  1234. return 0;
  1235. }
  1236. /******************************************************************************
  1237. BOOL OnDeviceChange(HWND,UINT,WPARAM,LPARAM)
  1238. ******************************************************************************/
  1239. const CHAR cszStiBroadcastPrefix[] = TEXT("STI");
  1240. BOOL OnDeviceChange(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1241. {
  1242. struct _DEV_BROADCAST_USERDEFINED *pBroadcastHeader;
  1243. if (wParam == DBT_USERDEFINED ) {
  1244. pBroadcastHeader = (struct _DEV_BROADCAST_USERDEFINED *)lParam;
  1245. __try {
  1246. if (pBroadcastHeader &&
  1247. (pBroadcastHeader->dbud_dbh.dbch_devicetype == DBT_DEVTYP_OEM) &&
  1248. (_strnicmp(pBroadcastHeader->dbud_szName,cszStiBroadcastPrefix,lstrlen(cszStiBroadcastPrefix)) == 0)
  1249. ) {
  1250. //
  1251. // Got STI device broadcast
  1252. //
  1253. DisplayOutput("Received STI device broadcast with message:%s ",
  1254. pBroadcastHeader->dbud_szName + lstrlen(cszStiBroadcastPrefix));
  1255. }
  1256. }
  1257. __except(EXCEPTION_EXECUTE_HANDLER ) {
  1258. ::GetExceptionCode();
  1259. }
  1260. }
  1261. return FALSE;
  1262. }
  1263. /******************************************************************************
  1264. BOOL FirstInstance(HANDLE)
  1265. Register the window.
  1266. Return TRUE/FALSE on success/failure.
  1267. ******************************************************************************/
  1268. BOOL FirstInstance(HINSTANCE hInst)
  1269. {
  1270. PWNDCLASS pClass;
  1271. PSTR pszClass;
  1272. if (! (pszClass = (PSTR) LocalAlloc(LPTR, LONGSTRING)))
  1273. return FALSE;
  1274. LoadString((HINSTANCE)hInst, IDS_CLASSNAME, pszClass, LONGSTRING);
  1275. pClass = (PWNDCLASS) LocalAlloc(LPTR, sizeof(WNDCLASS));
  1276. // set hbrBackground to 0 for no background (app draws background)
  1277. // use COLOR_BACKGROUND+1 for desktop color
  1278. pClass->style = CS_HREDRAW | CS_VREDRAW;
  1279. pClass->lpfnWndProc = WiskProc;
  1280. pClass->cbClsExtra = 0;
  1281. pClass->cbWndExtra = 0;
  1282. pClass->hInstance = (HINSTANCE)hInst;
  1283. pClass->hIcon = LoadIcon((HINSTANCE)hInst, MAKEINTRESOURCE(IDI_STI));
  1284. pClass->hCursor = LoadCursor((HINSTANCE)NULL, IDC_ARROW);
  1285. pClass->hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
  1286. pClass->lpszMenuName = NULL;
  1287. pClass->lpszClassName = (LPSTR) pszClass;
  1288. if (! (RegisterClass((LPWNDCLASS) pClass)))
  1289. return FALSE;
  1290. LocalFree((HANDLE) pClass);
  1291. LocalFree((HANDLE) pszClass);
  1292. return TRUE;
  1293. }
  1294. /******************************************************************************
  1295. HWND MakeWindow(HANDLE)
  1296. Create a window for current instance.
  1297. Return handle to window (which is 0 on failure)
  1298. ******************************************************************************/
  1299. HWND MakeWindow(HINSTANCE hInst)
  1300. {
  1301. HWND hWindow;
  1302. PSTR pszA,pszB;
  1303. RECT rect;
  1304. DWORD dwError;
  1305. // if we can't get string memory, shut down app
  1306. if (pszA = (PSTR) LocalAlloc(LPTR, LONGSTRING))
  1307. {
  1308. if (! (pszB = (PSTR) LocalAlloc(LPTR, LONGSTRING)))
  1309. {
  1310. LocalFree((HANDLE) pszA);
  1311. return FALSE;
  1312. }
  1313. }
  1314. else
  1315. return FALSE;
  1316. // get the caption, classname
  1317. LoadString(hInst, IDS_PRIVINI, pszA, LONGSTRING);
  1318. LoadString(hInst, IDS_PRIVSECTION, pszB, LONGSTRING);
  1319. GetFinalWindow(hInst,&rect,pszA,pszB);
  1320. LoadString(hInst,IDS_CAPTION,pszA,LONGSTRING);
  1321. LoadString(hInst,IDS_CLASSNAME,pszB,LONGSTRING);
  1322. hWindow = CreateWindow((LPSTR) pszB,
  1323. (LPSTR) pszA,
  1324. WS_OVERLAPPEDWINDOW,
  1325. rect.left,
  1326. rect.top,
  1327. rect.right,
  1328. rect.bottom,
  1329. (HWND) NULL,
  1330. 0,
  1331. hInst,
  1332. NULL);
  1333. if (hWindow == 0)
  1334. dwError = GetLastError();
  1335. // Save Instance globally
  1336. hThisInstance = hInst;
  1337. LocalFree((HANDLE) pszB);
  1338. LocalFree((HANDLE) pszA);
  1339. return hWindow;
  1340. }
  1341. /******************************************************************************
  1342. void DisplayOutput(LPSTR pString,...)
  1343. Show text on the display window
  1344. ******************************************************************************/
  1345. void DisplayOutput(LPSTR pString,...)
  1346. {
  1347. char Buffer[512];
  1348. MSG msg;
  1349. int iIndex;
  1350. va_list list;
  1351. va_start(list,pString);
  1352. vsprintf(Buffer,pString,list);
  1353. if (ulCount1++ == MAX_LOOP)
  1354. {
  1355. ulCount1 = 1;
  1356. ulCount2++;
  1357. SendMessage(hLogWindow,LB_RESETCONTENT,0,0);
  1358. }
  1359. iIndex = SendMessage(hLogWindow,LB_ADDSTRING,0,(LPARAM)Buffer);
  1360. SendMessage(hLogWindow,LB_SETCURSEL,iIndex,(LPARAM)MAKELONG(FALSE,0));
  1361. while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
  1362. {
  1363. TranslateMessage(&msg);
  1364. DispatchMessage(&msg);
  1365. }
  1366. UpdateWindow(hLogWindow);
  1367. }
  1368. /******************************************************************************
  1369. void LogOutput(int,LPSTR pString,...)
  1370. Show text on the display window
  1371. ******************************************************************************/
  1372. void LogOutput(int nVerbose,LPSTR pString,...)
  1373. {
  1374. char Buffer[512];
  1375. MSG msg;
  1376. int iIndex;
  1377. va_list list;
  1378. va_start(list,pString);
  1379. vsprintf(Buffer,pString,list);
  1380. if (ulCount1++ == MAX_LOOP)
  1381. {
  1382. ulCount1 = 1;
  1383. ulCount2++;
  1384. SendMessage(hLogWindow,LB_RESETCONTENT,0,0);
  1385. }
  1386. iIndex = SendMessage(hLogWindow,LB_ADDSTRING,0,(LPARAM)Buffer);
  1387. SendMessage(hLogWindow,LB_SETCURSEL,iIndex,(LPARAM)MAKELONG(FALSE,0));
  1388. while (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
  1389. {
  1390. TranslateMessage(&msg);
  1391. DispatchMessage(&msg);
  1392. }
  1393. UpdateWindow(hLogWindow);
  1394. }
  1395. /*****************************************************************************
  1396. void StiDisplayError(HRESULT,char *,BOOL)
  1397. Display verbose error information
  1398. Parameters:
  1399. HRESULT from failed call
  1400. failed call title string
  1401. BOOL TRUE to record error, else ignore it
  1402. Return:
  1403. none
  1404. *****************************************************************************/
  1405. void FatalError(char *szMsg)
  1406. {
  1407. DisplayOutput(szMsg);
  1408. DisplayOutput("* FATAL ERROR CANNOT CONTINUE *");
  1409. return;
  1410. }
  1411. /******************************************************************************
  1412. void DisplayLogPassFail(BOOL bPass)
  1413. ******************************************************************************/
  1414. void DisplayLogPassFail(BOOL bPass)
  1415. {
  1416. if (bPass)
  1417. sprintf(pszStr1," PASS");
  1418. else
  1419. sprintf(pszStr1," FAIL");
  1420. DisplayOutput(pszStr1);
  1421. DisplayOutput("");
  1422. tlLog(hNTLog,TL_LOG,pszStr1);
  1423. }
  1424. /******************************************************************************
  1425. BOOL ParseCmdLine(LPSTR lpCmdLine)
  1426. Parse the command line for valid options
  1427. Return TRUE if an automated test was selected, else FALSE
  1428. ******************************************************************************/
  1429. BOOL ParseCmdLine(LPSTR lpCmdLine)
  1430. {
  1431. int nAnyTest = 0,
  1432. nInfFile = 0,
  1433. nLogFile = 0,
  1434. nWLogFile = 0,
  1435. next;
  1436. char *pArg,
  1437. *szPtr,
  1438. szTmpBuf[LONGSTRING];
  1439. if (*lpCmdLine) {
  1440. DisplayOutput("Command line: \"%s\"",lpCmdLine);
  1441. DisplayOutput("");
  1442. }
  1443. for (pArg = lpCmdLine;*pArg;)
  1444. {
  1445. next = NextToken(szTmpBuf,pArg);
  1446. pArg += next;
  1447. // remove the common command line separators (if present)
  1448. if (szTmpBuf[0] == '/' || szTmpBuf[0] == '-')
  1449. strcpy(szTmpBuf,(szTmpBuf + 1));
  1450. // upper case our parameter
  1451. for (szPtr = &szTmpBuf[0];*szPtr;szPtr++)
  1452. *szPtr = toupper(*szPtr);
  1453. // Look for other switches
  1454. switch(szTmpBuf[0])
  1455. {
  1456. case '?':
  1457. case 'H':
  1458. if (! nAnyTest) {
  1459. // request for help
  1460. if ((! strncmp("?",szTmpBuf,strlen(szTmpBuf)) ||
  1461. (! strncmp("HELP",szTmpBuf,strlen(szTmpBuf))))) {
  1462. pSuite = nHelpSuite;
  1463. nMaxCount = 1;
  1464. nAnyTest = 1;
  1465. }
  1466. }
  1467. break;
  1468. case 'C':
  1469. if (! nAnyTest) {
  1470. // external Sti compliance test
  1471. if (! strncmp("COMPLIANCE",szTmpBuf,strlen(szTmpBuf))) {
  1472. pSuite = nComplianceSuite;
  1473. nMaxCount = 3;
  1474. nTimeScan = 10;
  1475. nTimeNext = 1;
  1476. nAnyTest = 1;
  1477. // get handle to the compliance menu
  1478. hMenu = LoadMenu(hThisInstance,
  1479. MAKEINTRESOURCE(IDR_STI_COMP));
  1480. }
  1481. }
  1482. break;
  1483. case 'E':
  1484. if (! nAnyTest) {
  1485. // external Sti compliance test
  1486. if (! strncmp("ERRORLOG",szTmpBuf,strlen(szTmpBuf))) {
  1487. pSuite = nErrorlogSuite;
  1488. nMaxCount = 1;
  1489. nTimeNext = 1;
  1490. nAnyTest = 1;
  1491. }
  1492. }
  1493. // exit when test has run
  1494. if (! strncmp("EXIT",szTmpBuf,strlen(szTmpBuf)))
  1495. bExit = TRUE;
  1496. break;
  1497. case 'I':
  1498. if (! nInfFile) {
  1499. // read test instructions from an .INF file
  1500. if (! strncmp("INF",szTmpBuf,strlen(szTmpBuf))) {
  1501. // inf file stuff
  1502. nInfFile = 1;
  1503. }
  1504. }
  1505. break;
  1506. case 'L':
  1507. if (! nLogFile) {
  1508. // write screen output to .LOG file
  1509. if (! strncmp("LOG",szTmpBuf,strlen(szTmpBuf))) {
  1510. // log file stuff
  1511. nLogFile = 1;
  1512. }
  1513. }
  1514. break;
  1515. case 'N':
  1516. // don't show COMPLIANCE test dialog
  1517. if (! strncmp("NODIALOG",szTmpBuf,strlen(szTmpBuf)))
  1518. bCompDiag = FALSE;
  1519. break;
  1520. case 'S':
  1521. if (! nAnyTest) {
  1522. // internal Sti SHIPCRIT test
  1523. if (! strncmp("SHIPCRIT",szTmpBuf,strlen(szTmpBuf))) {
  1524. pSuite = nShipcritSuite;
  1525. nMaxCount = 200;
  1526. nTimeScan = 10;
  1527. nTimeNext = 1;
  1528. nAnyTest = 1;
  1529. }
  1530. }
  1531. // the application was launched by an Sti event!
  1532. if (! (strncmp(STIEVENTARG,szTmpBuf, strlen(STIEVENTARG))) ||
  1533. (! (strncmp(STIDEVARG,szTmpBuf, strlen(STIDEVARG))))) {
  1534. nEvent = 1;
  1535. MessageBox(NULL,szTmpBuf,"Stillvue",MB_OK);
  1536. }
  1537. break;
  1538. case 'T':
  1539. if (! nAnyTest) {
  1540. // external Sti compliance test
  1541. if (! strncmp("TEST",szTmpBuf,strlen(szTmpBuf))) {
  1542. pSuite = nOutputSuite;
  1543. nMaxCount = 0;
  1544. nTimeNext = 1;
  1545. nAnyTest = 1;
  1546. nTimeMultiplier = 1;
  1547. }
  1548. }
  1549. break;
  1550. case 'W':
  1551. if (! nWLogFile) {
  1552. // write NTLOG output to STIWHQL.LOG file
  1553. if (! strncmp("WHQL",szTmpBuf,strlen(szTmpBuf))) {
  1554. // log file stuff
  1555. nWLogFile = 1;
  1556. }
  1557. }
  1558. break;
  1559. default:
  1560. break;
  1561. }
  1562. }
  1563. if (nAnyTest)
  1564. return TRUE;
  1565. else
  1566. return FALSE;
  1567. }
  1568. /******************************************************************************
  1569. int PASCAL WinMain(HANDLE,HANDLE,LPSTR,short)
  1570. The app itself.
  1571. ******************************************************************************/
  1572. int APIENTRY WinMain(HINSTANCE hInstance,
  1573. HINSTANCE hPrevInstance,
  1574. LPSTR lpCmdLine,
  1575. int nCmdShow)
  1576. {
  1577. MSG msg; // message passing structure
  1578. HWND hWnd; // Handle to main window
  1579. HMENU hMenuPopup; // add ports to PORT menu
  1580. // exit if registration and window creation fail
  1581. if (! FirstInstance (hInstance))
  1582. return FALSE;
  1583. // Can't create window? Bail out
  1584. if (! (hWnd = MakeWindow (hInstance)))
  1585. return FALSE;
  1586. ShowWindow(hWnd,nCmdShow);
  1587. // save instance
  1588. hThisInstance = hInstance;
  1589. // initialize NT Logging
  1590. NTLogInit();
  1591. // display name of this app
  1592. LoadString(hThisInstance,IDS_APPNAME,pszOut,LONGSTRING);
  1593. LoadString(hThisInstance,IDS_CAPTION,pszStr2,LONGSTRING);
  1594. wsprintf(pszStr1,"%s - %s",pszOut,pszStr2);
  1595. DisplayOutput(pszStr1);
  1596. // display last run statistics
  1597. {
  1598. int nCount,
  1599. nScan,
  1600. nError;
  1601. LoadString(hThisInstance,IDS_PRIVINI,pszStr3,LONGSTRING);
  1602. LoadString(hThisInstance,IDS_PRIVSECTION,pszStr4,LONGSTRING);
  1603. nCount = GetPrivateProfileInt(pszStr4,"Last count",0,pszStr3);
  1604. nScan = GetPrivateProfileInt(pszStr4,"Last scan",0,pszStr3);
  1605. nError = GetPrivateProfileInt(pszStr4,"Last error",0,pszStr3);
  1606. wsprintf(pszStr1,
  1607. "Last run was %d loops (%d scans and %d errors)",
  1608. nCount,nScan,nError);
  1609. DisplayOutput(pszStr1);
  1610. }
  1611. // get handle to the standard menu
  1612. hMenu = LoadMenu(hThisInstance, MAKEINTRESOURCE(IDR_STI_LAB));
  1613. // parse the command line
  1614. bAuto = ParseCmdLine(lpCmdLine);
  1615. // start test timer if automated test on command line
  1616. if (bAuto)
  1617. {
  1618. bAuto = StartAutoTimer(hWnd);
  1619. }
  1620. // start Sti event handler if an Sti event launched us
  1621. if (nEvent)
  1622. {
  1623. BOOL bReturn;
  1624. StiCreateInstance(&bReturn);
  1625. StiEnum(&bReturn);
  1626. StiEvent(hWnd);
  1627. // select the device that called the event
  1628. StiSelect(hWnd,EVENT,&bReturn);
  1629. }
  1630. // load the selected menu
  1631. hMenuPopup = CreateMenu();
  1632. SetMenu(hWnd, hMenu);
  1633. while (GetMessage(&msg,(HWND) NULL,0,0))
  1634. {
  1635. TranslateMessage(&msg);
  1636. DispatchMessage(&msg);
  1637. }
  1638. return 0;
  1639. }
  1640. /******************************************************************************
  1641. long FAR PASCAL WiskProc(HWND,UINT,WPARAM,LPARAM)
  1642. The main exported procedure.
  1643. ******************************************************************************/
  1644. long FAR PASCAL WiskProc(HWND hWnd,UINT wMsgID,WPARAM wParam,LPARAM lParam)
  1645. {
  1646. switch (wMsgID)
  1647. {
  1648. case WM_COMMAND:
  1649. return CommandParse(hWnd,wMsgID,wParam,lParam);
  1650. case WM_TIMER:
  1651. return TimerParse(hWnd,wMsgID,wParam,lParam);
  1652. case WM_SIZE:
  1653. return SizeDiff(hWnd,wMsgID,wParam,lParam);
  1654. case WM_HSCROLL:
  1655. return HScroll(hWnd,wMsgID,wParam,lParam);
  1656. case WM_VSCROLL:
  1657. return VScroll(hWnd,wMsgID,wParam,lParam);
  1658. case WM_CLOSE:
  1659. EndTest(hWnd,0);
  1660. return Destruction(hWnd,wMsgID,wParam,lParam);
  1661. case WM_DESTROY:
  1662. PostQuitMessage(0);
  1663. return 0L;
  1664. case WM_CREATE:
  1665. return Creation(hWnd,wMsgID,wParam,lParam);
  1666. case WM_DEVICECHANGE:
  1667. return OnDeviceChange(hWnd,wMsgID,wParam,lParam);
  1668. default:
  1669. return DefWindowProc(hWnd,wMsgID,wParam,lParam);
  1670. }
  1671. }