6 Star 38 Fork 25

ewin66/QueueSystem

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
MouseAwareButton.cs 1.54 KB
一键复制 编辑 原始数据 按行查看 历史
Ace 提交于 2018-08-16 11:39 +08:00 . update
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
public class MouseAwarePictureBox : PictureBox
{
private const int WM_LBUTTONDOWN = 0x201;
private const int WM_LBUTTONUP = 0x202;
Control prevParent = null;
public new event MouseEventHandler MouseUp;
public new event MouseEventHandler MouseDown;
protected override void OnParentChanged(EventArgs e)
{
if (prevParent != null)
{
WndProcHooker.UnhookWndProc(prevParent, WM_LBUTTONDOWN);
WndProcHooker.UnhookWndProc(prevParent, WM_LBUTTONUP);
}
prevParent = Parent;
if (Parent != null)
{
WndProcHooker.HookWndProc(Parent, WM_LBUTTONDOWN_Handler, WM_LBUTTONDOWN);
WndProcHooker.HookWndProc(Parent, WM_LBUTTONUP_Handler, WM_LBUTTONUP);
}
base.OnParentChanged(e);
}
int WM_LBUTTONDOWN_Handler(IntPtr hwnd, uint msg, uint wParam, int lParam, ref bool handled)
{
int x = lParam & 0xffff, y = lParam >> 16;
MouseEventArgs args = new MouseEventArgs(MouseButtons.Left, 0, x, y, 0);
if (MouseDown != null)
MouseDown(this, args);
return 0;
}
int WM_LBUTTONUP_Handler(IntPtr hwnd, uint msg, uint wParam, int lParam, ref bool handled)
{
int x = lParam & 0xffff, y = lParam >> 16;
MouseEventArgs args = new MouseEventArgs(MouseButtons.Left, 0, x, y, 0);
if (MouseUp != null)
MouseUp(this, args);
return 0;
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/EWIN66/QueueSystem.git
git@gitee.com:EWIN66/QueueSystem.git
EWIN66
QueueSystem
QueueSystem
master

搜索帮助