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.

709 lines
23 KiB

  1. /******************************************************************************
  2. Copyright (C) Microsoft Corporation 1985-1991. All rights reserved.
  3. Title: config.c - Multimedia Systems Media Control Interface
  4. driver for AVI - configuration dialog.
  5. *****************************************************************************/
  6. #include "graphic.h"
  7. #include "cnfgdlg.h"
  8. #define comptypeNONE mmioFOURCC('n','o','n','e')
  9. #ifndef WIN32
  10. #define SZCODE char _based(_segname("_CODE"))
  11. #else
  12. #define SZCODE TCHAR
  13. #endif
  14. SZCODE szDEFAULTVIDEO[] = TEXT("DefaultVideo");
  15. SZCODE szVIDEOWINDOW[] = TEXT("Window");
  16. SZCODE szVIDEO240[] = TEXT("240 Line Fullscreen");
  17. SZCODE szSEEKEXACT[] = TEXT("AccurateSeek");
  18. SZCODE szZOOMBY2[] = TEXT("ZoomBy2");
  19. //SZCODE szSTUPIDMODE[] = TEXT("DontBufferOffscreen");
  20. SZCODE szSKIPFRAMES[] = TEXT("SkipFrames");
  21. SZCODE szUSEAVIFILE[] = TEXT("UseAVIFile");
  22. SZCODE szIni[] = TEXT("MCIAVI");
  23. SZCODE sz1[] = TEXT("1");
  24. SZCODE sz0[] = TEXT("0");
  25. SZCODE szIntl[] = TEXT("Intl");
  26. SZCODE szDecimal[] = TEXT("sDecimal");
  27. SZCODE szThousand[] = TEXT("sThousand");
  28. /* Make sure we only have one configure box up at a time.... */
  29. HWND ghwndConfig = NULL;
  30. #ifdef DEBUG
  31. BOOL FAR PASCAL _LOADDS DebugDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  32. {
  33. static NPMCIGRAPHIC npMCI = NULL;
  34. HWND cb;
  35. int i;
  36. TCHAR ach[40];
  37. extern int giDebugLevel; // current debug level (common.h)
  38. switch (wMsg) {
  39. case WM_INITDIALOG:
  40. npMCI = (NPMCIGRAPHIC)(UINT)lParam;
  41. //
  42. // set the DEBUG stuff.
  43. //
  44. CheckDlgButton(hDlg, ID_SCREEN, GetProfileInt(TEXT("DrawDib"), TEXT("DecompressToScreen"), 2));
  45. CheckDlgButton(hDlg, ID_BITMAP, GetProfileInt(TEXT("DrawDib"), TEXT("DecompressToBitmap"), 2));
  46. CheckDlgButton(hDlg, ID_SUCKS, GetProfileInt(TEXT("DrawDib"), TEXT("DrawToBitmap"), 2));
  47. CheckDlgButton(hDlg, ID_USE_AVIFILE, (npMCI->dwOptionFlags & MCIAVIO_USEAVIFILE) != 0);
  48. SetScrollRange(GetDlgItem(hDlg, ID_RATE), SB_CTL, 0, 1000, TRUE);
  49. SetScrollPos(GetDlgItem(hDlg, ID_RATE), SB_CTL, (int)npMCI->PlaybackRate,TRUE);
  50. cb = GetDlgItem(hDlg, ID_LEVEL);
  51. SetWindowFont(cb, GetStockObject(ANSI_VAR_FONT), FALSE);
  52. ComboBox_AddString(cb, "0 - None");
  53. ComboBox_AddString(cb, "1 - Level 1");
  54. ComboBox_AddString(cb, "2 - Level 2");
  55. ComboBox_AddString(cb, "3 - Level 3");
  56. ComboBox_AddString(cb, "4 - Level 4");
  57. ComboBox_SetCurSel(cb, giDebugLevel);
  58. #include "..\verinfo\usa\verinfo.h"
  59. wsprintf(ach,TEXT("Build %d.%02d.%02d"), MMVERSION, MMREVISION, MMRELEASE);
  60. SetDlgItemText(hDlg, ID_BUILD, ach);
  61. return TRUE;
  62. case WM_HSCROLL:
  63. i = GetScrollPos((HWND)HIWORD(lParam),SB_CTL);
  64. switch (LOWORD(wParam)) {
  65. case SB_LINEDOWN: i+=10; break;
  66. case SB_LINEUP: i-=10; break;
  67. case SB_PAGEDOWN: i+=100; break;
  68. case SB_PAGEUP: i-=100; break;
  69. case SB_THUMBTRACK:
  70. case SB_THUMBPOSITION: i = LOWORD(lParam); break;
  71. }
  72. if (i<0) i=0;
  73. if (i>1000) i=1000;
  74. SetScrollPos((HWND)HIWORD(lParam),SB_CTL,i,TRUE);
  75. break;
  76. case WM_COMMAND:
  77. switch (wParam) {
  78. case IDCANCEL:
  79. case IDOK:
  80. i = IsDlgButtonChecked(hDlg, ID_SUCKS);
  81. if (i == 2)
  82. WriteProfileString(TEXT("DrawDib"), TEXT("DrawToBitmap"), NULL);
  83. else
  84. WriteProfileString(TEXT("DrawDib"), TEXT("DrawToBitmap"), (LPTSTR)(i ? sz1 : sz0));
  85. i = IsDlgButtonChecked(hDlg, ID_SCREEN);
  86. if (i == 2)
  87. WriteProfileString(TEXT("DrawDib"), TEXT("DecompressToScreen"),NULL);
  88. else
  89. WriteProfileString(TEXT("DrawDib"), TEXT("DecompressToScreen"),(LPTSTR)(i ? sz1 : sz0));
  90. i = IsDlgButtonChecked(hDlg, ID_BITMAP);
  91. if (i == 2)
  92. WriteProfileString(TEXT("DrawDib"), TEXT("DecompressToBitmap"),NULL);
  93. else
  94. WriteProfileString(TEXT("DrawDib"), TEXT("DecompressToBitmap"),(LPTSTR)(i ? sz1 : sz0));
  95. npMCI->PlaybackRate = GetScrollPos(GetDlgItem(hDlg, ID_RATE), SB_CTL);
  96. giDebugLevel = ComboBox_GetCurSel(GetDlgItem(hDlg, ID_LEVEL));
  97. wsprintf(ach,TEXT("%d"),giDebugLevel);
  98. WriteProfileString(TEXT("Debug"),TEXT("MCIAVI"),ach);
  99. if (IsDlgButtonChecked(hDlg, ID_USE_AVIFILE))
  100. npMCI->dwOptionFlags |= MCIAVIO_USEAVIFILE;
  101. else
  102. npMCI->dwOptionFlags &= ~MCIAVIO_USEAVIFILE;
  103. EndDialog(hDlg, TRUE);
  104. break;
  105. case ID_RATE:
  106. break;
  107. }
  108. break;
  109. }
  110. return FALSE;
  111. }
  112. #endif // DEBUG
  113. LONG AVIGetFileSize(LPTSTR szFile)
  114. {
  115. LONG lSize;
  116. #ifdef WIN32
  117. DWORD dwHigh;
  118. HANDLE fh;
  119. fh = CreateFile(szFile, GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ,
  120. NULL, OPEN_EXISTING, 0, 0);
  121. if (fh == (HANDLE)HFILE_ERROR)
  122. return 0;
  123. lSize = (LONG)GetFileSize(fh, &dwHigh);
  124. CloseHandle(fh);
  125. #else
  126. OFSTRUCT of;
  127. HFILE fh;
  128. fh = OpenFile(szFile, &of, OF_READ | OF_SHARE_DENY_NONE);
  129. if (fh == HFILE_ERROR)
  130. fh = OpenFile(szFile, &of, OF_READ);
  131. if (fh == HFILE_ERROR)
  132. return 0;
  133. lSize = _llseek(fh, 0, SEEK_END);
  134. _lclose(fh);
  135. #endif
  136. return lSize;
  137. }
  138. //
  139. //fill in the info box.
  140. //
  141. BOOL ConfigInfo(NPMCIGRAPHIC npMCI, HWND hwnd)
  142. {
  143. PTSTR pchInfo;
  144. LONG len;
  145. DWORD time;
  146. PTSTR pch;
  147. TCHAR ach[80];
  148. TCHAR achDecimal[4];
  149. TCHAR achThousand[4];
  150. int i;
  151. if (npMCI == NULL)
  152. return FALSE;
  153. achDecimal[0] = '.'; achDecimal[1] = 0;
  154. achThousand[0] = ','; achThousand[1] = 0;
  155. GetProfileString(szIntl, szDecimal, achDecimal, achDecimal, sizeof(achDecimal));
  156. GetProfileString(szIntl, szThousand, achThousand, achThousand, sizeof(achThousand));
  157. pchInfo = (PTSTR)LocalAlloc(LPTR, 8192*sizeof(TCHAR));
  158. if (pchInfo == NULL)
  159. return FALSE;
  160. pch = pchInfo;
  161. //
  162. // display file name
  163. //
  164. // File: full path.
  165. //
  166. LoadString(ghModule, INFO_FILE, ach, sizeof(ach));
  167. pch += wsprintf(pch, ach, (LPTSTR)npMCI->szFilename);
  168. //
  169. // display file type
  170. //
  171. // Type: type
  172. //
  173. if (npMCI->pf) {
  174. #ifdef USEAVIFILE
  175. AVIFILEINFO info;
  176. LoadString(ghModule, INFO_FILETYPE, ach, sizeof(ach));
  177. npMCI->pf->lpVtbl->Info(npMCI->pf, &info, sizeof(info));
  178. pch += wsprintf(pch, ach, (LPSTR)info.szFileType);
  179. #endif
  180. }
  181. else if (npMCI->dwFlags & MCIAVI_NOTINTERLEAVED) {
  182. LoadString(ghModule, INFO_FILETYPE_AVI, pch, 80);
  183. pch += lstrlen(pch);
  184. }
  185. else {
  186. LoadString(ghModule, INFO_FILETYPE_INT, pch, 80);
  187. pch += lstrlen(pch);
  188. }
  189. //
  190. // display length
  191. //
  192. // Length: ## Frames (#.## sec)
  193. //
  194. LoadString(ghModule, INFO_LENGTH, ach, sizeof(ach));
  195. time = muldivru32(npMCI->lFrames, npMCI->dwMicroSecPerFrame, 1000L);
  196. pch += wsprintf(pch, ach,
  197. npMCI->lFrames, time/1000, achDecimal[0], (int)(time%1000));
  198. //
  199. // display the average data rate
  200. //
  201. // Data Rate: #k/sec
  202. //
  203. len = npMCI->dwBigListEnd - npMCI->dwMovieListOffset;
  204. if (len == 0)
  205. len = AVIGetFileSize(npMCI->szFilename);
  206. if (len > 0) {
  207. LoadString(ghModule, INFO_DATARATE, ach, sizeof(ach));
  208. pch += wsprintf(pch, ach,muldiv32(len,1000,time) / 1024);
  209. }
  210. //
  211. // dump info on each stream.
  212. //
  213. for (i=0; i<npMCI->streams; i++) {
  214. STREAMINFO *psi = SI(i);
  215. LONG rate = muldiv32(psi->sh.dwRate,1000,psi->sh.dwScale);
  216. //
  217. // display video format
  218. //
  219. // Video: MSVC 160x120x8 (cram) 15.000 fps
  220. //
  221. if (psi->lpFormat && psi->sh.fccType == streamtypeVIDEO) {
  222. LPBITMAPINFOHEADER lpbi = (LPBITMAPINFOHEADER)psi->lpFormat;
  223. DWORD fccHandler = psi->sh.fccHandler;
  224. DWORD fccFormat = lpbi->biCompression;
  225. if (fccHandler == 0) fccHandler = comptypeNONE;
  226. if (fccHandler == BI_RLE8) fccHandler = comptypeRLE;
  227. if (fccFormat == 0) fccFormat = comptypeNONE;
  228. if (fccFormat == BI_RLE8) fccFormat = comptypeRLE;
  229. LoadString(ghModule, INFO_VIDEOFORMAT, ach, sizeof(ach));
  230. pch += wsprintf(pch, ach,
  231. (LPVOID)&fccHandler,
  232. (int)lpbi->biWidth,
  233. (int)lpbi->biHeight,
  234. (int)lpbi->biBitCount,
  235. (LPVOID)&fccFormat,
  236. (UINT)(rate/1000), achDecimal[0], (UINT)(rate%1000));
  237. }
  238. //
  239. // display audio format
  240. //
  241. // Audio: Mono 11.024KHz 8bit
  242. //
  243. else if (psi->lpFormat && psi->sh.fccType == streamtypeAUDIO) {
  244. LPWAVEFORMAT pwf = (LPWAVEFORMAT)psi->lpFormat;
  245. if (pwf->nChannels == 1)
  246. LoadString(ghModule, INFO_MONOFORMAT, ach, sizeof(ach));
  247. else
  248. LoadString(ghModule, INFO_STEREOFORMAT, ach, sizeof(ach));
  249. pch += wsprintf(pch, ach,
  250. (int)(pwf->nSamplesPerSec/1000),achDecimal[0],
  251. (int)(pwf->nSamplesPerSec%1000),
  252. (int)(pwf->nAvgBytesPerSec * 8 / (pwf->nSamplesPerSec * pwf->nChannels)));
  253. if (pwf->wFormatTag == WAVE_FORMAT_PCM) {
  254. }
  255. else if (pwf->wFormatTag == 2) { // ADPCM
  256. pch -= 2; // skip over \r\n
  257. LoadString(ghModule, INFO_ADPCM, pch, 20);
  258. pch += lstrlen(pch);
  259. }
  260. else {
  261. pch -= 2; // skip over \r\n
  262. LoadString(ghModule, INFO_COMPRESSED, pch, 20);
  263. pch += lstrlen(pch);
  264. }
  265. }
  266. //
  267. // Other stream.
  268. //
  269. else if (psi->sh.fccType != 0) {
  270. LoadString(ghModule, INFO_STREAM, ach, sizeof(ach));
  271. pch += wsprintf(pch, ach,
  272. (LPSTR)&psi->sh.fccType,
  273. (LPSTR)&psi->sh.fccHandler);
  274. }
  275. if (!(psi->dwFlags & STREAM_ENABLED)) {
  276. pch -= 2; // skip over \r\n
  277. LoadString(ghModule, INFO_DISABLED, ach, sizeof(ach));
  278. pch += wsprintf(pch, ach);
  279. }
  280. }
  281. #ifdef DEBUG
  282. //
  283. // show the frames skipped on the last play
  284. //
  285. if (npMCI->lFramesPlayed > 0) {
  286. LoadString(ghModule, INFO_SKIP, ach, sizeof(ach));
  287. pch += wsprintf(pch, ach,
  288. npMCI->lSkippedFrames,
  289. npMCI->lFramesPlayed,
  290. (int)(100L * npMCI->lSkippedFrames / npMCI->lFramesPlayed));
  291. //
  292. // show the frames not read on the last play
  293. //
  294. if (npMCI->lFramesSeekedPast > 0) {
  295. LoadString(ghModule, INFO_NOTREAD, ach, sizeof(ach));
  296. pch += wsprintf(pch, ach,
  297. npMCI->lFramesSeekedPast,
  298. (int)(100L * npMCI->lFramesSeekedPast / npMCI->lFramesPlayed));
  299. }
  300. }
  301. //
  302. // show the # audio breaks on the last play
  303. //
  304. if (npMCI->lFramesPlayed > 0 && npMCI->lAudioBreaks > 0) {
  305. LoadString(ghModule, INFO_SKIPAUDIO, ach, sizeof(ach));
  306. pch += wsprintf(pch, ach, npMCI->lAudioBreaks);
  307. }
  308. #endif
  309. if (npMCI->dwKeyFrameInfo == 1) {
  310. LoadString(ghModule, INFO_ALLKEYFRAMES, ach, sizeof(ach));
  311. pch += wsprintf(pch, ach, (int)npMCI->dwKeyFrameInfo);
  312. }
  313. else if (npMCI->dwKeyFrameInfo == 0) {
  314. LoadString(ghModule, INFO_NOKEYFRAMES, ach, sizeof(ach));
  315. pch += wsprintf(pch, ach, (int)npMCI->dwKeyFrameInfo);
  316. }
  317. else {
  318. LoadString(ghModule, INFO_KEYFRAMES, ach, sizeof(ach));
  319. pch += wsprintf(pch, ach, (int)npMCI->dwKeyFrameInfo);
  320. }
  321. #ifdef DEBUG
  322. //
  323. // timing info
  324. //
  325. #define SEC(time) (UINT)(time / 1000l) , (UINT)(time % 1000l)
  326. #define SECX(time,t) SEC(time) , (t ? (UINT)(time * 100l / t) : 0)
  327. if (npMCI->lFramesPlayed > 0) {
  328. DRAWDIBTIME ddt;
  329. pch += wsprintf(pch, TEXT("MCIAVI-------------------------------------\r\n"));
  330. pch += wsprintf(pch, TEXT("timePlay: \t%3d.%03dsec\r\n"),SEC(npMCI->timePlay));
  331. pch += wsprintf(pch, TEXT("timeRead: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeRead, npMCI->timePlay));
  332. pch += wsprintf(pch, TEXT("timeWait: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeWait, npMCI->timePlay));
  333. pch += wsprintf(pch, TEXT("timeYield: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeYield, npMCI->timePlay));
  334. pch += wsprintf(pch, TEXT("timeVideo: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeVideo, npMCI->timePlay));
  335. pch += wsprintf(pch, TEXT("timeDraw: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeDraw, npMCI->timePlay));
  336. pch += wsprintf(pch, TEXT("timeDecomp: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeDecompress, npMCI->timePlay));
  337. pch += wsprintf(pch, TEXT("timeAudio: \t%3d.%03dsec (%d%%)\r\n"),SECX(npMCI->timeAudio, npMCI->timePlay));
  338. pch += wsprintf(pch, TEXT("timePaused: \t%3d.%03dsec\r\n"),SEC(npMCI->timePaused));
  339. pch += wsprintf(pch, TEXT("timePrepare: \t%3d.%03dsec\r\n"),SEC(npMCI->timePrepare));
  340. pch += wsprintf(pch, TEXT("timeCleanup: \t%3d.%03dsec\r\n"),SEC(npMCI->timeCleanup));
  341. if (npMCI->hdd && DrawDibTime(npMCI->hdd, &ddt)) {
  342. pch += wsprintf(pch, TEXT("DrawDib-------------------------------------\r\n"));
  343. pch += wsprintf(pch, TEXT("timeDraw: \t%3d.%03dsec\r\n"), SEC(ddt.timeDraw));
  344. pch += wsprintf(pch, TEXT("timeDecompress: \t%3d.%03dsec (%d%%)\r\n"), SECX(ddt.timeDecompress, ddt.timeDraw));
  345. pch += wsprintf(pch, TEXT("timeDither: \t%3d.%03dsec (%d%%)\r\n"), SECX(ddt.timeDither, ddt.timeDraw));
  346. pch += wsprintf(pch, TEXT("timeStretch: \t%3d.%03dsec (%d%%)\r\n"), SECX(ddt.timeStretch, ddt.timeDraw));
  347. pch += wsprintf(pch, TEXT("timeSetDIBits: \t%3d.%03dsec (%d%%)\r\n"), SECX(ddt.timeSetDIBits, ddt.timeDraw));
  348. pch += wsprintf(pch, TEXT("timeBlt: \t%3d.%03dsec (%d%%)\r\n"), SECX(ddt.timeBlt, ddt.timeDraw));
  349. }
  350. }
  351. #endif
  352. //
  353. // now shove this mess into the info window.
  354. //
  355. Assert(pch - pchInfo < 8192);
  356. SetWindowFont(GetDlgItem(hwnd, ID_INFO), GetStockObject(ANSI_VAR_FONT), TRUE);
  357. SetDlgItemText(hwnd, ID_INFO, pchInfo);
  358. LocalFree((HLOCAL)pchInfo);
  359. return TRUE;
  360. }
  361. BOOL FAR PASCAL _LOADDS ConfigDlgProc(HWND hDlg, UINT wMsg,
  362. WPARAM wParam, LPARAM lParam)
  363. {
  364. static NPMCIGRAPHIC npMCI = NULL;
  365. DWORD dwOptions;
  366. TCHAR ach[80];
  367. switch (wMsg) {
  368. case WM_INITDIALOG:
  369. npMCI = (NPMCIGRAPHIC)(UINT)lParam;
  370. ghwndConfig = hDlg;
  371. if (npMCI)
  372. dwOptions = npMCI->dwOptionFlags;
  373. else
  374. dwOptions = ReadConfigInfo();
  375. #ifndef WIN32
  376. // On NT we do not support full screen. I wonder if this
  377. // will ever change ?
  378. CheckRadioButton(hDlg, ID_WINDOW, ID_VGA240,
  379. (dwOptions & MCIAVIO_USEVGABYDEFAULT) ?
  380. ID_VGA240 : ID_WINDOW);
  381. #endif
  382. CheckDlgButton(hDlg, ID_ZOOM2,
  383. (dwOptions & MCIAVIO_ZOOMBY2) != 0);
  384. CheckDlgButton(hDlg, ID_SKIPFRAMES,
  385. (dwOptions & MCIAVIO_SKIPFRAMES) != 0);
  386. #if 0 /////////////////////////////////////////////////////////////////////
  387. CheckDlgButton(hDlg, ID_FAILIFNOWAVE,
  388. (dwOptions & MCIAVIO_FAILIFNOWAVE) != 0);
  389. CheckDlgButton(hDlg, ID_SEEKEXACT,
  390. (dwOptions & MCIAVIO_SEEKEXACT) == 0);
  391. #endif /////////////////////////////////////////////////////////////////////
  392. // CheckDlgButton(hDlg, ID_STUPIDMODE,
  393. // (dwOptions & MCIAVIO_STUPIDMODE) != 0);
  394. EnableWindow(GetDlgItem(hDlg, ID_ZOOM2), TRUE);
  395. // (dwOptions & MCIAVIO_STUPIDMODE) == 0);
  396. if (npMCI == NULL) {
  397. GetDlgItemText(hDlg, ID_DEFAULT, ach, sizeof(ach)/sizeof(TCHAR));
  398. SetDlgItemText(hDlg, IDOK, ach);
  399. ShowWindow(GetDlgItem(hDlg, ID_DEFAULT),SW_HIDE);
  400. }
  401. if (!ConfigInfo(npMCI, hDlg)) {
  402. RECT rcWindow;
  403. RECT rc;
  404. GetWindowRect(hDlg, &rcWindow);
  405. GetWindowRect(GetDlgItem(hDlg, ID_SIZE), &rc);
  406. SetWindowPos(hDlg, NULL, 0, 0,
  407. rcWindow.right-rcWindow.left,
  408. rc.top - rcWindow.top,
  409. SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
  410. }
  411. return TRUE;
  412. case WM_ENDSESSION:
  413. if (wParam)
  414. EndDialog(hDlg, FALSE);
  415. break;
  416. case WM_COMMAND:
  417. switch (wParam) {
  418. case ID_DEFAULT:
  419. case IDOK:
  420. if (npMCI)
  421. dwOptions = npMCI->dwOptionFlags;
  422. else
  423. dwOptions = 0;
  424. /* Clear the flags we might set */
  425. dwOptions &= ~(MCIAVIO_USEVGABYDEFAULT |
  426. MCIAVIO_SKIPFRAMES |
  427. //// MCIAVIO_FAILIFNOWAVE |
  428. //// MCIAVIO_SEEKEXACT |
  429. MCIAVIO_ZOOMBY2 |
  430. MCIAVIO_STUPIDMODE);
  431. #ifndef WIN32
  432. // On NT we do not support full screen. I wonder if this
  433. // will ever change ?
  434. if (!IsDlgButtonChecked(hDlg, ID_WINDOW))
  435. dwOptions |= MCIAVIO_USEVGABYDEFAULT;
  436. #endif
  437. if (IsDlgButtonChecked(hDlg, ID_SKIPFRAMES))
  438. dwOptions |= MCIAVIO_SKIPFRAMES;
  439. //// if (IsDlgButtonChecked(hDlg, ID_FAILIFNOWAVE))
  440. //// dwOptions |= MCIAVIO_FAILIFNOWAVE;
  441. //// if (!IsDlgButtonChecked(hDlg, ID_SEEKEXACT))
  442. dwOptions |= MCIAVIO_SEEKEXACT;
  443. // if (IsDlgButtonChecked(hDlg, ID_STUPIDMODE))
  444. // dwOptions |= MCIAVIO_STUPIDMODE;
  445. //
  446. // else if (IsDlgButtonChecked(hDlg, ID_ZOOM2))
  447. if (IsDlgButtonChecked(hDlg, ID_ZOOM2))
  448. dwOptions |= MCIAVIO_ZOOMBY2;
  449. if (wParam == ID_DEFAULT || npMCI == NULL)
  450. WriteConfigInfo(dwOptions);
  451. if (wParam == IDOK) {
  452. if (npMCI)
  453. npMCI->dwOptionFlags = dwOptions;
  454. EndDialog(hDlg, TRUE);
  455. }
  456. break;
  457. // case ID_STUPIDMODE:
  458. // EnableWindow(GetDlgItem(hDlg, ID_ZOOM2),
  459. // !IsDlgButtonChecked(hDlg, ID_STUPIDMODE));
  460. //
  461. // /* Clear "zoom" if easy mode checked */
  462. // if (IsDlgButtonChecked(hDlg, ID_STUPIDMODE))
  463. // CheckDlgButton(hDlg, ID_ZOOM2, FALSE);
  464. // break;
  465. case IDCANCEL:
  466. EndDialog(hDlg, FALSE);
  467. break;
  468. #ifdef DEBUG
  469. case ID_DEBUG:
  470. DialogBoxParam(ghModule, MAKEINTRESOURCE(IDA_DEBUG),
  471. hDlg, DebugDlgProc, (DWORD)(UINT)npMCI);
  472. break;
  473. #endif
  474. }
  475. break;
  476. }
  477. return FALSE;
  478. }
  479. DWORD FAR PASCAL ReadConfigInfo(void)
  480. {
  481. int i;
  482. DWORD dwOptions = 0L;
  483. HDC hdc;
  484. //
  485. // ask the display device if it can do 256 color.
  486. //
  487. hdc = GetDC(NULL);
  488. i = GetDeviceCaps(hdc, BITSPIXEL) * GetDeviceCaps(hdc, PLANES);
  489. ReleaseDC(NULL, hdc);
  490. i = GetProfileInt(szIni, szDEFAULTVIDEO,
  491. (i < 8 && (GetWinFlags() & WF_CPU286)) ? 240 : 0);
  492. if (i >= 200)
  493. dwOptions |= MCIAVIO_USEVGABYDEFAULT;
  494. ////if (GetProfileInt(szIni, szSEEKEXACT, 1))
  495. dwOptions |= MCIAVIO_SEEKEXACT;
  496. if (GetProfileInt(szIni, szZOOMBY2, 0))
  497. dwOptions |= MCIAVIO_ZOOMBY2;
  498. ////if (GetProfileInt(szIni, szFAILIFNOWAVE, 0))
  499. //// dwOptions |= MCIAVIO_FAILIFNOWAVE;
  500. // if (GetProfileInt(szIni, szSTUPIDMODE, 0))
  501. // dwOptions |= MCIAVIO_STUPIDMODE;
  502. if (GetProfileInt(szIni, szSKIPFRAMES, 1))
  503. dwOptions |= MCIAVIO_SKIPFRAMES;
  504. if (GetProfileInt(szIni, szUSEAVIFILE, 0))
  505. dwOptions |= MCIAVIO_USEAVIFILE;
  506. return dwOptions;
  507. }
  508. void FAR PASCAL WriteConfigInfo(DWORD dwOptions)
  509. {
  510. // !!! This shouldn't get written out if it is the default!
  511. WriteProfileString(szIni, szDEFAULTVIDEO,
  512. (dwOptions & MCIAVIO_USEVGABYDEFAULT) ? szVIDEO240 : szVIDEOWINDOW);
  513. ////WriteProfileString(szIni, szSEEKEXACT,
  514. //// (dwOptions & MCIAVIO_SEEKEXACT) ? sz1 : sz0);
  515. WriteProfileString(szIni, szZOOMBY2,
  516. (dwOptions & MCIAVIO_ZOOMBY2) ? sz1 : sz0);
  517. ////WriteProfileString(szIni, szFAILIFNOWAVE,
  518. //// (dwOptions & MCIAVIO_FAILIFNOWAVE) ? sz1 : sz0);
  519. // WriteProfileString(szIni, szSTUPIDMODE,
  520. // (dwOptions & MCIAVIO_STUPIDMODE) ? sz1 : sz0);
  521. WriteProfileString(szIni, szSKIPFRAMES,
  522. (dwOptions & MCIAVIO_SKIPFRAMES) ? sz1 : sz0);
  523. WriteProfileString(szIni, szUSEAVIFILE,
  524. (dwOptions & MCIAVIO_USEAVIFILE) ? sz1 : sz0);
  525. }
  526. BOOL FAR PASCAL ConfigDialog(HWND hwnd, NPMCIGRAPHIC npMCI)
  527. {
  528. #define MAX_WINDOWS 10
  529. HWND hwndActive[MAX_WINDOWS];
  530. BOOL f;
  531. int i;
  532. HWND hwndT;
  533. if (ghwndConfig) {
  534. MessageBeep(0);
  535. return FALSE;
  536. }
  537. if (hwnd == NULL)
  538. hwnd = GetActiveWindow();
  539. //
  540. // enum all the toplevel windows of this task and disable them!
  541. //
  542. for (hwndT = GetWindow(GetDesktopWindow(), GW_CHILD), i=0;
  543. hwndT && i < MAX_WINDOWS;
  544. hwndT = GetWindow(hwndT, GW_HWNDNEXT)) {
  545. if (IsWindowEnabled(hwndT) &&
  546. IsWindowVisible(hwndT) &&
  547. (HTASK)GetWindowTask(hwndT) == GetCurrentTask() &&
  548. hwndT != hwnd) { // don't disable our parent
  549. hwndActive[i++] = hwndT;
  550. EnableWindow(hwndT, FALSE);
  551. }
  552. }
  553. f = DialogBoxParam(ghModule, MAKEINTRESOURCE(IDA_CONFIG),
  554. hwnd, ConfigDlgProc, (DWORD)(UINT)npMCI);
  555. //
  556. // restore all windows
  557. //
  558. while (i-- > 0)
  559. EnableWindow(hwndActive[i], TRUE);
  560. if (hwnd)
  561. SetActiveWindow(hwnd);
  562. ghwndConfig = NULL;
  563. return f;
  564. }