本帖最后由 作者 于 2007-4-18 9:25:15 编辑
使用Mouseleave事件可以获取到鼠标离开的事件,调用acedGetAcadDwgView()->SetFocus()可以使ACAD获取到焦点,具体实现方法如下: 添加OnMouseMove和OnMouseLeave两个事件和状态指示变量bTrackLeave: .h: static BOOL bTrackLeave; afx_msg LPARAM OnMouseLeave(WPARAM wp, LPARAM lp); afx_msg void OnMouseMove(UINT nFlags, CPoint point); .cpp: BEGIN_MESSAGE_MAP(CElemHierDlgChildDlg, CAcUiDialog) .... ON_WM_MOUSEMOVE() ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave) .... END_MESSAGE_MAP() BOOL C****::bTrackLeave=FALSE; void C****::OnMouseMove(UINT nFlags, CPoint point) { if (!bTrackLeave) { TRACKMOUSEEVENT tme; tme.cbSize = sizeof(tme); tme.hwndTrack = m_hWnd; tme.dwFlags = TME_LEAVE;
if(_TrackMouseEvent(&tme)) bTrackLeave = TRUE; } CAcUiDialog::OnMouseMove(nFlags, point); } LPARAM C****::OnMouseLeave(WPARAM wp, LPARAM lp) { bTrackLeave = FALSE; acedGetAcadDwgView()->SetFocus(); return 0; } |