DirectShow capture Click Event in DirectShow Filter

自己曾经也遇到过这样的问题,在中文网站发帖无果后,在一个英文的网站上找到了答案,内容很简单,不用我翻译了吧,看看就会明白。A1对这个问题做了一些思路的上的分析和引导;A2给出了最终解决方法(其实很简单,是我太孤陋寡闻了)。

 

Q:I am new to the DirectShow and need to change a transform filter. I need to capture and fire  within the

CTransformFilter class the Click event when a user clicks on the image that the transform filter creates.

This is weird but only have the transform filter code.

Does anyone have a clue on how to do this???

Any advise will be much appreciated.

 

A1:

I've got a bit more experience with DirectShow and I'm not sure if it's possible.  In DS you have some kind of filter pipeline
Source -> Transform ->Renderer
Your "normal" transform filter has no link to the displayed image other than transforming the received data as far as I know.
If catching the mouse click is indeed possible, I'm guessing you'd have to get the event in the renderer filter and then get the event back to your original transform filter using DirectShow notifications.
I've been googling around for a while but I haven't found anything useful as yet:

If it's not possible from an exisiting DS renderer, maybe the Windows Media Player supports this functionaly (though I haven't found anything there either yet), or you might have to dig deeper into the Windows API and write your own renderer?

In any case, let me know if you find anything and I'll do the same...

Does anyone else have any suggestions on how to capture the click event on the renderer window?

 

A2:

IVideoWindow:: put_MessageDrain

The put_MessageDrain method specifies a window to receive mouse and keyboard messages from the video window.

Remarks

This method enables an application to respond to mouse and keyboard events generated within the video window.

If Drain is non-NULL, the video renderer forwards certain messages to the specified window, using the PostMessage function. Which messages are forwarded might depend on the video renderer in use. The Video Renderer and Video Mixing Renderer (VMR) filters forward the following messages:

....

  • WM_LBUTTONDBLCLK
  • WM_LBUTTONDOWN
  • WM_LBUTTONUP

    .....
    The message drain window does not need to be a parent of the video window, so full-screen applications can use this method.

  • Note you don't get the simple click, you will have to handle yourself the ButtonDown and ButtonUp messages.

    So you just need a window to handle the messages, and then, from this window, you notify the filter through a custom interface.

    Alternatively, you could create a window in your filter, and set it as the message drain. Then you can easily trigger any processing you need when you detect a click

     

     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值