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

📄 setcolorstydlg.cpp

📁 一个LED楼宇亮化同步控制源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// SetColorStyDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SetColorSty.h"
#include "SetColorStyDlg.h"
#include "PropSheet.h"
#include "setSty.h"
#include "start.h"

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About


class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetColorStyDlg dialog

CSetColorStyDlg::CSetColorStyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSetColorStyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetColorStyDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CSetColorStyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetColorStyDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSetColorStyDlg, CDialog)
	//{{AFX_MSG_MAP(CSetColorStyDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnSetPro)
	ON_BN_CLICKED(IDC_BUTTON_RUN, OnButtonRun)
	ON_BN_CLICKED(IDC_BUTTON3, OnButtonAreaSet)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetColorStyDlg message handlers

BOOL CSetColorStyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.
	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	int r,g,b;
	CString strTemp;
	CString strTempName;
	for(int i=0;i<3;i++)
	{
		strTempName.Format("%d",i+1);
	    m_iHigh[i]=::GetPrivateProfileInt("Page"+strTempName,"H",40,".\\Init.ini");
	    m_iWidth[i]=::GetPrivateProfileInt("Page"+strTempName,"W",40,".\\Init.ini");
	    m_staPointx[i]=::GetPrivateProfileInt("Page"+strTempName,"X",0,".\\Init.ini");
	    m_staPointy[i]=::GetPrivateProfileInt("Page"+strTempName,"Y",0,".\\Init.ini");
        m_count[i]=::GetPrivateProfileInt("Page"+strTempName,"Count",0,".\\Init.ini");
    	r=::GetPrivateProfileInt("Page"+strTempName,"Red",0,".\\Init.ini");
	    g=::GetPrivateProfileInt("Page"+strTempName,"Green",0,".\\Init.ini");
	    b=::GetPrivateProfileInt("Page"+strTempName,"Blue",0,".\\Init.ini");
		m_actpage[i]=::GetPrivateProfileInt("Page"+strTempName,"act",0,".\\Init.ini");
	    m_color[i].SetColor(r,g,b);
	}
	for(int index=0;index<int(m_count[0]);index++)
	{
	     strTemp.Format("%d",index);
		 //读取区域1的初始列表 
		 m_fstyList[index]=::GetPrivateProfileInt("Page1List",strTemp,0,".\\Init.ini");
		 
		 //读取区域1的颜色列表
		 m_rgbColor[0][index].m_Red=::GetPrivateProfileInt("Page1ColorList",strTemp+"r",0,".\\Init.ini");
	     m_rgbColor[0][index].m_Green=::GetPrivateProfileInt("Page1ColorList",strTemp+"g",0,".\\Init.ini");
		 m_rgbColor[0][index].m_Blue=::GetPrivateProfileInt("Page1ColorList",strTemp+"b",0,".\\Init.ini");

	}
	for(index=0;index<int(m_count[1]);index++)
	{
	    strTemp.Format("%d",index);
		//读取区域二的初始列表 
		m_sstyList[index]=::GetPrivateProfileInt("Page2List",strTemp,0,".\\Init.ini");

		//读取区域二的颜色列表
		m_rgbColor[1][index].m_Red=::GetPrivateProfileInt("Page2ColorList",strTemp+"r",0,".\\Init.ini");
	    m_rgbColor[1][index].m_Green=::GetPrivateProfileInt("Page2ColorList",strTemp+"g",0,".\\Init.ini");
		m_rgbColor[1][index].m_Blue=::GetPrivateProfileInt("Page2ColorList",strTemp+"b",0,".\\Init.ini");
	}
	for(index=0;index<int(m_count[2]);index++)
	{
	    strTemp.Format("%d",index);
	    m_tstyList[index]=::GetPrivateProfileInt("Page3List",strTemp,0,".\\Init.ini");
		m_rgbColor[2][index].m_Red=::GetPrivateProfileInt("Page3ColorList",strTemp+"r",0,".\\Init.ini");
	    m_rgbColor[2][index].m_Green=::GetPrivateProfileInt("Page3ColorList",strTemp+"g",0,".\\Init.ini");
		m_rgbColor[2][index].m_Blue=::GetPrivateProfileInt("Page3ColorList",strTemp+"b",0,".\\Init.ini");

	}
    m_winX=::GetPrivateProfileInt("Win","winX",0,".\\Init.ini");
    m_winY=::GetPrivateProfileInt("Win","winY",0,".\\Init.ini");
	m_winW=::GetPrivateProfileInt("Win","winW",0,".\\Init.ini");
	m_winH=::GetPrivateProfileInt("Win","winH",0,".\\Init.ini");
	
	run.Create(IDD_DIALOG_RUN,this);
	run.ShowWindow(SW_SHOW);
	run.MoveWindow(m_winX,m_winY,m_winW,m_winH);
	run.SetWindowPos(&wndTopMost, m_winX, m_winY, m_winW, m_winH, SWP_SHOWWINDOW);
 
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSetColorStyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CSetColorStyDlg::OnPaint() 
{
	//MessageBox("123");
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;                                                                                                                                                                                                                                                    

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{   
		CDialog::OnPaint();
	}

}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CSetColorStyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CSetColorStyDlg::OnOK() 
{
	CDialog::OnOK();
}

void CSetColorStyDlg::OnSetPro() 
{
	// TODO: Add your control notification handler code here
	CPropSheet propSheet("属性设置");
	//设置区域一
    for(int index=0;index<int(m_count[0]);index++)
	{
		List[0][index]=m_fstyList[index];
	}
	for(index=0;index<int(m_count[0]);index++)//设置颜色
	{
		propSheet.m_prop1.Color[index]=m_rgbColor[0][index];
	}
    propSheet.m_prop1.m_count=m_count[0];
	propSheet.m_prop1.m_sldRedValue=m_color[0].m_Red*100/255;
	propSheet.m_prop1.m_sldBlueValue=m_color[0].m_Blue*100/255;
    propSheet.m_prop1.m_sldGreenValue=m_color[0].m_Green*100/255;
    
	propSheet.m_prop1.m_edtRedValue.Format("%d",m_color[0].m_Red);
    propSheet.m_prop1.m_edtGreenValue.Format("%d",m_color[0].m_Green);
    propSheet.m_prop1.m_edtBlueValue.Format("%d",m_color[0].m_Blue);

    //设置区域二
	for(index=0;index<int(m_count[1]);index++)
	{
		List[1][index]=m_sstyList[index];
	}
	for(index=0;index<int(m_count[1]);index++)//设置颜色
	{
		propSheet.m_prop2.Color[index]=m_rgbColor[1][index];
	}

    propSheet.m_prop2.m_count=m_count[1];
	propSheet.m_prop2.m_sldRedValue=m_color[1].m_Red*100/255;
	propSheet.m_prop2.m_sldBlueValue=m_color[1].m_Blue*100/255;
    propSheet.m_prop2.m_sldGreenValue=m_color[1].m_Green*100/255;

	propSheet.m_prop2.m_edtRedValue.Format("%d",m_color[1].m_Red);
    propSheet.m_prop2.m_edtGreenValue.Format("%d",m_color[1].m_Green);
    propSheet.m_prop2.m_edtBlueValue.Format("%d",m_color[1].m_Blue);

	//设置区域三
	for( index=0;index<int(m_count[2]);index++)
	{
		List[2][index]=m_tstyList[index];
	}
	for(index=0;index<int(m_count[2]);index++)//设置颜色
	{
		propSheet.m_prop3.Color[index]=m_rgbColor[2][index];
	}
	propSheet.m_prop3.m_count=m_count[2];
	propSheet.m_prop3.m_sldRedValue=m_color[2].m_Red*100/255;
	propSheet.m_prop3.m_sldBlueValue=m_color[2].m_Blue*100/255;
    propSheet.m_prop3.m_sldGreenValue=m_color[2].m_Green*100/255;

	propSheet.m_prop3.m_edtRedValue.Format("%d",m_color[2].m_Red);
    propSheet.m_prop3.m_edtGreenValue.Format("%d",m_color[2].m_Green);
    propSheet.m_prop3.m_edtBlueValue.Format("%d",m_color[2].m_Blue);

    count[0]=m_count[0];
	count[1]=m_count[1];
    count[2]=m_count[2];
//	propSheet.m_prop1.InitColor();
    propSheet.m_prop1.Color[0]=m_color[0];
    propSheet.m_prop2.Color[0]=m_color[1];
	propSheet.m_prop3.Color[0]=m_color[2];
	
   
	if(IDOK==propSheet.DoModal())
	{
        //m_color[0]=propSheet.m_prop1.Color[0];//颜色设置
		//m_color[1]=propSheet.m_prop2.Color;
		//m_color[2]=propSheet.m_prop3.Color;
	    m_count[0]=count[0]; //列表中节目数
		m_count[1]=count[1];
		m_count[2]=count[2];
		for(int index=0;index<int(m_count[0]);index++)
		{
			m_rgbColor[0][index]=propSheet.m_prop1.Color[index];
			
		}
        for(int i=0;i<int(m_count[0]);i++)
		{
	          m_fstyList[i]=List[0][i];//记录下播放列表
		}


		for(index=0;index<int(m_count[1]);index++)
		{
			m_rgbColor[1][index]=propSheet.m_prop2.Color[index];	
		}
		for(i=0;i<int(m_count[1]);i++)
		{
	          m_sstyList[i]=List[1][i];//记录下播放列表
		}

		
        for(index=0;index<int(m_count[2]);index++)
		{

⌨️ 快捷键说明

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