BOOL CMoveWinUsingPicDlg::PreTranslateMessage(MSG *pMsg)
{
static bool mouse_down = false;
static CRect MainRect;
static CPoint point;
switch(pMsg->message)
{
case WM_LBUTTONDOWN:
GetWindowRect(&MainRect);
point = pMsg->pt;
ScreenToClient(&point);
mouse_down = true;
break;
case WM_LBUTTONUP:
mouse_down = false;
break;
case WM_MOUSEMOVE:
CRect r;
m_myPic.GetWindowRect(&r);
if(mouse_down && r.PtInRect(pMsg->pt))
{
MoveWindow(pMsg->pt.x - point.x,pMsg->pt.y - point.y,
MainRect.Width(),MainRect.Height());
}
}
return CDialog::PreTranslateMessage(pMsg);
}