MCIWndCreate & MCIWndDestroy

i am trying to play an avi file.
I manage to start mci and play the file.
However, i want Mci to close down automatically when it has finished playing the file.
I done the following
if (m_videoWnd == NULL)
            m_videoWnd = MCIWndCreate(this->GetSafeHwnd(),

Thanks in advance
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have used the correct options  of creating the MCIWnd by using MCIWNDF_NOTIFYMODE as on of your options.
By using this option you will recieve a notification message

wParam = (WPARAM) (HWND) hwnd;
lParam = (LPARAM) (LONG) mode;

you should handle the notification message . Try this with your window message handler

    if (lParam == MCI_MODE_STOP){        // device stopped
        MessageBox(hwnd,"","Closing Device",MB_OK);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
manoj060697Author Commented:
Since I am using MFC and I create the window in my view class
how exactly do i add a handler for MCIWNDM_NOTIFYMODE ?


if you are using mfc treat the notification message as a user message and add your own handler without the help of classwizard
like this
declare the message handler in your .h file

afx_msg LRESULT OnMciWndNotification(WPARAM wParam, LPARAM lParam);

add this to your message map code


hanlde the function in your .cpp file like any other handler.

I hope this information will be helpful to you . in case you need more information , please read  MFC Message Maps  from the VC++ books online or MSDN.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.