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

📄 cjbutton0.cpp

📁 波峰焊后台控制软件-英文版
💻 CPP
字号:
// CJButton.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CJButton.h"
#include "FLADS.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCJButton
extern CFLADSApp theApp;
extern unsigned int JBMP[250];
extern unsigned int JRBMP[250];

CCJButton::CCJButton()
{
	m_nColor=0;
	m_bLBtnDown  = false;
	m_bFlatLook  = true;
    m_JFlag=0;
    m_dot_flag=0;
}

CCJButton::~CCJButton()
{
}


BEGIN_MESSAGE_MAP(CCJButton, CButton)
	//{{AFX_MSG_MAP(CCJButton)
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONDOWN()
	ON_WM_LBUTTONUP()
	ON_WM_TIMER()
	ON_WM_KEYDOWN()
	ON_WM_KEYUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCJButton message handlers

void CCJButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	// TODO: Add your code to draw the specified item
	ASSERT(lpDrawItemStruct != NULL);
	// must have at least the first bitmap loaded before calling DrawItem

	ASSERT(theApp.fillbitmap[m_nColor]->m_hObject != NULL);     // required
	m_nState = lpDrawItemStruct->itemState;
	// copy the rect, and fill the background.
	m_rcItem.CopyRect(&lpDrawItemStruct->rcItem);
	// draw the whole button
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	CDC memDC;
	memDC.CreateCompatibleDC(pDC);
	CBitmap* pOld = memDC.SelectObject(theApp.fillbitmap[m_nColor]);
	if (pOld == NULL)return;     // destructors will clean up
	pDC->BitBlt(m_rcItem.left, m_rcItem.top, m_rcItem.Width(), m_rcItem.Height(),
		&memDC, 0, 0, SRCCOPY);
	memDC.SelectObject(pOld);
    if(m_JFlag!=0)
	{
		if(m_nColor>=130)
		{
            m_nColor=JRBMP[m_nColor];
		}

	}
}



void CCJButton::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CRect rcItem;
	GetWindowRect(rcItem);
	CPoint ptCursor;
	GetCursorPos(&ptCursor);


	if (!rcItem.PtInRect(ptCursor)) 
	{
       m_dot_flag=0;
	}
	CButton::OnMouseMove(nFlags, point);
}

void CCJButton::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
    m_dot_flag=0xff;
	m_bLBtnDown = true;	
    if(m_JFlag!=0)
	{
		SetTimer (100,10,NULL);	
	}
	CButton::OnLButtonDown(nFlags, point);
}

void CCJButton::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	m_bLBtnDown = false;
    m_dot_flag=0;
	CButton::OnLButtonUp(nFlags, point);
}

void CCJButton::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	int OldMode,i;

	CRect rcItem;
	GetWindowRect(rcItem);

	CPoint ptCursor;
	GetCursorPos(&ptCursor);

	static bool pPainted = false;

	if (m_bLBtnDown==true) 
	{

		if (pPainted == true) 
		{
			InvalidateRect (NULL);
		}

		pPainted = false;
		return;
	}

	if (!rcItem.PtInRect(ptCursor)) 
	{

		if (pPainted) 
		{
			InvalidateRect (NULL);
		}

		pPainted = false;
	    KillTimer(100);	
        m_dot_flag=0;
		return;
	}else
	{//鼠标在按钮范围内

			if(m_bFlatLook)
			{

				if (pPainted == false)
				{
                    if(m_JFlag!=0)
					{
                       m_nColor=JBMP[m_nColor];
					}

					InvalidateRect (NULL);

				
					pPainted = true;
				}
			}
	}

	CButton::OnTimer(nIDEvent);
}

void CCJButton::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
    return;	
	CButton::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CCJButton::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	// TODO: Add your message handler code here and/or call default
    return;		
	CButton::OnKeyUp(nChar, nRepCnt, nFlags);
}

⌨️ 快捷键说明

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