在仅由句柄知道的窗口上检测鼠标单击 [英] Detecting mouse click on a window known only by handle

查看:126
本文介绍了在仅由句柄知道的窗口上检测鼠标单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建了一个类,使用avicap32.dll使用多个网络摄像头来满足我自己的需求.网络摄像头功能(例如眼动追踪和录制功能)可以正常运行.但是,我面临一个小的挫折,即单击用户控件时不再检测到鼠标单击.我将此归咎于以下代码行. pn是用户控件中的面板.

Hi
I have created a class to use several webcams to fit my own needs using the avicap32.dll. Webcam features such as eyetracking and recording function properly. I''m however facing a small setback that mouseclicks are no longer detected when clicking the user control. I blame this on the following line of code. pn is a panel in the usercontrol.

<br />
hWnd = Webcam.capCreateCaptureWindowA("0", Webcam.WS_VISIBLE | Webcam.WS_CHILD, 0, 0, 0, 0, pn.Handle, 0);<br />



这条线与我用来在其上绘制网络摄像头图像的面板重叠,因此我实际上无法单击它们.
有没有一种方法可以通过使用父窗体的WindowProc或挂接到创建的窗口来检测这些事件?还是有一种更清洁的方法来解决这个问题?我已经研究过SetWindowLongPtr,但是由于子类化,这对我来说似乎是一件肮脏的事,并且由于时间用完,我不想弄乱这些东西.
我特别想让用户在网络摄像头图像上定义一组点.只是坐标.

在此先感谢



This line sort of overlaps the panels I use to draw the webcam images on, so I can''t actually click them.
Is there a way to detect these event by using WindowProc of the parent form or hooking into the created window? Or is there a cleaner way to solve this? I already looked into SetWindowLongPtr, but this seems kind of dirty business to me because of subclassing and I wouldn''t want to mess with those things since I am running out of time...
I specifically want to let the user define a set of points on the webcam image. Just the coordinates.

Thanks in advance

推荐答案

我将继续进行钩子. 此处中有一篇文章可能会帮助您在父窗口中拦截鼠标消息(我没有) t尝试过),但是即使它能正常工作,我也认为挂钩是更清洁(且100%有效)的解决方案,也许是唯一的解决方案.不幸的是,当唯一的解决方案是钩子时,GUI编程中有很多方案.这并不是第一次出现的肮脏解决方案,只需隐藏上面的窗口创建调用和对类的钩子,就不必再考虑了! :laugh:
I would go on with hooking. There is an article here that may help you to intercept mouse messages in the parent window (I haven''t tried it), but even if its working I think that the hooking is the cleaner (and 100% working) solution, and maybe the only one. Unfortunately there are a lot of scenarios in GUI programming when the only solution is hooking. It isn''t that dirty solution as it seems to be for the first time, just hide the above window creation call and the hooking to a class and don''t think of it again! :laugh:


找到了我自己的答案,其中涉及到钩挂已创建的窗口.
这是我找到的链接.希望它能像我一样为将来的读者服务;)

http://www.eggheadcafe.com/software/aspnet/33974118/- subclassing-an-unmanaged-wndproc.aspx [
Found my own answer involving hooking the created window.
This is the link I found. May it serve future readers as it served me ;)

http://www.eggheadcafe.com/software/aspnet/33974118/-subclassing-an-unmanaged-wndproc.aspx[^]


这篇关于在仅由句柄知道的窗口上检测鼠标单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆