C++ 未解决的问题EDITTEXT 和 DIRECTSHOW PAUSE()
我有一个简单的winform,可以写入EDITTEXT,因为程序继续完美执行打印过程。但是一旦我单击停止按钮,它首先调用 PAUSE() 我的程序卡在
SetWindowText(m_hWatermarksEditBox, &m_watermarkLog[0]);
所有值都已初始化并且正确的数据进入的内部。
我的猜测是我必须声明一个 METHOD WORKER ,就像在 C#.NET 中一样,但我不知道如何声明。
STDMETHODIMP CNaveFilter::Pause()
{
ATLTRACE(L"(%0.5d)CNaveFilter::Pause() (this:0x%.8x)\r\n", GetCurrentThreadId(), (DWORD)this);
HRESULT hr = S_OK;
CAutoLock __lock(&m_cs);
hr = CBaseFilter::Pause();
return hr;
}
STDMETHODIMP CNaveFilter::Stop()
{
ATLTRACE(L"(%0.5d)CNaveFilter::Stop() (this:0x%.8x)\r\n", GetCurrentThreadId(), (DWORD)this);
HRESULT hr = S_OK;
CAutoLock __lock(&m_cs);
hr = CBaseFilter::Stop();
ATLASSERT(SUCCEEDED(hr));
return hr;
}
i have a simple winform that writes to an EDITTEXT , as the program goes on the printing process executing perfectly . but once i click the STOP BUTTON which firstly calls the PAUSE()
function my program gets stuck inside the
SetWindowText(m_hWatermarksEditBox, &m_watermarkLog[0]);
all values are initialized and proper data gets in.
my guess is that i have to declare a METHOD WORKER , like in C#.NET but i dont know how.
STDMETHODIMP CNaveFilter::Pause()
{
ATLTRACE(L"(%0.5d)CNaveFilter::Pause() (this:0x%.8x)\r\n", GetCurrentThreadId(), (DWORD)this);
HRESULT hr = S_OK;
CAutoLock __lock(&m_cs);
hr = CBaseFilter::Pause();
return hr;
}
STDMETHODIMP CNaveFilter::Stop()
{
ATLTRACE(L"(%0.5d)CNaveFilter::Stop() (this:0x%.8x)\r\n", GetCurrentThreadId(), (DWORD)this);
HRESULT hr = S_OK;
CAutoLock __lock(&m_cs);
hr = CBaseFilter::Stop();
ATLASSERT(SUCCEEDED(hr));
return hr;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有显示您在哪里执行
SetWindowText
,但由于您有自定义过滤器,最可能的问题是,通过此调用,您会阻止流/工作线程执行,并且所涉及的线程会被锁定。SetWindowText
只能安全地从 UI 线程调用(嗯,从技术上讲不仅如此,而且绝对不是流线程)。因此,如果您想更新控制文本或向其发送任何消息,您必须以不同的方式进行,以便您的调用者线程可以继续运行。通常,您将在成员变量中存储一些相关信息(不要忘记临界区锁),然后在
PostMessage
中存储,在窗口/控件上接收消息并在正确的线程中处理它,调用>SetWindowText
在那里。请参阅控制帧/速率和曝光通过sampleCB的时间。它涵盖了一些不同的主题,但对于在 DirectShow 过滤器中发送/发布消息而言很有用。
You don't show where you are doing
SetWindowText
but as you have the custom filter the most likely problem is that with this call you block your streaming/worker thread execution and the involved threads lock dead.SetWindowText
is only safe to be called from your UI thread (well, technically not only it, but definitely not a streaming thread). So if you want to update the control text or send any message to it, you have to do it in a different way, so that your caller thread could keep running.Typically, you would store some relevant information in member variable (don't forget critical section lock) then
PostMessage
, receive the message on your window/control and handle it there in the right thread, callingSetWindowText
there.See controlling frame/rate and exposure time through sampleCB. It covers a bit different topic, but useful in terms of sending/posting messages in a DirectShow filter.