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

📄 setupdlg.cpp

📁 中国象棋网络版
💻 CPP
字号:
// setupdlg.cpp : implementation file
//

#include "stdafx.h"
#include "chineseqi.h"
#include "setupdlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// setupdlg dialog


setupdlg::setupdlg(CWnd* pParent /*=NULL*/)
	: CDialog(setupdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(setupdlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	mode=1;
	which=1;
	beok=FALSE;
	r=0;
	g=0;
	b=0;
	filename="";
}


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


BEGIN_MESSAGE_MAP(setupdlg, CDialog)
	//{{AFX_MSG_MAP(setupdlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(GRASS, OnGRASS)
	ON_BN_CLICKED(DAI, OnDAI)
	ON_BN_CLICKED(BAN, OnBAN)
	ON_BN_CLICKED(PINGPU, OnPINGPU)
	ON_BN_CLICKED(LA, OnLA)
	ON_BN_CLICKED(PUCENTER, OnPUCENTER)
	ON_BN_CLICKED(FILE, OnFILE)
	ON_BN_CLICKED(YUSE, OnYUSE)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_CBN_SELCHANGE(COLORBOX, OnSelchangeCOLORBOX)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// setupdlg message handlers

void setupdlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	myfiledlg dlg(TRUE,"*.bmp",filename,0,"*.bmp|*.bmp");
	dlg.DoModal();
	if(dlg.GetPathName()!="")
	{
		filename=dlg.GetPathName();
		m_static.draw(dlg.GetPathName());
	}

}

BOOL setupdlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_static.SubclassDlgItem(PREVIEW,this);	
	grassbutton.SubclassDlgItem(GRASS,this);
	 banbutton.SubclassDlgItem(BAN,this);
	daibutton.SubclassDlgItem(DAI,this);
	filebutton.SubclassDlgItem(FILE,this);
	yubutton.SubclassDlgItem(YUSE,this);
	pubutton.SubclassDlgItem(PINGPU,this);
	labutton.SubclassDlgItem(LA,this);
	cebutton.SubclassDlgItem(PUCENTER,this);
	openbutton.SubclassDlgItem(IDC_BUTTON1,this);
	colorbox.SubclassDlgItem(COLORBOX,this);
	st.SubclassDlgItem(STATICPRINTER,this);
	box.SubclassDlgItem(COMB,this);
	colorotherbox.SubclassDlgItem(IDC_OTHER,this);
	colormyselfbox.SubclassDlgItem(IDC_MYSELF,this);
	coloreditbox.SubclassDlgItem(IDC_EDIT,this);
	yubutton.EnableWindow(TRUE);
	grassbutton.EnableWindow(TRUE);
	banbutton.EnableWindow(TRUE);
	daibutton.EnableWindow(TRUE);
	yubutton.SetCheck(TRUE);
	grassbutton.SetCheck(TRUE);
	cebutton.SetCheck(TRUE);
	grassbutton.SetCheck(TRUE);
	m_static.clear();
	openbutton.EnableWindow(FALSE);
		switch(mode)
	{
	case 1:
		cebutton.SetCheck(FALSE);
		labutton.SetCheck(FALSE);
		pubutton.SetCheck(TRUE);
		break;
	case 2:
		cebutton.SetCheck(FALSE);
		labutton.SetCheck(TRUE);
		pubutton.SetCheck(FALSE);
		break;
	case 3:
		cebutton.SetCheck(TRUE);
		labutton.SetCheck(FALSE);
		pubutton.SetCheck(FALSE);
	}
	m_static.mode=mode;
	m_static.draw(BACK);
	DWORD cbBuffer = 16800;
	LPPRINTER_INFO_2 printerinfo;
	LPBYTE buf; 
	buf=new BYTE[16800];
	DWORD need;
	DWORD count;
	EnumPrinters(PRINTER_ENUM_LOCAL,NULL,2,buf,cbBuffer,&need,&count);
	printerinfo=(LPPRINTER_INFO_2)buf;
	for(int i=0;i<count;i++)
	{
		CString string;
		string.Format("%s",printerinfo->pPortName );
		box.AddString(printerinfo->pPrinterName);
		buf=buf+sizeof(PRINTER_INFO_2);
		printerinfo=(LPPRINTER_INFO_2)buf;
	//	printerinfo->
	//	MessageBox(string,"j");
		st.SetWindowText(string);
		
	}
	delete[] buf;
	if (filename!="")
	{
		openbutton.EnableWindow(TRUE);
		daibutton.EnableWindow(FALSE);
		grassbutton.EnableWindow(FALSE);
		banbutton.EnableWindow(FALSE);
		filebutton.SetCheck(TRUE);
		yubutton.SetCheck(FALSE);
		m_static.draw(filename);
	}
	colorbox.SetSelectedColorValue(RGB(r,g,b));
	colormyselfbox.SetSelectedColorValue(colormyself);
	coloreditbox.SetSelectedColorValue(coloredit);
	colorotherbox.SetSelectedColorValue(colorother);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void setupdlg::OnGRASS() 
{
	// TODO: Add your control notification handler code here
	banbutton.SetCheck(FALSE);
	daibutton.SetCheck(FALSE);
	if(grassbutton.GetCheck()==TRUE)
	{
		m_static.draw(BACK);
		which=1;
	}
}

void setupdlg::OnDAI() 
{
	// TODO: Add your control notification handler code here
	grassbutton.SetCheck(FALSE);
	banbutton.SetCheck(FALSE);
	if(daibutton.GetCheck()==TRUE)
	{
		m_static.draw(MADAI);
		which=2;
	}
}

void setupdlg::OnBAN() 
{
	// TODO: Add your control notification handler code here
	daibutton.SetCheck(FALSE);
	grassbutton.SetCheck(FALSE);
	if(banbutton.GetCheck()==TRUE)
	{
		m_static.draw(MUBAN);
		which=3;
	}
}

void setupdlg::OnPINGPU() 
{
	cebutton.SetCheck(FALSE);
	labutton.SetCheck(FALSE);
 if(pubutton.GetCheck())
 {
	 m_static.mode=1;
	 mode=1;
	 m_static.drawbody();
 }
}

void setupdlg::OnLA() 
{
	// TODO: Add your control notification handler code here
	pubutton.SetCheck(FALSE);
	cebutton.SetCheck(FALSE);
	if (labutton.GetCheck())
	{
		m_static.mode=2;
		mode=2;
		m_static.drawbody();
	}
}


void setupdlg::OnPUCENTER() 
{
		labutton.SetCheck(FALSE);
		pubutton.SetCheck(FALSE);
		m_static.mode=3;
		mode=3;
		m_static.drawbody();	
}

void setupdlg::OnFILE() 
{
	// TODO: Add your control notification handler code here
	yubutton.SetCheck(FALSE);
	grassbutton.EnableWindow(FALSE);
	banbutton.EnableWindow(FALSE);
	daibutton.EnableWindow(FALSE);
	openbutton.EnableWindow(TRUE);
	m_static.clear();
	if(filename!="")
		m_static.draw(filename);
}

void setupdlg::OnYUSE() 
{
	filebutton.SetCheck(FALSE);
	grassbutton.EnableWindow(TRUE);
	banbutton.EnableWindow(TRUE);
	daibutton.EnableWindow(TRUE);
	openbutton.EnableWindow(FALSE);
	grassbutton.SetCheck(TRUE);
	banbutton.SetCheck(FALSE);
	daibutton.SetCheck(FALSE);
	m_static.draw(BACK);
}

void setupdlg::OnOK() 
{
	// TODO: Add extra validation here
	beok=TRUE;
	int inde=colorbox.GetCurSel();
	COLORREF color=colorbox.GetSelectedColorValue();
	colormyself=colormyselfbox.GetSelectedColorValue();
	colorother=colorotherbox.GetSelectedColorValue();
	coloredit=coloreditbox.GetSelectedColorValue();
	r=GetRValue(color);
	g=GetGValue(color);
	b=GetBValue(color);
	if(filebutton.GetCheck()!=TRUE)
		filename="";
	CDialog::OnOK();
}

void setupdlg::OnButton2() 
{
	CString string;
	HANDLE printer;
	PRINTER_DEFAULTS def;
	int sel;
	if(box.GetCount()<1) return;
	sel=box.GetCurSel();
	box.GetLBText(sel,string);
	PRINTER_INFO_2 printerinf;
	DWORD need;
	OpenPrinter(string.GetBuffer(string.GetLength()),&printer,&def);
	GetPrinter(printer, 2,(LPBYTE)&printerinf,sizeof(PRINTER_INFO_2),&need);
	if(printerinf.Status==PRINTER_STATUS_WAITING)
	{
		MessageBox("

⌨️ 快捷键说明

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