C++ 未解决的问题EDITTEXT 和 DIRECTSHOW PAUSE()

发布于 2024-12-14 17:43:45 字数 922 浏览 0 评论 0原文

我有一个简单的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇纵 2024-12-21 17:43:48

您没有显示您在哪里执行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, calling SetWindowText 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文