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

📄 dlgdrawgraph.cpp

📁 Calculator program written by DLLs with the math algorithms such as automata and can draw some simpl
💻 CPP
字号:
// DlgDrawGraph.cpp : implementation file
//

#include "stdafx.h"
#include "CalculatorGUI.h"
#include "DlgDrawGraph.h"
#include "Lib/BalanceAl.h"
#include "Lib/Diagram.h"
#include "Lib/CalculatorDLL.h"
#include "Lib/MyPoint.h"
#include "Lib/DrawGraphFx.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgDrawGraph dialog


CDlgDrawGraph::CDlgDrawGraph(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgDrawGraph::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgDrawGraph)
	m_vA = _T("");
	m_vB = _T("");
	m_vFunction = _T("");
	//}}AFX_DATA_INIT
}


void CDlgDrawGraph::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgDrawGraph)
	DDX_Text(pDX, IDC_EDIT_A, m_vA);
	DDX_Text(pDX, IDC_EDIT_B, m_vB);
	DDX_Text(pDX, IDC_EDIT_FUCTION, m_vFunction);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgDrawGraph, CDialog)
	//{{AFX_MSG_MAP(CDlgDrawGraph)
	ON_WM_SIZE()
	ON_BN_CLICKED(IDC_BUTTON_DRAW, OnButtonDraw)
	ON_WM_ERASEBKGND()
	ON_WM_CTLCOLOR()
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgDrawGraph message handlers

void CDlgDrawGraph::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	maxxw = cx - 10;
	maxyw = cy - 10;
}

BOOL CDlgDrawGraph::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	minxw = 10;
	minyw = 50;

	SetBitmap(IDB_BITMAP1);

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

void CDlgDrawGraph::OnButtonDraw() 
{
	// TODO: Add your control notification handler code here
	char *f;
	
	UpdateData(TRUE);
	double a = strtod(m_vA,&f);
	double b = strtod(m_vB,&f);
	if((m_vFunction=="") || (m_vA=="") || (m_vB==""))	
	{
		MessageBox("Please, fill in all the blanks !!!");
	}
	else
	{
		m_vFunction.MakeLower();
		DrawGraphFx D;
		CClientDC dc(this);
		CString m;
		m = D.onDraw(&dc,m_vFunction,a,b,maxxw,minxw,maxyw,minyw);
		if(m != "")	
		{
			MessageBox(m);
		}
	}
	UpdateData(FALSE);
}

// Bat su kien phim enter

BOOL CDlgDrawGraph::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (pMsg->message == WM_KEYDOWN)
    {
        if (pMsg->wParam == VK_RETURN){
            pMsg->wParam = NULL;
			OnButtonDraw();
		}
    }

	return CDialog::PreTranslateMessage(pMsg);
}

// Tao bitmap background cho dialog

BOOL CDlgDrawGraph::OnEraseBkgnd(CDC* pDC) 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnEraseBkgnd(pDC);
	if(!m_bitmap.m_hObject)
		return true;
	
	CRect rect;
	GetClientRect(&rect);
	CDC dc;
	dc.CreateCompatibleDC(pDC);
	CBitmap* pOldBitmap = dc.SelectObject(&m_bitmap);
	int bmw, bmh ;
	BITMAP bmap;
	m_bitmap.GetBitmap(&bmap);
	bmw = bmap.bmWidth;
	bmh = bmap.bmHeight;
	int xo=0, yo=0;
	
	pDC->StretchBlt(xo, yo, rect.Width(), rect.Height(), &dc, 0, 0,bmw,bmh, SRCCOPY);
	
	dc.SelectObject(pOldBitmap);
	
	return true;
}

int CDlgDrawGraph::SetBitmap(UINT nIDResource)
{
	if(m_bitmap.LoadBitmap(nIDResource))
		return 0;
	else
		return 1;//error
}

// Transparent static text

HBRUSH CDlgDrawGraph::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr;
	
	if(nCtlColor == CTLCOLOR_STATIC)
	{
		pDC->SetBkMode(TRANSPARENT);
		hbr = (HBRUSH)GetStockObject(NULL_BRUSH);
	}
	
	return hbr;
}

void CDlgDrawGraph::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	if((m_vFunction != "") && (m_vA != "") && (m_vB != ""))	
	{
		OnButtonDraw();
	}
	// Do not call CDialog::OnPaint() for painting messages
}

⌨️ 快捷键说明

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