⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moveablebutton.cpp

📁 这个是MFC用于拖动CSATIC图标的程序源代码
💻 CPP
字号:
// MoveableButton.cpp : implementation file
//

#include "stdafx.h"
#include "MoveableButton.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMoveableButton

CMoveableButton::CMoveableButton()
{
    m_bStartMove = FALSE;
}

CMoveableButton::~CMoveableButton()
{
}


BEGIN_MESSAGE_MAP(CMoveableButton, CButton)
//{{AFX_MSG_MAP(CMoveableButton)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMoveableButton message handlers

void CMoveableButton::OnLButtonDown(UINT nFlags, CPoint point) 
{
    // TODO: Add your message handler code here and/or call default
    m_bStartMove = TRUE;
    CButton::OnLButtonDown(nFlags, point);
}

void CMoveableButton::OnLButtonUp(UINT nFlags, CPoint point) 
{
    // TODO: Add your message handler code here and/or call default
    m_bStartMove = FALSE;
    CButton::OnLButtonUp(nFlags, point);
}

void CMoveableButton::OnMouseMove(UINT nFlags, CPoint point) 
{
    // TODO: Add your message handler code here and/or call default
    if (m_bStartMove)
    {
        CRect rect;
		
        ClientToScreen(&point);
        this->GetParent()->ScreenToClient(&point);
		
        GetClientRect(&rect);
        point.Offset(-rect.Width()/2, -rect.Height()/2);
		
        SetWindowPos(NULL, point.x , point.y , 0, 0, SWP_NOZORDER|SWP_NOSIZE);
		//         afxDump<<point.x<<","<<point.y<<"\n";
        Invalidate();
    }
    CButton::OnMouseMove(nFlags, point);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -