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

📄 atransclrsetdlg.cpp

📁 Resource editor base speadrum Chinese mobile
💻 CPP
字号:
// ATransClrSetDlg.cpp : implementation file
//

#include "stdafx.h"
#include "resourceeditor.h"
#include "ATransClrSetDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CATransClrSetDlg dialog


CATransClrSetDlg::CATransClrSetDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CATransClrSetDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CATransClrSetDlg)
	m_strPrjName = _T("");
	//}}AFX_DATA_INIT
	m_nBlue = 0;
	m_nGreen = 0;
	m_nRed = 0;
	m_nColor = 0;
	m_nRGB = 0;
	m_bFromDec = TRUE;
	m_bFromHex = TRUE;
}


void CATransClrSetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CATransClrSetDlg)
	DDX_Control(pDX, IDC_STC_PRJ_NAME, m_stcPrjName);
	DDX_Control(pDX, IDC_EDT_RGB, m_edtRGB);
	DDX_Control(pDX, IDC_EDT_R, m_edtR);
	DDX_Control(pDX, IDC_EDT_G, m_edtG);
	DDX_Control(pDX, IDC_EDT_B, m_edtB);
	DDX_Control(pDX, IDC_STC_COLOR, m_stcColor);
	DDX_Text(pDX, IDC_STC_PRJ_NAME, m_strPrjName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CATransClrSetDlg, CDialog)
	//{{AFX_MSG_MAP(CATransClrSetDlg)
	ON_EN_CHANGE(IDC_EDT_R, OnChangeEdtR)
	ON_EN_CHANGE(IDC_EDT_B, OnChangeEdtB)
	ON_EN_CHANGE(IDC_EDT_G, OnChangeEdtG)
	ON_WM_CANCELMODE()
	ON_EN_CHANGE(IDC_EDT_RGB, OnChangeEdtRgb)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CATransClrSetDlg message handlers

BOOL CATransClrSetDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if(m_nRGB != 0 )
	{
		m_nBlue = m_nRGB & 0x0000FF;
		m_nGreen = m_nRGB & 0x00FF00;
		m_nGreen = m_nGreen >> 8;
		m_nRed = m_nRGB & 0xFF0000;
		m_nRed = m_nRed >> 16;

		m_nColor=m_nBlue;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nGreen;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nRed;
	}
	
	m_stcColor.SetColor(m_nColor);
 
	m_edtR.SetDispMode(DEC);
	m_edtG.SetDispMode(DEC);
	m_edtB.SetDispMode(DEC);
	m_edtRGB.SetDispMode(HEX);
    //m_bFromDec = FALSE;
    //m_edtR.SetDigit(m_nRed);
    //m_edtG.SetDigit(m_nGreen);
    //m_edtB.SetDigit(m_nBlue);
    m_edtRGB.SetDigit(m_nRGB);   
    //m_bFromDec = TRUE;



	m_stcPrjName.SetWindowText(m_strPrjName);
	Invalidate();
	UpdateData(FALSE);
	

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



void CATransClrSetDlg::OnChangeEdtR() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_bFromDec)
	{
		m_nRed = m_edtR.GetDigit();
		if(m_nRed > 255)
		{
			m_nRed = 255;
			m_edtR.SetDigit(m_nRed);
		}
		m_nGreen = m_edtG.GetDigit();
		m_nBlue  = m_edtB.GetDigit();

		m_nColor=m_nBlue;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nGreen;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nRed;
		m_stcColor.SetColor(m_nColor);
		Invalidate();
    
		m_nRGB=m_nRed;
		m_nRGB = m_nRGB<<8;
		m_nRGB |= m_nGreen;
		m_nRGB = m_nRGB<<8;
		m_nRGB |= m_nBlue;
		
		m_bFromHex = FALSE;
		m_edtRGB.SetDigit(m_nRGB);
		m_bFromHex = TRUE;

		UpdateData(FALSE);
	}

	
}

void CATransClrSetDlg::OnChangeEdtB() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData();
	CPoint pt = m_edtRGB.GetCaretPos();    
    int nIndex = LOWORD(m_edtRGB.CharFromPos(pt));

	if(m_bFromDec)
	{
		m_nBlue  = m_edtB.GetDigit();
		if(m_nBlue > 255)
		{
			m_nBlue = 255;
			m_edtB.SetDigit(m_nBlue);
		}

		CString strText;
		strText.Format(_T("%d"),m_nBlue);
//	    if(_tcslen(strText)==3)	
//		{

//			SetWindowText(strText);
//			for(int j=0;j<nIndex;j++)
//			{
//				keybd_event(VK_RIGHT,0,0,0);
//				keybd_event(VK_RIGHT,0,KEYEVENTF_KEYUP,0);
//			} 

// 		}

		m_nGreen = m_edtG.GetDigit();
		m_nRed = m_edtR.GetDigit();	
		
		m_nColor=m_nBlue;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nGreen;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nRed;
		m_stcColor.SetColor(m_nColor);
		Invalidate();
        

		m_nRGB=m_nRed;
		m_nRGB = m_nRGB<<8;
		m_nRGB |= m_nGreen;
		m_nRGB = m_nRGB<<8;
		m_nRGB |= m_nBlue;

		m_bFromHex = FALSE;
		m_edtRGB.SetDigit(m_nRGB);
		m_bFromHex = TRUE;

		UpdateData(FALSE);
	}

	
}

void CATransClrSetDlg::OnChangeEdtG() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_bFromDec)
	{
		m_nGreen = m_edtG.GetDigit();
		if(m_nGreen > 255)
		{
			m_nGreen = 255;
			m_edtG.SetDigit(m_nGreen);
		}

		m_nRed = m_edtR.GetDigit();
		m_nBlue  = m_edtB.GetDigit();

		m_nColor=m_nBlue;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nGreen;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nRed;
		m_stcColor.SetColor(m_nColor);
		Invalidate();
				
		m_nRGB=m_nRed;
		m_nRGB = m_nRGB<<8;
		m_nRGB |= m_nGreen;
		m_nRGB = m_nRGB<<8;
		m_nRGB |= m_nBlue;
		
		m_bFromHex = FALSE;
		m_edtRGB.SetDigit(m_nRGB);
		m_bFromHex = TRUE;

		UpdateData(FALSE);
	}

	
}

void CATransClrSetDlg::OnChangeEdtRgb() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here

	UpdateData();
	if(m_bFromHex)
	{
		m_nRGB = m_edtRGB.GetDigit();
		if(m_nRGB > 0xFFFFFF)
		{
			m_nRGB = 0xFFFFFF;
			m_edtRGB.SetDigit(m_nRGB);
		}
		
		m_nBlue    = m_nRGB & 0x0000FF;
		m_nGreen  = m_nRGB & 0x00FF00;
		m_nGreen  = m_nGreen >> 8;
		m_nRed  = m_nRGB & 0xFF0000;
		m_nRed   = m_nRed >> 16;
		
		m_nColor=m_nBlue;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nGreen;
		m_nColor = m_nColor<<8;
		m_nColor |= m_nRed;
		
		m_stcColor.SetColor(m_nColor);	
		Invalidate();
		
		m_bFromDec = FALSE;
		
		m_edtR.SetDigit(m_nRed);
		m_edtG.SetDigit(m_nGreen);
		m_edtB.SetDigit(m_nBlue);
		
		m_bFromDec = TRUE;

		UpdateData(FALSE);
	}	
}

⌨️ 快捷键说明

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