怎样做一个类似spy++中那样的拖动图标? 在spy++中有一个工具叫finder tool,用户可以拖动一个图标,将其放到想要定位的窗口上,这样spy++就可以获得该窗口的句柄。问:这个图标(或位图,。。)所属哪个类?是如何实现的?如何响应mousemove、hittest等等已知。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 响应一个Button的拖放void CDButton::OnMouseMove(UINT nFlags, CPoint point) { if(GetKeyState(VK_LBUTTON) < 0) { flag = 1; AfxmessageBox("拖动中..."); } CButton::OnMouseMove(nFlags, point);}void CDButton::OnLButtonUp( UINT nFlags, CPoint point ){ flag = 0; AfxMessageBox("释放中..."); CButton::OnLButtonUp( nFlags, point );} vars:BOOL m_bDraging;m_strSelectedWnd;//和对话框中某编辑框关联的CstringIDC_CURSOR_CAPTURE://光标资源OnLbuttonDown:if (!m_bDraging){ m_bDraging = TRUE; SetCapture();}OnLbuttonUp:if (m_bDraging){ m_bDraging = FALSE; ReleaseCapture();}OnMouseMove:if (m_bDraging){ ::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_CAPTURE)); ClientToScreen(&point); HWND hSelectWnd = ::WindowFromPoint(point); CString strTitle; CWnd::FromHandle(hSelectWnd)->GetWindowText(strTitle); m_strSelectedWnd.Format("HWND:%p \"%s\"", (void *)hSelectWnd, strTitle); UpdateData(FALSE);} 谢谢两位解答。我昨晚已经得出答案了,跟timepalette朋友的差不多。因为在spy++中也就是用的CurSor做的。timepalette好象也在做这个?连m_strSelectedWnd这个想法也跟我一致,不过代码风格比我要好。这个贴子nonocast得5分,timepalette得15分。 求助:RegSetValue 函数创建一个项无法删除 怎样把《对话框》单独放进任务栏 动态创建编辑框 欲开发IC卡储值消费模块,需要注意哪些问题? 100分讨论 ATL 框架中的 一个小问题, 找不到定义 如何设置CTabCtrl的TAB的背景色,如何设置CTabCtrl的通明? 模态对话框问题 free_card() 领分 谁有MpInfo或者MapEngine的控件? 关于递归函数入参的问题,求解!!!!!!!!!! 求助:关于输入法 新手问题,如何在VC中连接SQL数据库?
void CDButton::OnMouseMove(UINT nFlags, CPoint point)
{
if(GetKeyState(VK_LBUTTON) < 0)
{
flag = 1;
AfxmessageBox("拖动中...");
}
CButton::OnMouseMove(nFlags, point);
}
void CDButton::OnLButtonUp( UINT nFlags, CPoint point )
{
flag = 0;
AfxMessageBox("释放中..."); CButton::OnLButtonUp( nFlags, point );
}
BOOL m_bDraging;
m_strSelectedWnd;//和对话框中某编辑框关联的Cstring
IDC_CURSOR_CAPTURE://光标资源OnLbuttonDown:
if (!m_bDraging)
{
m_bDraging = TRUE;
SetCapture();
}OnLbuttonUp:
if (m_bDraging)
{
m_bDraging = FALSE;
ReleaseCapture();
}OnMouseMove:
if (m_bDraging)
{
::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_CAPTURE));
ClientToScreen(&point);
HWND hSelectWnd = ::WindowFromPoint(point);
CString strTitle;
CWnd::FromHandle(hSelectWnd)->GetWindowText(strTitle);
m_strSelectedWnd.Format("HWND:%p \"%s\"", (void *)hSelectWnd, strTitle);
UpdateData(FALSE);
}
这个贴子nonocast得5分,timepalette得15分。