求助:关于DirectShow中OAHWND的问题

autoegg 2003-05-09 12:59:28
小弟刚刚开始用DirectShow,在DirectX SDK中看到如下代码:
set the filter graph manager to deliver this message to the application's main window:

pEvent->SetNotifyWindow((OAHWND)g_hwnd, WM_GRAPHNOTIFY, 0);

The IMediaEventEx::SetNotifyWindow method designates the specified window (g_hwnd) as the recipient of the message. Call this method after you create the filter graph and specify the owner window, but before running the graph.

于是我在自己的程序中写下如下代码:
pEventEx->SetNotifyWindow((OAHWND)AfxGetMainWnd()->m_hWnd, WM_GRAPHNOTIFY, 0);

编译提示错误信息:“内存不能为read”;
调试提示错误信息:“Access Violation”

小弟真的不解,这其中的OAHWND到底是怎么回事?和HWND有何区别?多谢了!
...全文
58 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
autoegg 2003-05-15
  • 打赏
  • 举报
回复
不好意思,我犯了一个低级错误,pEventEx失效!
还是要谢谢大家。
chenxiaa 2003-05-14
  • 打赏
  • 举报
回复
检验一下pEventEx是否有效。
peterleex 2003-05-13
  • 打赏
  • 举报
回复
你试过吗:
AfxGetMainWnd()->m_hWnd
pVidWin->put_Owner((OAHWND)(AfxGetMainWnd()->m_hWnd));
SendMessage(AfxGetMainWnd()->m_hWnd, WM_GRAPHNOTIFY, 0, 0);
autoegg 2003-05-13
  • 打赏
  • 举报
回复
AfxGetMainWnd()->GetSafeHwnd()
还是不行。
确实如peterleex所说,AfxGetMainWnd()->m_hWnd 在其他地方是可以用的,
可是就是不明白为什么在SetNotifyWindow中就不能用。
peterleex 2003-05-13
  • 打赏
  • 举报
回复
AfxGetMainWnd()->m_hWnd 在其他地方是可以用的,例如:
pVidWin->put_Owner((OAHWND)(AfxGetMainWnd()->m_hWnd));
SendMessage(AfxGetMainWnd()->m_hWnd, WM_GRAPHNOTIFY, 0, 0);
matrass_zhao 2003-05-12
  • 打赏
  • 举报
回复
你试一下这样得到hWnd
AfxGetMainWnd()->GetSafeHwnd()
autoegg 2003-05-12
  • 打赏
  • 举报
回复
非常谢谢两位!

首先,我已经成功定义了WM_GRAPHNOTIFY;

其次,AfxGetMainWnd()->m_hWnd 在其他地方是可以用的,例如:
SendMessage(AfxGetMainWnd()->m_hWnd, WM_GRAPHNOTIFY, 0, 0);
pVidWin->put_Owner((OAHWND)(AfxGetMainWnd()->m_hWnd));

但是不知道为什么在SetNotifyWindow中就不能用。
Afile 2003-05-10
  • 打赏
  • 举报
回复
我的看法是你的错误应该出在AfxGetMainWnd()->m_hWnd上,按这个成员的命名和常见惯例,应该是一个被保护的数据成员,你无法将它交给SetNotifyWindow。

但是由于我从来没有用过MFC,所以我了不知道怎么得到一个hwnd,不论如何,我想怎么得到一个正确的hwnd才是关键。我在BCB里的实现是

pEventEx->SetNotifyWindow((long)Main_Windows->windowhandle, WM_GRAPHNOTIFY, 0);

这样是可以被通过的。
peterleex 2003-05-09
  • 打赏
  • 举报
回复
你 WM_GRAPHNOTIFY 定义了吗?
autoegg 2003-05-09
  • 打赏
  • 举报
回复
要怎样才能正确运用OAHWND呢?

2,542

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧