Click here to Skip to main content
15,120,883 members
Articles / Desktop Programming / MFC
Article
Posted 11 Jan 2003

Stats

152.7K views
3.1K downloads
48 bookmarked

MFC Wrapper Class for MCIWnd

Rate me:
Please Sign up or sign in to vote.
4.71/5 (15 votes)
11 Jan 20032 min read
An MFC Wrapper Class for MCIWnd

Sample Image - MCIWndWrapper.gif

Introduction

A recent small project required the use of MFC and it also needed to be able to play an AVI file. The Microsoft 'Video for Windows' technology seemed like the easiest route to go. To make the project coding cleaner, I built a MFC wrapper class CMCIWnd for the MCIWnd functions.

Using the code

There are no licensing restrictions on the use of the source code. This is completely an exercise in giving something back to a community that has helped me often when I needed some quick code.

To use the wrapper class in your own project, add MCIWnd.cpp and MCIWnd.h to your project. In your project settings, link to Vfw32.lib and Winmm.lib. Create a variable of type CMCIWnd and then call CMCIWnd::Create() to create the window, CMCIWnd::Open() to open an AVI file, and CMCIWnd::Play() to play the file.

The demo application shows how to do all this. I elected to keep the demo application very simple so you could quickly see how the CMCIWnd wrapper class would be used in an MFC project. Take a look at MCIWndWrapperDlg.cpp and its CWrapperDlg::OnPlayAVI() function. It shows how to use the CMCIWnd wrapper class to play an AVI file. Just in case you need to know how to do it, I also added MFC message handlers for the notifications that the MCIWnd window sends to a parent window.

Points of Interest

I did manage to make one improvement in the wrapper class that is not offered out of the box by MCIWnd. While you can set the MCIWnd to repeat/loop the playing of an AVI, the standard MCIWnd Play() function does not recognize this setting and will only play the AVI one time. I did a bit of digging in the mciSendCommand() function and came up with a way for the wrapper class's CMCIWnd::Play() function to recognize the repeat setting and have the AVI loop if CMCIWnd::GetRepeat() is TRUE.

History

  • 12/25/2002 Created.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Paul Kissel
Web Developer
United States United States
Paul Kissel is presently a Principal with RiverBend Software, Inc. - a consulting services company specializing in the design and development of consumer-focused, commercial application software for Microsoft Windows.

Comments and Discussions

 
QuestionOpen file after play error Pin
phydthekid16-Dec-09 5:44
Memberphydthekid16-Dec-09 5:44 
GeneralDrag the slider hang the application Pin
Ha_Tim10-Dec-09 17:19
MemberHa_Tim10-Dec-09 17:19 
GeneralNeed Information about CDateTimeCtrl in VC++ Pin
John50218-Mar-09 23:28
MemberJohn50218-Mar-09 23:28 
GeneralMCIWndOpenInterface & AVI Streams Pin
sdancer7531-Oct-07 3:02
Membersdancer7531-Oct-07 3:02 
GeneralRe: MCIWndOpenInterface & AVI Streams Pin
Viorel.31-Oct-07 4:18
MemberViorel.31-Oct-07 4:18 
GeneralRe: MCIWndOpenInterface & AVI Streams [modified] Pin
sdancer7531-Oct-07 4:48
Membersdancer7531-Oct-07 4:48 
GeneralVideo position using time format hh:mm:ss Pin
sdancer7510-Oct-07 6:21
Membersdancer7510-Oct-07 6:21 
QuestionPlay an encrypted AVI Pin
Mehdy Khoshrou3-May-06 10:50
MemberMehdy Khoshrou3-May-06 10:50 
GeneralThanks! Pin
S Douglas24-Jan-06 17:14
professionalS Douglas24-Jan-06 17:14 
GeneralRe: Thanks! Pin
LordofthePings11-May-11 10:11
MemberLordofthePings11-May-11 10:11 
GeneralRe: Thanks! Pin
S Douglas11-May-11 12:38
professionalS Douglas11-May-11 12:38 
GeneralMCIWnd Blinks in Upper Left Corner Pin
PFG2329-Mar-05 6:37
MemberPFG2329-Mar-05 6:37 
GeneralMCIWnd has severe bug Pin
yinfudan16-Jan-05 1:59
Memberyinfudan16-Jan-05 1:59 
GeneralRe: MCIWnd has severe bug Pin
PFG2329-Mar-05 6:33
MemberPFG2329-Mar-05 6:33 
GeneralRe: MCIWnd has severe bug Pin
yinfudan29-Mar-05 15:46
Memberyinfudan29-Mar-05 15:46 
Generalhelp!!!!!! Pin
athira11-Jun-03 2:15
Memberathira11-Jun-03 2:15 
Generalurgent help Pin
athira28-May-03 22:36
Memberathira28-May-03 22:36 
GeneralRe: urgent help Pin
Paul Kissel29-May-03 8:13
MemberPaul Kissel29-May-03 8:13 
GeneralRe: urgent help Pin
athira1-Jun-03 20:23
Memberathira1-Jun-03 20:23 
GeneralRe: urgent help Pin
Paul Kissel1-Jun-03 22:35
MemberPaul Kissel1-Jun-03 22:35 
GeneralRe: urgent help Pin
luweiwinson16-Jul-08 22:19
Memberluweiwinson16-Jul-08 22:19 
GeneralMemory Leak HELP!!!! Pin
pvivera30-Apr-03 19:56
Memberpvivera30-Apr-03 19:56 
GeneralRe: Memory Leak HELP!!!! Pin
GaryMLong25-Jun-03 17:00
MemberGaryMLong25-Jun-03 17:00 
GeneralRe: Memory Leak HELP!!!! Pin
pvivera26-Jun-03 4:41
Memberpvivera26-Jun-03 4:41 
GeneralNotification Pin
itlk19-Feb-03 11:26
Memberitlk19-Feb-03 11:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.