LRESULT CALLBACK PlayWindow::PlayWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)//这是一个static成员函数
{
switch (uMsg)
{
case WM_LBUTTONDOWN:
if(m_pIPlayCtrl->GetStatus() == 3)
{
m_pIPlayCtrl->Pause();
}
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
由于PlayWindowProc是窗口过程,在类中定义成static成员函数,m_pIPlayCtrl是非static变量,访问出现问题。
解决该问题:可以在static成员函数PlayWindowProc变为非static成员函数,另外添加一个static成员函数__PlayWindowProc,调用PlayWindowProc,这样PlayWindowProc就可以访问非static成员了。如下所示:
LRESULT CALLBACK PlayWindow::__PlayWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
PlayWindow* pThis = reinterpret_cast<PlayWindow*>(GetWindowLong(hWnd, GWL_USERDATA));
if(pThis)
{
return pThis->PlayWindowProc(hWnd, uMsg, wParam, lParam);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
//视频播放窗口的过程函数////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK PlayWindow::PlayWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_LBUTTONDOWN:
if(m_pIPlayCtrl->GetStatus() == 3)
{
m_pIPlayCtrl->Pause();
}
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}