Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MCIWndCreate & MCIWndDestroy

Posted on 1997-06-07
3
Medium Priority
?
994 Views
Last Modified: 2013-12-03
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(),
            AfxGetInstanceHandle(),
            WS_CAPTION | WS_VISIBLE | MCIWNDF_SHOWPOS | MCIWNDF_SHOWNAME|MCIWNDF_NOTIFYMODE,
            filename);
            MCIWndPlay(m_videoWnd);
      }

Thanks in advance
0
Comment
Question by:manoj060697
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
ramshank earned 150 total points
ID: 1397906
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

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

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

case MCIWNDM_NOTIFYMODE:
    if (lParam == MCI_MODE_STOP){        // device stopped
        MessageBox(hwnd,"","Closing Device",MB_OK);
        MCIWndClose(g_hwndMCIWnd);
    }
    break;



0
 

Author Comment

by:manoj060697
ID: 1397907
Since I am using MFC and I create the window in my view class
how exactly do i add a handler for MCIWNDM_NOTIFYMODE ?

Thanks


0
 
LVL 1

Expert Comment

by:ramshank
ID: 1397908
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

BEGIN_MESSAGE_MAP(CMyWnd, CMyParentWndClass)
    ON_MESSAGE(MCIWNDM_NOTIFYMODE,OnMciWndNotification )
END_MESSAGE_MAP()


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.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question