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
21 KiB

  1. /*
  2. ***************************************************************
  3. * video.c
  4. *
  5. * Copyright (C) Microsoft, 1990, All Rights Reserved.
  6. *
  7. * Displays the Simple media properties
  8. *
  9. * History:
  10. *
  11. * July 1994 -by- VijR (Created)
  12. *
  13. ***************************************************************
  14. */
  15. #include "mmcpl.h"
  16. #include <windowsx.h>
  17. #ifdef DEBUG
  18. #undef DEBUG
  19. #include <mmsystem.h>
  20. #define DEBUG
  21. #else
  22. #include <mmsystem.h>
  23. #endif
  24. #include <commctrl.h>
  25. #include <prsht.h>
  26. #include "utils.h"
  27. #include "medhelp.h"
  28. #include "profile.key" // For ROOTKEY and KEYNAME etc
  29. #define Assert(f)
  30. /*
  31. ***************************************************************
  32. * Defines
  33. ***************************************************************
  34. */
  35. //
  36. // !!! These actually live in mciavi\graphic.h
  37. // !!! If MCIAVI changes these, we're hosed!
  38. //
  39. #define MCIAVIO_ZOOMBY2 0x00000100
  40. #define MCIAVIO_USEVGABYDEFAULT 0x00000200
  41. #define MCIAVIO_1QSCREENSIZE 0x00010000
  42. #define MCIAVIO_2QSCREENSIZE 0x00020000
  43. #define MCIAVIO_3QSCREENSIZE 0x00040000
  44. #define MCIAVIO_MAXWINDOWSIZE 0x00080000
  45. #define MCIAVIO_DEFWINDOWSIZE 0x00000000
  46. #define MCIAVIO_WINDOWSIZEMASK 0x000f0000
  47. // This bit is set in dwOptions if f16BitCompat, but doesn't get written back
  48. // directly into the registry's version of that DWORD.
  49. //
  50. #define MCIAVIO_F16BITCOMPAT 0x00000001
  51. /*
  52. ***************************************************************
  53. * File Globals
  54. ***************************************************************
  55. */
  56. static SZCODE aszMCIAVIOpt[] = TEXT("Software\\Microsoft\\Multimedia\\Video For Windows\\MCIAVI");
  57. static SZCODE aszDefVideoOpt[] = TEXT("DefaultOptions");
  58. static SZCODE aszReject[] = TEXT("RejectWOWOpenCalls");
  59. static SZCODE aszRejectSection[] = TEXT("MCIAVI");
  60. HBITMAP g_hbmMonitor = NULL; // monitor bitmap (original)
  61. HBITMAP g_hbmScrSample = NULL; // bitmap used for IDC_SCREENSAMPLE
  62. HBITMAP g_hbmDefault = NULL;
  63. HDC g_hdcMem = NULL;
  64. /*
  65. ***************************************************************
  66. * Prototypes
  67. ***************************************************************
  68. */
  69. BOOL PASCAL DoVideoCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify);
  70. /*
  71. ***************************************************************
  72. ***************************************************************
  73. */
  74. // mmGetProfileInt/mmWriteProfileInt snitched from MCIAVI32
  75. UINT
  76. mmGetProfileInt(LPCTSTR appname, LPCTSTR valuename, INT uDefault)
  77. {
  78. TCHAR achName[MAX_PATH];
  79. HKEY hkey;
  80. DWORD dwType;
  81. INT value = uDefault;
  82. DWORD dwData;
  83. int cbData;
  84. lstrcpy(achName, KEYNAME);
  85. if (appname)
  86. {
  87. if ((lstrlen(achName)+lstrlen(appname))<ARRAYSIZE(achName))
  88. {
  89. lstrcat(achName, appname);
  90. if (RegOpenKey(ROOTKEY, achName, &hkey) == ERROR_SUCCESS)
  91. {
  92. cbData = sizeof(dwData);
  93. if (RegQueryValueEx(
  94. hkey,
  95. (LPTSTR)valuename,
  96. NULL,
  97. &dwType,
  98. (PBYTE) &dwData,
  99. &cbData) == ERROR_SUCCESS)
  100. {
  101. if (dwType == REG_DWORD)
  102. {
  103. value = (INT)dwData;
  104. }
  105. }
  106. RegCloseKey(hkey);
  107. }
  108. }
  109. }
  110. return((UINT)value);
  111. }
  112. /*
  113. * write a UINT to the profile, if it is not the
  114. * same as the default or the value already there
  115. */
  116. VOID
  117. mmWriteProfileInt(LPCTSTR appname, LPCTSTR valuename, INT Value)
  118. {
  119. // If we would write the same as already there... return.
  120. if (mmGetProfileInt(appname, valuename, !Value) == (UINT)Value) {
  121. return;
  122. }
  123. {
  124. TCHAR achName[MAX_PATH];
  125. HKEY hkey = NULL;
  126. lstrcpy(achName, KEYNAME);
  127. lstrcat(achName, appname);
  128. if ((RegCreateKey (ROOTKEY, achName, &hkey) == ERROR_SUCCESS) && hkey)
  129. {
  130. RegSetValueEx(
  131. hkey,
  132. valuename,
  133. 0,
  134. REG_DWORD,
  135. (PBYTE) &Value,
  136. sizeof(Value)
  137. );
  138. RegCloseKey(hkey);
  139. }
  140. }
  141. }
  142. /*
  143. ***************************************************************
  144. ***************************************************************
  145. */
  146. STATIC void WriteVideoOptions(DWORD dwOpt)
  147. {
  148. HKEY hkVideoOpt;
  149. BOOL f16BitCompat;
  150. f16BitCompat = (dwOpt & MCIAVIO_F16BITCOMPAT) ? TRUE : FALSE;
  151. dwOpt &= ~MCIAVIO_F16BITCOMPAT;
  152. if(RegCreateKeyEx( HKEY_CURRENT_USER, (LPTSTR)aszMCIAVIOpt, 0, NULL, 0,KEY_WRITE | KEY_READ, NULL, &hkVideoOpt, NULL ))
  153. return;
  154. RegSetValueEx( hkVideoOpt, (LPTSTR)aszDefVideoOpt, 0, REG_DWORD,(LPBYTE)&dwOpt, sizeof(DWORD) );
  155. mmWriteProfileInt (aszRejectSection, aszReject, (int)f16BitCompat);
  156. RegCloseKey(hkVideoOpt);
  157. }
  158. STATIC DWORD ReadVideoOptions(void)
  159. {
  160. HKEY hkVideoOpt;
  161. DWORD dwType;
  162. DWORD dwOpt;
  163. DWORD cbSize;
  164. if(RegCreateKeyEx( HKEY_CURRENT_USER, (LPTSTR)aszMCIAVIOpt, 0, NULL, 0,KEY_WRITE | KEY_READ, NULL, &hkVideoOpt, NULL ))
  165. return 0 ;
  166. cbSize = sizeof(DWORD);
  167. if (RegQueryValueEx( hkVideoOpt,(LPTSTR)aszDefVideoOpt,NULL,&dwType,(LPBYTE)&dwOpt,&cbSize ))
  168. {
  169. dwOpt = 0;
  170. RegSetValueEx( hkVideoOpt, (LPTSTR)aszDefVideoOpt, 0, REG_DWORD,(LPBYTE)&dwOpt, sizeof(DWORD) );
  171. }
  172. if (mmGetProfileInt (aszRejectSection, aszReject, 0))
  173. {
  174. dwOpt |= MCIAVIO_F16BITCOMPAT;
  175. }
  176. RegCloseKey(hkVideoOpt);
  177. return dwOpt;
  178. }
  179. STATIC void FillWindowSizeCB(DWORD dwOptions, HWND hCBWinSize)
  180. {
  181. TCHAR sz1QScreenSize[64];
  182. TCHAR sz2QScreenSize[64];
  183. TCHAR sz3QScreenSize[64];
  184. TCHAR szMaxSize[64];
  185. TCHAR szOriginalSize[64];
  186. TCHAR szZoomedSize[64];
  187. int iIndex;
  188. LPTSTR lpszCurDefSize;
  189. LoadString(ghInstance, IDS_NORMALSIZE, szOriginalSize, sizeof(szOriginalSize)/sizeof(TCHAR));
  190. LoadString(ghInstance, IDS_ZOOMEDSIZE, szZoomedSize, sizeof(szZoomedSize)/sizeof(TCHAR));
  191. LoadString(ghInstance, IDS_1QSCREENSIZE, sz1QScreenSize, sizeof(sz1QScreenSize)/sizeof(TCHAR));
  192. LoadString(ghInstance, IDS_2QSCREENSIZE, sz2QScreenSize, sizeof(sz2QScreenSize)/sizeof(TCHAR));
  193. LoadString(ghInstance, IDS_3QSCREENSIZE, sz3QScreenSize, sizeof(sz3QScreenSize)/sizeof(TCHAR));
  194. LoadString(ghInstance, IDS_VIDEOMAXIMIZED, szMaxSize, sizeof(szMaxSize)/sizeof(TCHAR));
  195. iIndex = ComboBox_AddString(hCBWinSize, szOriginalSize);
  196. ComboBox_SetItemData(hCBWinSize, iIndex, (LPARAM)MCIAVIO_DEFWINDOWSIZE);
  197. iIndex = ComboBox_AddString(hCBWinSize, szZoomedSize);
  198. ComboBox_SetItemData(hCBWinSize, iIndex, (LPARAM)MCIAVIO_ZOOMBY2);
  199. iIndex = ComboBox_AddString(hCBWinSize, sz1QScreenSize);
  200. ComboBox_SetItemData(hCBWinSize, iIndex, (LPARAM)MCIAVIO_1QSCREENSIZE);
  201. iIndex = ComboBox_AddString(hCBWinSize, sz2QScreenSize);
  202. ComboBox_SetItemData(hCBWinSize, iIndex, (LPARAM)MCIAVIO_2QSCREENSIZE);
  203. iIndex = ComboBox_AddString(hCBWinSize, sz3QScreenSize);
  204. ComboBox_SetItemData(hCBWinSize, iIndex, (LPARAM)MCIAVIO_3QSCREENSIZE);
  205. iIndex = ComboBox_AddString(hCBWinSize, szMaxSize);
  206. ComboBox_SetItemData(hCBWinSize, iIndex, (LPARAM)MCIAVIO_MAXWINDOWSIZE);
  207. switch(dwOptions & MCIAVIO_WINDOWSIZEMASK)
  208. {
  209. case MCIAVIO_DEFWINDOWSIZE:
  210. if (dwOptions & MCIAVIO_ZOOMBY2)
  211. lpszCurDefSize = szZoomedSize;
  212. else
  213. lpszCurDefSize = szOriginalSize;
  214. break;
  215. case MCIAVIO_1QSCREENSIZE:
  216. lpszCurDefSize = sz1QScreenSize;
  217. break;
  218. case MCIAVIO_2QSCREENSIZE:
  219. lpszCurDefSize = sz2QScreenSize;
  220. break;
  221. case MCIAVIO_3QSCREENSIZE:
  222. lpszCurDefSize = sz3QScreenSize;
  223. break;
  224. case MCIAVIO_MAXWINDOWSIZE:
  225. lpszCurDefSize = szMaxSize;
  226. break;
  227. }
  228. //
  229. // We should select string that matches exactly.
  230. //
  231. iIndex = ComboBox_FindStringExact(hCBWinSize, 0, lpszCurDefSize);
  232. ComboBox_SetCurSel(hCBWinSize, iIndex);
  233. }
  234. /*---------------------------------------------------------
  235. **
  236. **---------------------------------------------------------*/
  237. // information about the monitor bitmap
  238. // x, y, dx, dy define the size of the "screen" part of the bitmap
  239. // the RGB is the color of the screen's desktop
  240. // these numbers are VERY hard-coded to a monitor bitmap
  241. #define MON_X 16
  242. #define MON_Y 17
  243. #define MON_DX 152
  244. #define MON_DY 112
  245. #define MON_IMAGE_X (MON_X + 46)
  246. #define MON_IMAGE_Y (MON_Y + 33)
  247. #define MON_IMAGE_DX 59
  248. #define MON_IMAGE_DY 44
  249. #define MON_TITLE 10
  250. #define MON_BORDER 2
  251. #define MON_TRAY 8
  252. STATIC HBITMAP FAR LoadMonitorBitmap( BOOL bFillDesktop )
  253. {
  254. HBITMAP hbm;
  255. hbm = (HBITMAP) LoadImage(ghInstance,MAKEINTATOM(IDB_MONITOR), IMAGE_BITMAP, 0, 0, LR_LOADMAP3DCOLORS);
  256. Assert(hbm);
  257. return hbm;
  258. }
  259. /*------------------------pixel resolution---------------------------
  260. **
  261. ** show the sample screen with proper sizing
  262. */
  263. STATIC void NEAR PASCAL ShowSampleScreen(HWND hDlg, int iMCIWindowSize)
  264. {
  265. HBITMAP hbmOld;
  266. HBRUSH hbr;
  267. HDC hdcMem2;
  268. SIZE dSrc = {MON_IMAGE_DX, MON_IMAGE_DY};
  269. POINT ptSrc = {MON_IMAGE_X, MON_IMAGE_Y};
  270. SIZE dDst;
  271. POINT ptDst;
  272. RECT rcImage = {MON_IMAGE_X, MON_IMAGE_Y, MON_IMAGE_X + MON_IMAGE_DX, MON_IMAGE_Y + MON_IMAGE_DY};
  273. if (!g_hbmMonitor || !g_hbmScrSample)
  274. return;
  275. switch(iMCIWindowSize)
  276. {
  277. case MCIAVIO_DEFWINDOWSIZE:
  278. dDst = dSrc;
  279. ptDst = ptSrc;
  280. break;
  281. case MCIAVIO_ZOOMBY2:
  282. dDst.cx = 2 * dSrc.cx;
  283. dDst.cy = 2 * dSrc.cy;
  284. ptDst.x = ptSrc.x - (int)(dSrc.cx/2);
  285. ptDst.y = ptSrc.y - (int)(dSrc.cy/2);
  286. break;
  287. case MCIAVIO_MAXWINDOWSIZE:
  288. ptDst.x = MON_X;
  289. ptDst.y = MON_Y;
  290. dDst.cx = MON_DX;
  291. dDst.cy = MON_DY - MON_TRAY;
  292. break;
  293. case MCIAVIO_1QSCREENSIZE:
  294. dDst.cx = MulDiv(MON_DX, 1, 4);
  295. dDst.cy = MulDiv(MON_DY, 1, 4);
  296. ptDst.x = MON_X + MulDiv((MON_DX - dDst.cx), 1 , 2);
  297. ptDst.y = MON_Y + MulDiv((MON_DY - dDst.cy - MON_TRAY), 1 , 2);
  298. break;
  299. case MCIAVIO_2QSCREENSIZE:
  300. dDst.cx = MulDiv(MON_DX, 1, 2);
  301. dDst.cy = MulDiv(MON_DY, 1, 2);
  302. ptDst.x = MON_X + MulDiv((MON_DX - dDst.cx), 1 , 2);
  303. ptDst.y = MON_Y + MulDiv((MON_DY - dDst.cy - MON_TRAY), 1 , 2);
  304. break;
  305. case MCIAVIO_3QSCREENSIZE:
  306. dDst.cx = MulDiv(MON_DX, 3, 4);
  307. dDst.cy = MulDiv(MON_DY, 3, 4);
  308. ptDst.x = MON_X + MulDiv((MON_DX - dDst.cx), 1 , 2);
  309. ptDst.y = MON_Y + MulDiv((MON_DY - dDst.cy - MON_TRAY), 1 , 2);
  310. break;
  311. case MCIAVIO_USEVGABYDEFAULT:
  312. dDst.cx = MON_DX;
  313. dDst.cy = MON_DY;
  314. ptDst.x = MON_X;
  315. ptDst.y = MON_Y;
  316. dSrc.cx = MON_IMAGE_DX - (2 * MON_BORDER);
  317. dSrc.cy = MON_IMAGE_DY - MON_TITLE - MON_BORDER;
  318. ptSrc.x = MON_IMAGE_X + MON_BORDER;
  319. ptSrc.y = MON_IMAGE_Y + MON_TITLE + MON_BORDER;
  320. break;
  321. }
  322. // set up a work area to play in
  323. hdcMem2 = CreateCompatibleDC(g_hdcMem);
  324. if (!hdcMem2)
  325. return;
  326. SelectObject(hdcMem2, g_hbmScrSample);
  327. hbmOld = SelectObject(g_hdcMem, g_hbmMonitor);
  328. //copy the whole bmp first and then start stretching
  329. BitBlt(hdcMem2, MON_X, MON_Y, MON_DX, MON_DY, g_hdcMem, MON_X, MON_Y, SRCCOPY);
  330. //Wipe out the existing Image
  331. hbr = CreateSolidBrush( GetPixel( g_hdcMem, MON_X + 1, MON_Y + 1 ) );
  332. if (!hbr)
  333. {
  334. DeleteObject( hdcMem2 );
  335. return;
  336. }
  337. FillRect(hdcMem2, &rcImage, hbr);
  338. DeleteObject( hbr );
  339. // stretch the image to reflect the new size
  340. SetStretchBltMode( hdcMem2, COLORONCOLOR );
  341. StretchBlt( hdcMem2, ptDst.x, ptDst.y, dDst.cx, dDst.cy,
  342. g_hdcMem, ptSrc.x, ptSrc.y, dSrc.cx, dSrc.cy, SRCCOPY );
  343. SelectObject( hdcMem2, g_hbmDefault );
  344. DeleteObject( hdcMem2 );
  345. SelectObject( g_hdcMem, hbmOld );
  346. InvalidateRect(GetDlgItem(hDlg, IDC_SCREENSAMPLE), NULL, FALSE);
  347. }
  348. STATIC void DoMonitorBmp(HWND hDlg)
  349. {
  350. HDC hdc = GetDC(NULL);
  351. HBITMAP hbm;
  352. g_hdcMem = CreateCompatibleDC(hdc);
  353. ReleaseDC(NULL, hdc);
  354. if (!g_hdcMem)
  355. return;
  356. hbm = CreateBitmap(1,1,1,1,NULL);
  357. if (!hbm) return;
  358. g_hbmDefault = SelectObject(g_hdcMem, hbm);
  359. SelectObject(g_hdcMem, g_hbmDefault);
  360. DeleteObject(hbm);
  361. // set up bitmaps for sample screen
  362. g_hbmScrSample = LoadMonitorBitmap( TRUE ); // let them do the desktop
  363. SendDlgItemMessage(hDlg, IDC_SCREENSAMPLE, STM_SETIMAGE, IMAGE_BITMAP, (DWORD_PTR)g_hbmScrSample);
  364. // get a base copy of the bitmap for when the "internals" change
  365. g_hbmMonitor = LoadMonitorBitmap( FALSE ); // we'll do the desktop
  366. }
  367. const static DWORD aAdvVideoDlgHelpIds[] = { // Context Help IDs
  368. (DWORD)IDC_STATIC, IDH_VIDEO_ADVANCED_COMPAT,
  369. ID_ADVVIDEO_COMPAT, IDH_VIDEO_ADVANCED_COMPAT,
  370. 0, 0
  371. };
  372. INT_PTR AdvancedVideoDlgProc (HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lParam)
  373. {
  374. static BOOL *pfCompat = NULL;
  375. switch (wMsg)
  376. {
  377. case WM_INITDIALOG:
  378. {
  379. if ((pfCompat = (BOOL *)lParam) == NULL)
  380. return -1;
  381. CheckDlgButton (hDlg, ID_ADVVIDEO_COMPAT, (*pfCompat));
  382. break;
  383. }
  384. case WM_COMMAND:
  385. {
  386. switch (GET_WM_COMMAND_ID(wParam, lParam))
  387. {
  388. case IDOK:
  389. *pfCompat = IsDlgButtonChecked (hDlg, ID_ADVVIDEO_COMPAT);
  390. // fall through
  391. case IDCANCEL:
  392. EndDialog (hDlg, GET_WM_COMMAND_ID(wParam, lParam));
  393. break;
  394. }
  395. break;
  396. }
  397. case WM_CONTEXTMENU:
  398. {
  399. WinHelp ((HWND)wParam, NULL, HELP_CONTEXTMENU,
  400. (UINT_PTR)aAdvVideoDlgHelpIds);
  401. return TRUE;
  402. }
  403. case WM_HELP:
  404. {
  405. WinHelp (((LPHELPINFO)lParam)->hItemHandle, NULL,
  406. HELP_WM_HELP, (UINT_PTR)aAdvVideoDlgHelpIds);
  407. return TRUE;
  408. }
  409. }
  410. return FALSE;
  411. }
  412. const static DWORD aVideoDlgHelpIds[] = { // Context Help IDs
  413. IDC_GROUPBOX, IDH_COMM_GROUPBOX,
  414. IDC_SCREENSAMPLE, IDH_VIDEO_GRAPHIC,
  415. IDC_VIDEO_FULLSCREEN, IDH_VIDEO_FULL_SCREEN,
  416. IDC_VIDEO_INWINDOW, IDH_VIDEO_FIXED_WINDOW,
  417. IDC_VIDEO_CB_SIZE, IDH_VIDEO_FIXED_WINDOW,
  418. ID_VIDEO_ADVANCED, IDH_VIDEO_ADVANCED_BUTTON,
  419. 0, 0
  420. };
  421. BOOL CALLBACK VideoDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  422. {
  423. NMHDR FAR *lpnm;
  424. switch (uMsg)
  425. {
  426. case WM_NOTIFY:
  427. lpnm = (NMHDR FAR *)lParam;
  428. switch(lpnm->code)
  429. {
  430. case PSN_KILLACTIVE:
  431. FORWARD_WM_COMMAND(hDlg, IDOK, 0, 0, SendMessage);
  432. break;
  433. case PSN_APPLY:
  434. FORWARD_WM_COMMAND(hDlg, ID_APPLY, 0, 0, SendMessage);
  435. break;
  436. case PSN_SETACTIVE:
  437. FORWARD_WM_COMMAND(hDlg, ID_INIT, 0, 0, SendMessage);
  438. break;
  439. case PSN_RESET:
  440. FORWARD_WM_COMMAND(hDlg, IDCANCEL, 0, 0, SendMessage);
  441. break;
  442. }
  443. break;
  444. case WM_INITDIALOG:
  445. {
  446. DWORD dwOptions;
  447. dwOptions = ReadVideoOptions();
  448. FillWindowSizeCB(dwOptions, GetDlgItem(hDlg, IDC_VIDEO_CB_SIZE));
  449. SetWindowLongPtr(hDlg, DWLP_USER, (LPARAM)dwOptions);
  450. DoMonitorBmp(hDlg);
  451. if (IsFlagSet(dwOptions, MCIAVIO_USEVGABYDEFAULT))
  452. {
  453. CheckRadioButton(hDlg, IDC_VIDEO_INWINDOW, IDC_VIDEO_FULLSCREEN, IDC_VIDEO_FULLSCREEN);
  454. EnableWindow(GetDlgItem(hDlg, IDC_VIDEO_CB_SIZE), FALSE);
  455. ShowSampleScreen(hDlg, MCIAVIO_USEVGABYDEFAULT);
  456. break;
  457. }
  458. else
  459. {
  460. CheckRadioButton(hDlg, IDC_VIDEO_INWINDOW, IDC_VIDEO_FULLSCREEN, IDC_VIDEO_INWINDOW);
  461. EnableWindow(GetDlgItem(hDlg, IDC_VIDEO_CB_SIZE), TRUE);
  462. }
  463. ShowSampleScreen(hDlg, dwOptions & (MCIAVIO_WINDOWSIZEMASK|MCIAVIO_ZOOMBY2));
  464. break;
  465. }
  466. case WM_DESTROY:
  467. if (g_hbmScrSample)
  468. {
  469. DeleteObject(g_hbmScrSample);
  470. g_hbmScrSample = NULL;
  471. }
  472. if (g_hbmMonitor)
  473. {
  474. DeleteObject(g_hbmMonitor);
  475. g_hbmMonitor = NULL;
  476. }
  477. if (g_hbmDefault)
  478. {
  479. DeleteObject(g_hbmDefault);
  480. g_hbmDefault = NULL;
  481. }
  482. if (g_hdcMem)
  483. {
  484. DeleteDC(g_hdcMem);
  485. g_hdcMem = NULL;
  486. }
  487. break;
  488. case WM_DROPFILES:
  489. break;
  490. case WM_CONTEXTMENU:
  491. WinHelp ((HWND) wParam, NULL, HELP_CONTEXTMENU,
  492. (UINT_PTR) (LPTSTR) aVideoDlgHelpIds);
  493. return TRUE;
  494. case WM_HELP:
  495. {
  496. LPHELPINFO lphi = (LPVOID) lParam;
  497. WinHelp (lphi->hItemHandle, NULL, HELP_WM_HELP,
  498. (UINT_PTR) (LPTSTR) aVideoDlgHelpIds);
  499. return TRUE;
  500. }
  501. case WM_COMMAND:
  502. HANDLE_WM_COMMAND(hDlg, wParam, lParam, DoVideoCommand);
  503. break;
  504. }
  505. return FALSE;
  506. }
  507. BOOL PASCAL DoVideoCommand(HWND hDlg, int id, HWND hwndCtl, UINT codeNotify)
  508. {
  509. switch (id)
  510. {
  511. case ID_APPLY:
  512. {
  513. int iIndex;
  514. HWND hCBWinSize = GetDlgItem(hDlg,IDC_VIDEO_CB_SIZE);
  515. DWORD dwOldOpt;
  516. DWORD dwNewOpt;
  517. dwOldOpt = (DWORD)GetWindowLongPtr(hDlg, DWLP_USER);
  518. if(Button_GetCheck(GetDlgItem(hDlg, IDC_VIDEO_FULLSCREEN)))
  519. {
  520. dwNewOpt = MCIAVIO_USEVGABYDEFAULT;
  521. }
  522. else
  523. {
  524. iIndex = ComboBox_GetCurSel(hCBWinSize);
  525. dwNewOpt = (DWORD)ComboBox_GetItemData(hCBWinSize, iIndex);
  526. }
  527. ClearFlag(dwOldOpt,MCIAVIO_WINDOWSIZEMASK|MCIAVIO_USEVGABYDEFAULT|MCIAVIO_ZOOMBY2);
  528. SetFlag(dwOldOpt, dwNewOpt);
  529. WriteVideoOptions(dwOldOpt);
  530. SetWindowLongPtr(hDlg, DWLP_USER, (LPARAM)dwOldOpt);
  531. return TRUE;
  532. }
  533. case IDOK:
  534. break;
  535. case IDCANCEL:
  536. break;
  537. case IDC_VIDEO_FULLSCREEN:
  538. EnableWindow(GetDlgItem(hDlg, IDC_VIDEO_CB_SIZE), FALSE);
  539. PropSheet_Changed(GetParent(hDlg),hDlg);
  540. ShowSampleScreen(hDlg, MCIAVIO_USEVGABYDEFAULT);
  541. break;
  542. case IDC_VIDEO_INWINDOW:
  543. {
  544. HWND hwndCB = GetDlgItem(hDlg,IDC_VIDEO_CB_SIZE);
  545. int iIndex = ComboBox_GetCurSel(hwndCB);
  546. int iOpt = (int)ComboBox_GetItemData(hwndCB, iIndex);
  547. EnableWindow(GetDlgItem(hDlg, IDC_VIDEO_CB_SIZE), TRUE);
  548. PropSheet_Changed(GetParent(hDlg),hDlg);
  549. ShowSampleScreen(hDlg, iOpt);
  550. break;
  551. }
  552. case IDC_VIDEO_CB_SIZE:
  553. switch (codeNotify)
  554. {
  555. case CBN_SELCHANGE:
  556. {
  557. int iIndex = ComboBox_GetCurSel(hwndCtl);
  558. int iOpt = (int)ComboBox_GetItemData(hwndCtl, iIndex);
  559. PropSheet_Changed(GetParent(hDlg),hDlg);
  560. ShowSampleScreen(hDlg, iOpt);
  561. break;
  562. }
  563. default:
  564. break;
  565. }
  566. break;
  567. case ID_VIDEO_ADVANCED:
  568. {
  569. INT_PTR f16BitCompat;
  570. f16BitCompat = (GetWindowLongPtr(hDlg, DWLP_USER) & MCIAVIO_F16BITCOMPAT);
  571. if (DialogBoxParam (ghInstance,
  572. MAKEINTRESOURCE(ADVVIDEODLG),
  573. hDlg,
  574. AdvancedVideoDlgProc,
  575. (LPARAM)&f16BitCompat) == IDOK)
  576. {
  577. SetWindowLongPtr (hDlg, DWLP_USER,
  578. GetWindowLongPtr (hDlg, DWLP_USER)
  579. & (~MCIAVIO_F16BITCOMPAT)
  580. | ((f16BitCompat) ? (MCIAVIO_F16BITCOMPAT) : 0));
  581. PropSheet_Changed(GetParent(hDlg),hDlg);
  582. }
  583. break;
  584. }
  585. case ID_INIT:
  586. break;
  587. }
  588. return FALSE;
  589. }