mfc 对话框中怎么使用鼠标拖动位图

mfc 对话框中如何使用鼠标拖动位图
RT,求指导。我已经蒙了

------解决方案--------------------
可以做个全局变量,然后存储位图位置信息,然后响应左键按下.鼠标移动.左键放开的消息,如果是在这个位图所在区域,就进行movewindow! 这个仅仅是我的思路,我也没有做过! 不知道可不可行!
------解决方案--------------------
不是才结了一个贴,和这一样。给一点代码吧。
------解决方案--------------------
在OnMouseMove里,记录鼠标坐标,然后Invalidate,
pDC->BitBlt(x,y,bmInfo.bmWidth,bmInfo.bmHeight,&mDC,0,0,SRCCOPY);//绘制图片
修改x,y的坐标
------解决方案--------------------
你这两天一直在问这个问题
我的博客看来确实不适合你
帮人帮到底
送佛送到西
给你一个例子你参考一下吧
以下代码实现的是在frame窗口拖动位图的一个方案
对话框原理是一样
新建win32空项目
然后更改项目属性使用mfc
新建cpp文件导入此代码即可
位图你自己找一个放工程目录下取名test.bmp即可
C/C++ code
#include<afxwin.h>
#include<winuser.h>

class CMyWnd:public CFrameWnd                            //主窗口框架类
{
    CBitmap m_bitmapTest;
    CRect    m_rtBitmap;
    BOOL    m_bIsPick;
    CPoint    m_ptPre;

public:
    CMyWnd();                                            //构造函数

protected:
    //消息相应函数
    afx_msg BOOL OnEraseBkgnd(CDC* pDC);
    afx_msg void OnPaint();
    afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnMouseMove(UINT nflags,CPoint point);//鼠标移动

    DECLARE_MESSAGE_MAP()

public:
    afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
};
BEGIN_MESSAGE_MAP(CMyWnd,CFrameWnd)
  ON_WM_MOUSEMOVE()
  ON_WM_ERASEBKGND()
  ON_WM_PAINT()
  ON_WM_LBUTTONDOWN()
  ON_WM_LBUTTONUP()
END_MESSAGE_MAP()

class CMyApp:public CWinApp             //主程序类
{
public:
    BOOL InitInstance();
};

CMyApp ThisApp;
//////////////////////////////////////////////////////

BOOL CMyApp::InitInstance()
{
    CMyWnd *pFrame=new CMyWnd;
    pFrame->Create(0,_T("Test"));
    pFrame->ShowWindow(m_nCmdShow);
    this->m_pMainWnd=pFrame;
    return TRUE;
}

CMyWnd::CMyWnd()
{
    BITMAP    bmInfo;

    m_bIsPick    = FALSE;

    m_bitmapTest.Attach((HBITMAP)LoadImage(NULL, _T("test.bmp"), IMAGE_BITMAP, NULL, NULL, LR_LOADFROMFILE));
    m_bitmapTest.GetBitmap(&bmInfo);
    m_rtBitmap.SetRect(0, 0, bmInfo.bmWidth, bmInfo.bmHeight);
}

BOOL CMyWnd::OnEraseBkgnd(CDC* pDC)
{
    return    true;
}

void CMyWnd::OnPaint()
{
    CPaintDC    dc(this);
    CDC            dcMem, dcBmp;
    CBitmap        bitmapTemp;
    CRect        rectClient;

    GetClientRect(&rectClient);
    bitmapTemp.CreateCompatibleBitmap(&dc, rectClient.Width(), rectClient.Height());

    dcMem.CreateCompatibleDC(&dc);
    dcBmp.CreateCompatibleDC(&dc);

    dcMem.SelectObject(&bitmapTemp);
    dcBmp.SelectObject(&m_bitmapTest);
    
    dcMem.SelectStockObject(WHITE_BRUSH);
    dcMem.Rectangle(&rectClient);
    dcMem.BitBlt(m_rtBitmap.left, m_rtBitmap.top, m_rtBitmap.Width(), m_rtBitmap.Height(), &dcBmp, 0, 0, SRCCOPY);
    dc.BitBlt(0, 0, rectClient.right, rectClient.bottom, &dcMem, 0, 0, SRCCOPY);
}

void CMyWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
    if(m_rtBitmap.PtInRect(point))
    {
        m_bIsPick    = TRUE;
        m_ptPre        = point;
        SetCapture();
    }

    CFrameWnd::OnLButtonDown(nFlags, point);
}

void CMyWnd::OnLButtonUp(UINT nFlags, CPoint point)
{
    m_bIsPick    = FALSE;
    ReleaseCapture();

    CFrameWnd::OnLButtonUp(nFlags, point);
}

void CMyWnd::OnMouseMove(UINT nflags,CPoint point)
{
    if(m_bIsPick)
    {
        m_rtBitmap.top        += point.y-m_ptPre.y;
        m_rtBitmap.bottom    += point.y-m_ptPre.y;
        m_rtBitmap.right    += point.x-m_ptPre.x;
        m_rtBitmap.left        += point.x-m_ptPre.x;

        m_ptPre    = point;
        Invalidate();
    }
}