CAnimateCtrl crashes when it sends WM_COMMAND messages 
Author Message
 CAnimateCtrl crashes when it sends WM_COMMAND messages

I have the following function that creates and destroys a CAnimateCtrl
(m_pSearchAVI). The problem is, when I call ShowSearchingAVI(FALSE) it
stops the AVI playing and destroys the window. But on Stop(), the
CAnimateCtrl posts a WM_COMMAND message, and by the time MFC gets
around to processing it, the CAnimateCtrl window is gone, and MFC
throws an exception in CWnd::OnCommand because hWndCtrl is no longer a
valid window. Anybody know how i can get around this problem? My code
follows. One solution would be not to destroy the CAnimateCtrl, but
that won't work for me since i need to recreate it with a different
background color.

void CFileList::ShowSearchingAVI(BOOL bShow)
{
  if (bShow)
  {
    m_pSearchAVI = new CAnimateCtrl();
    m_pSearchAVI->Create(WS_CHILD|WS_VISIBLE|ACS_CENTER|ACS_TRANSPARENT,
                         CRect(10,10,40,40), this, IDC_SEARCHAVI);

    m_pSearchAVI->Open(MAKEINTRESOURCE(IDR_SEARCH));

    m_pSearchAVI->Play(0, -1, -1);
  }
  else
  {
    if (m_pSearchAVI)
    {
      m_pSearchAVI->Stop();            
      m_pSearchAVI->DestroyWindow();
      delete m_pSearchAVI;
      m_pSearchAVI;
    }
  }

Quote:
}

Thanks
Roland


Sat, 16 Oct 2004 07:57:08 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. accelerator key sends two WM_COMMAND messages

2. Sending message to CPropertySheet crashes app in Release

3. Sending WM_COMMANDs to another application

4. Push button won't send WM_COMMAND

5. Send WM_COMMAND from VxD's

6. Unhandled WM_COMMAND messages close windows???

7. Help : WM_COMMAND message

8. WM_COMMAND message

9. define WM_COMMAND messages

10. handle WM_COMMAND messages

11. Cannt receive message WM_COMMAND?

12. Send a message like NET SEND in MFC

 

 
Powered by phpBB® Forum Software