www.gusucode.com > 一个VC++ GUI测试程序-源码程序 > 一个VC++ GUI测试程序-源码程序/code/Test4Dlg.cpp

    //Download by http://www.NewXing.com
// Test4Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "guitest.h"
#include "Test4Dlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTest4Dlg dialog


CTest4Dlg::CTest4Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTest4Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTest4Dlg)
	m_String = _T("");
	//}}AFX_DATA_INIT
}


void CTest4Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTest4Dlg)
	DDX_Control(pDX, IDC_BUTTON1, m_color);
	DDX_Control(pDX, IDC_STATIC_GRA, m_Gra);
	DDX_Control(pDX, IDC_CHECK1, m_check1);
	DDX_Control(pDX, IDC_TREE1, m_OptionsTreeCtrl);
	DDX_Control(pDX, IDC_STATIC3, m_Label3);
	DDX_Control(pDX, IDC_STATIC2, m_Label2);
	DDX_Control(pDX, IDC_STATIC1, m_Label1);
	DDX_Text(pDX, IDC_EDIT1, m_String);
	DDV_MaxChars(pDX, m_String, 255);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTest4Dlg, CDialog)
	//{{AFX_MSG_MAP(CTest4Dlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTest4Dlg message handlers

BOOL CTest4Dlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_Label3.SetBackgroundColour( RGB(6,60,60) );
	m_Label3.SetMainTextColour( RGB(200,200,250) );
	m_Label3.SetSubTextColour( RGB(200,200,250) );
	m_Label3.SetDrawShadow(false);
	m_Label3.SetAlignCentre();
	m_Label3.Display("The fade controls below form the attraction of this demo:", "", 100);

	COLORREF crVerse = RGB(190,190,250);
	COLORREF crReference = RGB(120,120,150);
	COLORREF crBackground = RGB(30,30,60);

	m_Label1.SetBackgroundColour( crBackground );
	m_Label1.SetMainTextColour( RGB(250,250,255) );
	m_Label1.Display("The Book of Isaiah","",10);

	m_Label2.SetDrawBorder(false);
	m_Label2.Initialise( crBackground, crVerse, crReference );
	m_Label2.Display("Do not call conspiracy everything that these people call conspiracy;","8:12",30);

	//
	CFont newfont;
	newfont.CreateFont(12,0,0,0,FW_MEDIUM,0,0,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH|FF_DONTCARE,"Arial");
	m_OptionsTreeCtrl.SetFont(&newfont);
	m_OptionsTreeCtrl.m_pOptions=&m_Options;
	//

	m_Options.SetOption("RadioOption1", 0);
	m_Options.SetOption("RadioOption2", 1);
	m_Options.SetOptionItem("Radio Options", IDB_ITEMS, IDB_ITEMS);
	m_Options.SetOptionItem("RadioOption1", "\tSelection 0", 0, IDB_RADIOON, IDB_RADIOOFF);
	m_Options.SetOptionItem("RadioOption1", "\tSelection 1", 1, IDB_RADIOON, IDB_RADIOOFF);
	m_Options.SetOptionItem("RadioOption1", "\tSelection 2", 2, IDB_RADIOON, IDB_RADIOOFF);
		m_Options.SetOptionItem("RadioOption2", "\t\tSelection 0", 0, IDB_RADIOON, IDB_RADIOOFF);
		m_Options.SetOptionItem("RadioOption2", "\t\tSelection 1", 1, IDB_RADIOON, IDB_RADIOOFF);
	m_Options.SetOptionItem("RadioOption1", "\tSelection 3", 3, IDB_RADIOON, IDB_RADIOOFF);

	m_Options.SetOptionItem("Check Options", IDB_ITEMS, IDB_ITEMS);
	m_Options.SetOption("CheckOption1", COptions::CheckFalse);
	m_Options.SetOptionItem("CheckOption1", "\tCheck 1", COptions::CheckTrue, IDB_CHECKON, IDB_CHECKOFF);
		m_Options.SetOption("RadioOption3", 1);
		m_Options.SetOptionItem("RadioOption3", "\t\tSelection 0", 0, IDB_RADIOON, IDB_RADIOOFF);
		m_Options.SetOptionItem("RadioOption3", "\t\tSelection 1", 1, IDB_RADIOON, IDB_RADIOOFF);
	m_Options.SetOption("CheckOption2", COptions::CheckTrue);
	m_Options.SetOptionItem("CheckOption2", "\tCheck 2", COptions::CheckTrue, IDB_CHECKON, IDB_CHECKOFF);

	m_OptionsTreeCtrl.Initialize(NULL);
	
	m_check1.SetIcon(AfxGetApp()->LoadIcon(IDI_ICON2));

	m_Gra.SetStartColor(RGB(68,98,156));
	m_Gra.SetEndColor(RGB(170,190,248));
	CString title;
	m_Gra.GetWindowText(title);
	m_Gra.SetTitle(title);

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

#include "MathParser.h"
void CTest4Dlg::OnButton1() 
{
	UpdateData(TRUE);
	CMathParser Parser(m_String);
	
	Parser.Parse();

	CString retstring;
	if(Parser.ParseError == TRUE)
		retstring="计算错误";
	else
		retstring.Format("%f", Parser.ParseValue);

	AfxMessageBox(retstring);	
}