webbrowser拖动无边框页面移动

原理:截取webbrowser窗口的鼠标消息,然后在宿主窗口指定区域返回HTCAPTION

HWND hw = FindWindowEx(m_hWnd,NULL,_T("ActiveXWnd"),NULL);


HWND hSon = FindWindowEx(hw,NULL,_T("Shell Embedding"),NULL);


HWND hGS = FindWindowEx(hSon,NULL,_T("Shell DocObject View"),NULL);


HWND hGGS = FindWindowEx(hGS,NULL,_T("Internet Explorer_Server"),NULL);


m_proc.m_hwnd = m_hWnd;
m_proc.m_oldProc = (WNDPROC)SetWindowLong(hGGS,GWL_WNDPROC,(LONG)CMsgMouseProc::MouseProc);



拦截:

LRESULT CALLBACK CMsgMouseProc::MouseProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
if (Msg == WM_MOUSEACTIVATE)
{


RECT rc;
POINT point;
GetWindowRect(m_hwnd,&rc);
rc.bottom=rc.top+36;
GetCursorPos(&point);
if (PtInRect(&rc,point)==TRUE)
{
::PostMessage(m_hwnd,WM_NCLBUTTONDOWN,HTCAPTION,0);
}




return MA_ACTIVATE;
}


return m_oldProc(hWnd,Msg,wParam,lParam);


}

展开阅读全文

没有更多推荐了,返回首页