0

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;
        }
4

1 回答 1

0

你没有显示你在哪里做SetWindowText,但你有自定义过滤器最可能的问题是,通过这个调用你会阻止你的流/工作线程执行并且所涉及的线程锁定死。

SetWindowText仅从您的 UI 线程调用是安全的(从技术上讲,不仅是它,而且绝对不是流线程)。因此,如果您想更新控制文本或向其发送任何消息,您必须以不同的方式进行操作,以便您的调用者线程可以继续运行。

通常,您会将一些相关信息存储在成员变量中(不要忘记关键部分锁定),然后PostMessage在窗口/控件上接收消息并在正确的线程中处理它,在那里调用SetWindowText

请参阅通过 sampleCB 控制帧/速率和曝光时间。它涵盖了一些不同的主题,但在 DirectShow 过滤器中发送/发布消息方面很有用。

于 2011-11-09T09:51:03.893 回答