110,536
社区成员
发帖
与我相关
我的任务
分享
这段是WM_MOUSE_LL响应函数里面的
private void HookOnMouseActivity(object sener, HookEx.MouseExEventArgs e) {
Point location = e.Location;
if (e.Button == MouseButtons.Left) {
Rectangle captionRect = new Rectangle(this.Location, new Size(this.Width, SystemInformation.CaptionHeight));
if (captionRect.Contains(location)) {
SetWindowLong(this.Handle, GWL_EXSTYLE,
(int)GetWindowLong(this.Handle, GWL_EXSTYLE) & (~WS_DISABLED));
SendMessage(this.Handle, WM_SETFOCUS, IntPtr.Zero, IntPtr.Zero);
} else {
SetWindowLong(this.Handle, GWL_EXSTYLE,
(int)GetWindowLong(this.Handle, GWL_EXSTYLE) | WS_DISABLED);
}
}
}
g_hwnd 为我的程序的HWND 给值在我的dlg程序的 initdialog里面,g_hwnd=this->m_hWnd;
//这段是WM_MOUSE_LL响应函数里面的
if(nCode==HC_ACTION)
{
if(wParam==WM_LBUTTONDOWN||wParam==WM_LBUTTONUP)
{
CRect rectwindow;
::GetWindowRect(g_hwnd,&rectwindow);
MSLLHOOKSTRUCT* msl = (MSLLHOOKSTRUCT *)lParam;
if(rectwindow.PtInRect(msl->pt))
{
SetWindowLong(g_hwnd, GWL_EXSTYLE,GetWindowLong(g_hwnd, GWL_EXSTYLE) & (~WS_DISABLED));
SendMessage(g_hwnd, WM_SETFOCUS, 0, 0);
}
else
{
SetWindowLong(g_hwnd, GWL_EXSTYLE,GetWindowLong(g_hwnd, GWL_EXSTYLE)|WS_DISABLED);
}
}
}