MFC窗口鼠标移动图片(不成熟版)

//中键按下开始移动
/*void Citem_defectInspectionDlg::OnMButtonDown(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值	
	CRect rtImage1; 
	GetDlgItem(IDC_STATIC1)->GetWindowRect(&rtImage1);
	//CPoint point1;
	//GetCursorPos( &point1 );
	if (rtImage1.PtInRect(point)&& ho_Image.IsInitialized())
	{
		onmousemove = TRUE;
		point1=point;

	}
	CDialogEx::OnMButtonDown(nFlags, point);
}

//开始移动图片
void Citem_defectInspectionDlg::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	point2 = point;

	if(onmousemove == TRUE)
	{
	double xOffset=point2.x-point1.x;
	double yOffset=point2.y-point1.y;
 
	//m_dXOffset=m_dXOffset+point2.x-point1.x;
	//m_dYOffset=m_dYOffset+point2.y-point1.x;
   
	m_dDispImagePartRow0=m_dDispImagePartRow0-yOffset;
	m_dDispImagePartCol0=m_dDispImagePartCol0-xOffset;
	m_dDispImagePartRow1=m_dDispImagePartRow1-yOffset;
	m_dDispImagePartCol1=m_dDispImagePartCol1-xOffset;
	ClearWindow(hv_WindowHandle);
	SetPart(hv_WindowHandle,m_dDispImagePartRow0,m_dDispImagePartCol0,m_dDispImagePartRow1,m_dDispImagePartCol1);
	DispImage(ho_Image, hv_WindowHandle); 
	}
	CDialogEx::OnMouseMove(nFlags, point);
}
//中键抬起结束移动操作
void Citem_defectInspectionDlg::OnMButtonUp(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	onmousemove = FALSE;
	CDialogEx::OnMButtonUp(nFlags, point);
}*/

你可能感兴趣的:(MFC界面学习)