最近在学习duilib这个库,看了网上Alberl的教程,他那个仿迅雷播放器做的不错,我就直接拿来学习duilib了。不过这个播放器有个缺点,就是无法双击全屏,也就是鼠标放到libVLC播放窗口时无法响应消息,消息都被libVLC内部处理了。这对我们而言不是很方便。因为有时我们需要双击全屏,或者弹出鼠标右键菜单做一些操作。后来上网查了下,好多人遇到这个问题。下面是一些查到的解决方法。
解决libVLC无法响应鼠标消息
如下是查到的一些方法:
1)使用全局钩子;
2)修改libVLC鼠标消息处理代码,重新编译;
3)禁用子窗口消息。
第一种方法不安全,容易被杀毒软件干掉,而且效率不高,第二种方法麻烦,编译就得花你好多时间,而且很麻烦,第三种方法比较简单,解决方法如下:
// First step is start a timer when you play a video,
// Second step : in the timer function i call :
EnumChildWindows(MyWindow_HWND, EnumerateVLC, NULL);
// Third step : if EnumerateVlc get some child window these window is the VlcEventWindow, and need disable it, to reach mouse events on MyWindow
BOOL CALLBACK EnumerateVLC(HWND hWndvlc, LPARAM lParam) {
EnableWindow(hWndvlc, FALSE);
// And kill timer, i only need get this handle one time.
return TRUE;
}
// When EnumerateVLC is called all mouse events are redirected to MyWindow
1
2
3
4
5
6
7
8
9
10
11
12
13
// First step is start a timer when you play a video,
// Second step : in the