1、SPY++明显用到了WM_LBUTTONDOWN消息和WM_LBUTTONUP消息,但是正常情况下Picture Control(这里Notify属性要为 TURE) 只有鼠标的STN_CLICKED 单击消息和STN_DBLCLK双击消息类型。 类视图右键添加一个类如:CMy_ICON,基类为CStatic;主程序对话框类中添加一个该类成员如:CMy_ICON my_Icon;再在主对话框初始化时关联图片控件。 my_Icon.SubclassDlgItem(IDC_PICCTRL,this);
2、用类似EXESCOPE的软件把 SPY++的光标、图标资源导出来以便使用。靶心形的光标,带靶心的图标,不带靶心的图标共3个资源。
3、在类视窗 右键 CMy_ICON->类向导->消息,添加WM_LBUTTONDOWN、WM_LBUTTONUP处理程序,再编辑2个消息处理函数;
void CMy_ICON::OnLButtonDown(UINT nFlags, CPoint point)
{
SetCapture();
//IDC_CURSOR1是靶心光标 IDI_ICON1是无靶心图标 IDI_ICON2 是有靶心图标 HCURSOR hc = LoadCursor(AfxGetApp()->m_hInstance, MAKEINTRESOURCE (IDC_CURSOR1));
::SetCursor(hc);
HICON hicon1 = LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE (IDI_ICON1)); this->SetIcon(hicon1);
CStatic::OnLButtonDown(nFlags, point);
}
void CMyPicCtrl::OnLButtonUp(UINT nFlags, CPoint point)
{
ReleaseCapture();
HICON hicon2 = LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE (IDI_ICON2)); this->SetIcon(hicon2);
CStatic::OnLButtonUp(nFlags, point);
}
获得窗口句柄明天写