Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

671 lines
25 KiB

  1. /*--------------------------------------------------------------------------*\
  2. | qmci.c - Quick MDI App |
  3. | |
  4. | Usage: |
  5. | To make a quick MDI windows application, modify this source |
  6. | |
  7. | History: |
  8. | 12/15/87 toddla Created |
  9. | |
  10. \*-------------------------------------------------------------------------*/
  11. #include <windows.h>
  12. #include <commdlg.h>
  13. #include "movplay.h"
  14. #include "mciwnd.h"
  15. #include "preview.h" //!!! in mciwnd.h???
  16. typedef LONG (FAR PASCAL *LPWNDPROC)(); // pointer to a window procedure
  17. /*-------------------------------------------------------------------------*\
  18. | |
  19. | g l o b a l v a r i a b l e s |
  20. | |
  21. \*------------------------------------------------------------------------*/
  22. // We have our own copy of the MCIWND.LIB so we better make our own class
  23. // names or we'll conflict and blow up!
  24. extern char aszMCIWndClassName[];
  25. extern char aszToolbarClassName[];
  26. extern char aszTrackbarClassName[];
  27. char szAppName[] = "MovPlay"; /* change this to your app's name */
  28. char szOpenFilter[] = "Video Files\0*.avi\0"
  29. "Wave Files\0*.wav\0"
  30. "Midi Files\0*.mid; *.rmi\0"
  31. "All Files\0*.*\0";
  32. HANDLE hInstApp; /* Instance handle */
  33. HACCEL hAccelApp;
  34. HWND hwndApp; /* Handle to parent window */
  35. HWND hwndMdi; /* Handle to MCI client window */
  36. OFSTRUCT of;
  37. OPENFILENAME ofn;
  38. char achFileName[128];
  39. /*----------------------------------------------------------------------------*\
  40. \*----------------------------------------------------------------------------*/
  41. long FAR PASCAL _export AppWndProc(HWND, UINT, WPARAM, LPARAM);
  42. long FAR PASCAL _export mdiDocWndProc(HWND, unsigned, WORD, LONG);
  43. int ErrMsg (LPSTR sz,...);
  44. HWND mdiCreateDoc(LPSTR szClass, LPSTR szTitle, LPARAM l);
  45. /*----------------------------------------------------------------------------*\
  46. | AppAbout( hDlg, msg, wParam, lParam ) |
  47. | |
  48. | Description: |
  49. | This function handles messages belonging to the "About" dialog box. |
  50. | The only message that it looks for is WM_COMMAND, indicating the use |
  51. | has pressed the "OK" button. When this happens, it takes down |
  52. | the dialog box. |
  53. | |
  54. | Arguments: |
  55. | hDlg window handle of about dialog window |
  56. | msg message number |
  57. | wParam message-dependent |
  58. | lParam message-dependent |
  59. | |
  60. | Returns: |
  61. | TRUE if message has been processed, else FALSE |
  62. | |
  63. \*----------------------------------------------------------------------------*/
  64. BOOL FAR PASCAL _export AppAbout(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  65. {
  66. switch (msg) {
  67. case WM_COMMAND:
  68. EndDialog(hwnd,TRUE);
  69. return TRUE;
  70. case WM_INITDIALOG:
  71. return TRUE;
  72. }
  73. return FALSE;
  74. }
  75. /*----------------------------------------------------------------------------*\
  76. | AppInit ( hInstance, hPrevInstance ) |
  77. | |
  78. | Description: |
  79. | This is called when the application is first loaded into |
  80. | memory. It performs all initialization that doesn't need to be done |
  81. | once per instance. |
  82. | |
  83. | Arguments: |
  84. | hPrevInstance instance handle of previous instance |
  85. | hInstance instance handle of current instance |
  86. | |
  87. | Returns: |
  88. | TRUE if successful, FALSE if not |
  89. | |
  90. \*----------------------------------------------------------------------------*/
  91. BOOL AppInit(HANDLE hInst, HANDLE hPrev, LPSTR szCmd, int sw)
  92. {
  93. WNDCLASS cls;
  94. /* Save instance handle for DialogBox */
  95. hInstApp = hInst;
  96. hAccelApp = LoadAccelerators(hInstApp, "AppAccel");
  97. if (!hPrev) {
  98. cls.hCursor = LoadCursor(NULL,IDC_ARROW);
  99. cls.hIcon = LoadIcon(hInst,"AppIcon");
  100. cls.lpszMenuName = "AppMenu";
  101. cls.lpszClassName = szAppName;
  102. cls.hbrBackground = (HBRUSH)COLOR_APPWORKSPACE+1;
  103. cls.hInstance = hInst;
  104. cls.style = 0;
  105. cls.lpfnWndProc = (WNDPROC)AppWndProc;
  106. cls.cbClsExtra = 0;
  107. cls.cbWndExtra = 0;
  108. if (!RegisterClass(&cls))
  109. return FALSE;
  110. }
  111. // This app has its own copy of the MCIWnd stuff, and doesn't use
  112. // the copy found in MSVIDEO.DLL We better also have different
  113. // class names or else we'll conflict and blow up.
  114. // !!! Warning - The variable is not too long!
  115. lstrcpy(aszMCIWndClassName, "MCIWndMov");
  116. lstrcpy(aszTrackbarClassName, "TrackMov");
  117. lstrcpy(aszToolbarClassName, "ToolMov");
  118. MCIWndRegisterClass();
  119. hwndApp =
  120. #ifdef BIDI
  121. CreateWindowEx(WS_EX_BIDI_SCROLL | WS_EX_BIDI_MENU |WS_EX_BIDI_NOICON,
  122. #else
  123. CreateWindow (
  124. #endif
  125. szAppName,szAppName,
  126. WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
  127. CW_USEDEFAULT,0,
  128. CW_USEDEFAULT,0,
  129. (HWND)NULL, /* no parent */
  130. (HMENU)NULL, /* use class menu */
  131. (HANDLE)hInst, /* handle to window instance */
  132. (LPSTR)NULL /* no params to pass on */
  133. );
  134. /* Make window visible according to the way the app is activated */
  135. ShowWindow(hwndApp,sw);
  136. if (szCmd && szCmd[0])
  137. mdiCreateDoc(aszMCIWndClassName, 0, (LPARAM)(LPSTR)szCmd);
  138. return TRUE;
  139. }
  140. /*----------------------------------------------------------------------------*\
  141. | WinMain( hInstance, hPrevInstance, lpszCmdLine, cmdShow ) |
  142. | |
  143. | Description: |
  144. | The main procedure for the App. After initializing, it just goes |
  145. | into a message-processing loop until it gets a WM_QUIT message |
  146. | (meaning the app was closed). |
  147. | |
  148. | Arguments: |
  149. | hInstance instance handle of this instance of the app |
  150. | hPrevInstance instance handle of previous instance, NULL if first |
  151. | lpszCmdLine ->null-terminated command line |
  152. | cmdShow specifies how the window is initially displayed |
  153. | |
  154. | Returns: |
  155. | The exit code as specified in the WM_QUIT message. |
  156. | |
  157. \*----------------------------------------------------------------------------*/
  158. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int sw)
  159. {
  160. MSG msg;
  161. if (!AppInit(hInstance,hPrevInstance,szCmdLine,sw))
  162. return FALSE;
  163. /*
  164. * Polling messages from event queue
  165. */
  166. for (;;)
  167. {
  168. if (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE))
  169. {
  170. if (msg.message == WM_QUIT)
  171. break;
  172. if (hAccelApp && hwndApp &&
  173. TranslateAccelerator(hwndApp, hAccelApp, &msg))
  174. continue;
  175. TranslateMessage(&msg);
  176. DispatchMessage(&msg);
  177. }
  178. else
  179. {
  180. // idle time here, DONT BE A PIG!
  181. WaitMessage();
  182. }
  183. }
  184. return msg.wParam;
  185. }
  186. /*----------------------------------------------------------------------------*\
  187. \*----------------------------------------------------------------------------*/
  188. BOOL fDialog(HWND hwnd,int id,FARPROC fpfn)
  189. {
  190. BOOL f;
  191. HANDLE hInst;
  192. hInst = (HINSTANCE)GetWindowWord(hwnd,GWW_HINSTANCE);
  193. fpfn = MakeProcInstance(fpfn,hInst);
  194. f = DialogBox(hInst,MAKEINTRESOURCE(id),hwnd,(DLGPROC)fpfn);
  195. FreeProcInstance (fpfn);
  196. return f;
  197. }
  198. /*----------------------------------------------------------------------------*\
  199. \*----------------------------------------------------------------------------*/
  200. #define mdiGetCreateParam(lParam) \
  201. (((LPMDICREATESTRUCT)(((LPCREATESTRUCT)lParam)->lpCreateParams))->lParam)
  202. /*----------------------------------------------------------------------------*\
  203. | mdiCreateChild() |
  204. | |
  205. | Description: |
  206. | |
  207. | Arguments: |
  208. | |
  209. | Returns: |
  210. | HWND if successful, NULL otherwise |
  211. | |
  212. \*----------------------------------------------------------------------------*/
  213. HWND mdiCreateChild(
  214. HWND hwndMdi,
  215. LPSTR szClass,
  216. LPSTR szTitle,
  217. DWORD dwStyle,
  218. int x,
  219. int y,
  220. int dx,
  221. int dy,
  222. WORD sw,
  223. HMENU hmenu,
  224. LPARAM l)
  225. {
  226. MDICREATESTRUCT mdics;
  227. mdics.szClass = szClass;
  228. mdics.szTitle = szTitle;
  229. mdics.hOwner = (HINSTANCE)GetWindowWord(hwndMdi, GWW_HINSTANCE);
  230. mdics.x = x;
  231. mdics.y = y;
  232. mdics.cx = dx;
  233. mdics.cy = dy;
  234. mdics.style = dwStyle;
  235. mdics.lParam = l;
  236. return (HWND)SendMessage(hwndMdi,WM_MDICREATE,0,(LONG)(LPVOID)&mdics);
  237. }
  238. /*----------------------------------------------------------------------------*\
  239. \*----------------------------------------------------------------------------*/
  240. HWND mdiCreateDoc(LPSTR szClass, LPSTR szTitle, LPARAM l)
  241. {
  242. return mdiCreateChild(hwndMdi,szClass,szTitle,
  243. WS_CLIPCHILDREN | WS_CLIPSIBLINGS | MCIWNDF_SHOWALL,
  244. CW_USEDEFAULT,0,CW_USEDEFAULT,0,SW_NORMAL,NULL,l);
  245. }
  246. /*----------------------------------------------------------------------------*\
  247. | mdiCreateClient() |
  248. | |
  249. | Description: |
  250. | |
  251. | Arguments: |
  252. | |
  253. | Returns: |
  254. | HWND if successful, NULL otherwise |
  255. | |
  256. \*----------------------------------------------------------------------------*/
  257. HWND FAR PASCAL mdiCreateClient(HWND hwndP, HMENU hmenuWindow)
  258. {
  259. CLIENTCREATESTRUCT ccs;
  260. ccs.hWindowMenu = hmenuWindow;
  261. ccs.idFirstChild = 100;
  262. return
  263. #ifdef BIDI
  264. CreateWindowEx(WS_EX_BIDI_SCROLL | WS_EX_BIDI_MENU |WS_EX_BIDI_NOICON,
  265. #else
  266. CreateWindow (
  267. #endif
  268. "MDICLIENT",NULL,
  269. WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE,
  270. 0,0,0,0,
  271. hwndP, 0, (HINSTANCE)GetWindowWord(hwndP,GWW_HINSTANCE),
  272. (LPVOID)&ccs);
  273. }
  274. /*----------------------------------------------------------------------------*\
  275. \*----------------------------------------------------------------------------*/
  276. #define mdiActiveDoc() \
  277. (HWND)SendMessage(hwndMdi,WM_MDIGETACTIVE,0,0L)
  278. /*----------------------------------------------------------------------------*\
  279. \*----------------------------------------------------------------------------*/
  280. LONG NEAR PASCAL mdiSendMessage(HWND hwndMdi, HWND hwnd, unsigned msg, WORD wParam, LONG lParam)
  281. {
  282. if (hwnd == (HWND)-1)
  283. {
  284. for (hwnd = GetWindow(hwndMdi, GW_CHILD); hwnd; hwnd = GetWindow(hwnd, GW_HWNDNEXT))
  285. SendMessage(hwnd, msg, wParam, lParam);
  286. return 0L;
  287. }
  288. else
  289. {
  290. if (hwnd == NULL)
  291. hwnd = (HWND)SendMessage(hwndMdi,WM_MDIGETACTIVE,0,0L);
  292. if (hwnd)
  293. return SendMessage(hwnd, msg, wParam, lParam);
  294. }
  295. }
  296. /*----------------------------------------------------------------------------*\
  297. | AppWndProc( hwnd, msg, wParam, lParam ) |
  298. | |
  299. | Description: |
  300. | The window proc for the app's main (tiled) window. This processes all |
  301. | of the parent window's messages. |
  302. | |
  303. | Arguments: |
  304. | hwnd window handle for the parent window |
  305. | msg message number |
  306. | wParam message-dependent |
  307. | lParam message-dependent |
  308. | |
  309. | Returns: |
  310. | 0 if processed, nonzero if ignored |
  311. | |
  312. \*----------------------------------------------------------------------------*/
  313. long FAR PASCAL _export AppWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
  314. {
  315. UINT f;
  316. PAINTSTRUCT ps;
  317. HDC hdc;
  318. HMENU hmenu;
  319. HWND hwndMovie;
  320. switch (msg) {
  321. case WM_COMMAND:
  322. hwndMovie = mdiActiveDoc();
  323. switch(wParam) {
  324. case MENU_ABOUT:
  325. fDialog(hwnd,ABOUTBOX,(FARPROC)AppAbout);
  326. break;
  327. case MENU_EXIT:
  328. PostMessage(hwnd,WM_CLOSE,0,0L);
  329. break;
  330. case MENU_CLOSE:
  331. //PostMessage(hwndMdi, WM_MDIDESTROY, (WPARAM)hwndMovie, 0);
  332. PostMessage(hwndMovie, WM_CLOSE, 0, 0L);
  333. break;
  334. case MENU_CLOSEALL:
  335. mdiSendMessage(hwndMdi,(HWND)-1,WM_CLOSE,0,0);
  336. break;
  337. case MENU_NEW:
  338. mdiCreateDoc(aszMCIWndClassName, "Untitled", 0);
  339. break;
  340. case MENU_OPEN:
  341. /* prompt user for file to open */
  342. ofn.lStructSize = sizeof(OPENFILENAME);
  343. ofn.hwndOwner = hwnd;
  344. ofn.hInstance = NULL;
  345. ofn.lpstrFilter = szOpenFilter;
  346. ofn.lpstrCustomFilter = NULL;
  347. ofn.nMaxCustFilter = 0;
  348. ofn.nFilterIndex = 0;
  349. ofn.lpstrFile = achFileName;
  350. ofn.nMaxFile = sizeof(achFileName);
  351. ofn.lpstrFileTitle = NULL;
  352. ofn.nMaxFileTitle = 0;
  353. ofn.lpstrInitialDir = NULL;
  354. ofn.lpstrTitle = "Open";
  355. ofn.Flags =
  356. #ifdef BIDI
  357. OFN_BIDIDIALOG |
  358. #endif
  359. OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;
  360. ofn.nFileOffset = 0;
  361. ofn.nFileExtension = 0;
  362. ofn.lpstrDefExt = NULL;
  363. ofn.lCustData = 0;
  364. ofn.lpfnHook = NULL;
  365. ofn.lpTemplateName = NULL;
  366. if (GetOpenFileNamePreview(&ofn))
  367. {
  368. mdiCreateDoc(aszMCIWndClassName, 0,
  369. (LPARAM)(LPSTR)achFileName);
  370. }
  371. break;
  372. case WM_MDITILE:
  373. case WM_MDICASCADE:
  374. case WM_MDIICONARRANGE:
  375. SendMessage(hwndMdi, (UINT)wParam, 0, 0);
  376. break;
  377. /* Movie Menu */
  378. case IDM_PLAY:
  379. MCIWndPlay(hwndMovie);
  380. break;
  381. case IDM_RPLAY:
  382. MCIWndPlayReverse(hwndMovie);
  383. break;
  384. case IDM_STOP:
  385. MCIWndStop(hwndMovie);
  386. break;
  387. case IDM_HOME:
  388. MCIWndHome(hwndMovie);
  389. break;
  390. case IDM_END:
  391. MCIWndEnd(hwndMovie);
  392. break;
  393. case IDM_STEP:
  394. MCIWndStep(hwndMovie, 1);
  395. break;
  396. case IDM_RSTEP:
  397. MCIWndStep(hwndMovie, -1);
  398. break;
  399. /* Styles POPUP */
  400. #define ISCHECKED() (BOOL)(GetMenuState(GetMenu(hwnd), wParam, 0) & MF_CHECKED)
  401. case IDM_SRepeat:
  402. MCIWndSetRepeat(hwndMovie, !ISCHECKED());
  403. break;
  404. case IDM_SAutosizeWindow:
  405. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOAUTOSIZEWINDOW,
  406. ISCHECKED() ? MCIWNDF_NOAUTOSIZEWINDOW : 0);
  407. break;
  408. case IDM_SAutosizeMovie:
  409. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOAUTOSIZEMOVIE,
  410. ISCHECKED() ? MCIWNDF_NOAUTOSIZEMOVIE : 0);
  411. break;
  412. case IDM_SPlaybar:
  413. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOPLAYBAR,
  414. ISCHECKED() ? MCIWNDF_NOPLAYBAR : 0);
  415. break;
  416. case IDM_SRecord:
  417. MCIWndChangeStyles(hwndMovie, MCIWNDF_RECORD,
  418. ISCHECKED() ? 0 : MCIWNDF_RECORD);
  419. break;
  420. case IDM_SMenu:
  421. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOMENU,
  422. ISCHECKED() ? MCIWNDF_NOMENU : 0);
  423. break;
  424. case IDM_SErrorDlg:
  425. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOERRORDLG,
  426. ISCHECKED() ? MCIWNDF_NOERRORDLG : 0);
  427. break;
  428. case IDM_SShowName:
  429. MCIWndChangeStyles(hwndMovie, MCIWNDF_SHOWNAME,
  430. ISCHECKED() ? 0 : MCIWNDF_SHOWNAME);
  431. break;
  432. case IDM_SShowMode:
  433. MCIWndChangeStyles(hwndMovie, MCIWNDF_SHOWMODE,
  434. ISCHECKED() ? 0 : MCIWNDF_SHOWMODE);
  435. break;
  436. case IDM_SShowPos:
  437. MCIWndChangeStyles(hwndMovie, MCIWNDF_SHOWPOS,
  438. ISCHECKED() ? 0 : MCIWNDF_SHOWPOS);
  439. break;
  440. case IDM_SNotifyMedia:
  441. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOTIFYMEDIA,
  442. ISCHECKED() ? 0 : MCIWNDF_NOTIFYMEDIA);
  443. break;
  444. case IDM_SNotifyMode:
  445. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOTIFYMODE,
  446. ISCHECKED() ? 0 : MCIWNDF_NOTIFYMODE);
  447. break;
  448. case IDM_SNotifyPos:
  449. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOTIFYPOS,
  450. ISCHECKED() ? 0 : MCIWNDF_NOTIFYPOS);
  451. break;
  452. case IDM_SNotifySize:
  453. MCIWndChangeStyles(hwndMovie, MCIWNDF_NOTIFYSIZE,
  454. ISCHECKED() ? 0 : MCIWNDF_NOTIFYSIZE);
  455. break;
  456. default:
  457. mdiSendMessage(hwndMdi,NULL,msg,wParam,lParam);
  458. break;
  459. }
  460. break;
  461. case WM_PALETTECHANGED:
  462. mdiSendMessage(hwndMdi, (HWND)-1, msg, wParam, lParam);
  463. break;
  464. case WM_QUERYNEWPALETTE:
  465. return mdiSendMessage(hwndMdi, NULL, msg, wParam, lParam);
  466. case WM_INITMENUPOPUP:
  467. hwndMovie = mdiActiveDoc();
  468. //
  469. // Check the styles properly when styles is chosen
  470. // !!! Make sure position constants don't change!
  471. //
  472. hmenu = GetSubMenu(GetSubMenu(GetMenu(hwnd), 1), 10);
  473. if (((HMENU)wParam == hmenu) && hwndMovie) {
  474. WORD wStyles = MCIWndGetStyles(hwndMovie);
  475. CheckMenuItem(hmenu, IDM_SRepeat,
  476. MCIWndGetRepeat(hwndMovie) ? MF_CHECKED : MF_UNCHECKED);
  477. CheckMenuItem(hmenu, IDM_SAutosizeWindow,
  478. (wStyles & MCIWNDF_NOAUTOSIZEWINDOW) ? MF_UNCHECKED :
  479. MF_CHECKED);
  480. CheckMenuItem(hmenu, IDM_SAutosizeMovie,
  481. (wStyles & MCIWNDF_NOAUTOSIZEMOVIE) ? MF_UNCHECKED :
  482. MF_CHECKED);
  483. CheckMenuItem(hmenu, IDM_SPlaybar,
  484. (wStyles & MCIWNDF_NOPLAYBAR) ? MF_UNCHECKED : MF_CHECKED);
  485. CheckMenuItem(hmenu, IDM_SRecord,
  486. (wStyles & MCIWNDF_RECORD) ? MF_CHECKED :MF_UNCHECKED);
  487. CheckMenuItem(hmenu, IDM_SMenu,
  488. (wStyles & MCIWNDF_NOMENU) ? MF_UNCHECKED :MF_CHECKED);
  489. CheckMenuItem(hmenu, IDM_SErrorDlg,
  490. (wStyles & MCIWNDF_NOERRORDLG) ? MF_UNCHECKED :MF_CHECKED);
  491. CheckMenuItem(hmenu, IDM_SShowName,
  492. (wStyles & MCIWNDF_SHOWNAME) ? MF_CHECKED :MF_UNCHECKED);
  493. CheckMenuItem(hmenu, IDM_SShowMode,
  494. (wStyles & MCIWNDF_SHOWMODE) ? MF_CHECKED :MF_UNCHECKED);
  495. CheckMenuItem(hmenu, IDM_SShowPos,
  496. (wStyles & MCIWNDF_SHOWPOS) ? MF_CHECKED :MF_UNCHECKED);
  497. CheckMenuItem(hmenu, IDM_SNotifyMedia,
  498. (wStyles & MCIWNDF_NOTIFYMEDIA) ? MF_CHECKED :MF_UNCHECKED);
  499. CheckMenuItem(hmenu, IDM_SNotifyMode,
  500. (wStyles & MCIWNDF_NOTIFYMODE) ? MF_CHECKED :MF_UNCHECKED);
  501. CheckMenuItem(hmenu, IDM_SNotifyPos,
  502. (wStyles & MCIWNDF_NOTIFYPOS) ? MF_CHECKED :MF_UNCHECKED);
  503. CheckMenuItem(hmenu, IDM_SNotifySize,
  504. (wStyles & MCIWNDF_NOTIFYSIZE) ? MF_CHECKED :MF_UNCHECKED);
  505. }
  506. //
  507. // Enable/Disable the stuff under the MOVIE popup
  508. // !!! Make sure position constants don't change!
  509. //
  510. if ((HMENU)wParam == GetSubMenu(GetMenu(hwnd), 1)) {
  511. EnableMenuItem((HMENU)wParam, 10,
  512. MF_BYPOSITION | (hwndMovie ? MF_ENABLED : MF_GRAYED));
  513. if (!hwndMovie || MCIWndGetMode(hwndMovie, NULL, 0) ==
  514. MCI_MODE_NOT_READY) {
  515. f = hwndMovie ? MF_ENABLED : MF_GRAYED;
  516. EnableMenuItem((HMENU)wParam, MENU_CLOSE, f);
  517. EnableMenuItem((HMENU)wParam, MENU_CLOSEALL, f);
  518. EnableMenuItem((HMENU)wParam, IDM_STOP, MF_GRAYED);
  519. EnableMenuItem((HMENU)wParam, IDM_PLAY, MF_GRAYED);
  520. EnableMenuItem((HMENU)wParam, IDM_RPLAY, MF_GRAYED);
  521. EnableMenuItem((HMENU)wParam, IDM_HOME, MF_GRAYED);
  522. EnableMenuItem((HMENU)wParam, IDM_END, MF_GRAYED);
  523. EnableMenuItem((HMENU)wParam, IDM_STEP, MF_GRAYED);
  524. EnableMenuItem((HMENU)wParam, IDM_RSTEP, MF_GRAYED);
  525. } else {
  526. EnableMenuItem((HMENU)wParam, MENU_CLOSE, MF_ENABLED);
  527. EnableMenuItem((HMENU)wParam, MENU_CLOSEALL, MF_ENABLED);
  528. f = MCIWndGetMode(hwndMovie, NULL, 0) != MCI_MODE_STOP;
  529. EnableMenuItem((HMENU)wParam, IDM_PLAY,
  530. !f ? MF_ENABLED : MF_GRAYED);
  531. EnableMenuItem((HMENU)wParam, IDM_RPLAY,
  532. !f ? MF_ENABLED : MF_GRAYED);
  533. EnableMenuItem((HMENU)wParam, IDM_STOP,
  534. f ? MF_ENABLED : MF_GRAYED);
  535. EnableMenuItem((HMENU)wParam, IDM_HOME, MF_ENABLED);
  536. EnableMenuItem((HMENU)wParam, IDM_END, MF_ENABLED);
  537. EnableMenuItem((HMENU)wParam, IDM_STEP, MF_ENABLED);
  538. EnableMenuItem((HMENU)wParam, IDM_RSTEP,MF_ENABLED);
  539. }
  540. }
  541. return mdiSendMessage(hwndMdi, NULL, msg, wParam, lParam);
  542. break;
  543. case WM_CREATE:
  544. hmenu = GetMenu(hwnd);
  545. hwndMdi = mdiCreateClient(hwnd, GetSubMenu(hmenu, GetMenuItemCount(hmenu)-1));
  546. break;
  547. case WM_SIZE:
  548. MoveWindow(hwndMdi,0,0,LOWORD(lParam),HIWORD(lParam),TRUE);
  549. break;
  550. case WM_DESTROY:
  551. hwndApp = NULL;
  552. PostQuitMessage(0);
  553. break;
  554. case WM_PAINT:
  555. hdc = BeginPaint(hwnd, &ps);
  556. EndPaint(hwnd, &ps);
  557. return 0;
  558. }
  559. return DefFrameProc(hwnd,hwndMdi,msg,wParam,lParam);
  560. }
  561. /*----------------------------------------------------------------------------*\
  562. | ErrMsg - Opens a Message box with a error message in it. The user can |
  563. | select the OK button to continue or the CANCEL button to kill |
  564. | the parent application. |
  565. \*----------------------------------------------------------------------------*/
  566. int ErrMsg (LPSTR sz,...)
  567. {
  568. char ach[128];
  569. wvsprintf(ach,sz,(LPSTR)(&sz+1)); /* Format the string */
  570. MessageBox (NULL,ach,NULL,
  571. #ifdef BIDI
  572. MB_RTL_READING |
  573. #endif
  574. MB_OK|MB_ICONEXCLAMATION);
  575. return FALSE;
  576. }