diranddfview.cpp

来自「帮人做的一个心理测试小程序」· C++ 代码 · 共 188 行

CPP
188
字号
// DirAndDFView.cpp : implementation of the CDirAndDFView class
//

#include "stdafx.h"
#include "DirAndDF.h"

#include "DirAndDFDoc.h"
#include "DirAndDFView.h"
#include "ShowDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDirAndDFView

IMPLEMENT_DYNCREATE(CDirAndDFView, CFormView)

BEGIN_MESSAGE_MAP(CDirAndDFView, CFormView)
	//{{AFX_MSG_MAP(CDirAndDFView)
	ON_BN_CLICKED(IDC_START, OnStart)
	ON_WM_TIMER()
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDirAndDFView construction/destruction

CDirAndDFView::CDirAndDFView()
	: CFormView(CDirAndDFView::IDD)
{
	//{{AFX_DATA_INIT(CDirAndDFView)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CDirAndDFView::~CDirAndDFView()
{
}

void CDirAndDFView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDirAndDFView)
	DDX_Control(pDX, IDC_START, m_start);
	//}}AFX_DATA_MAP
}

BOOL CDirAndDFView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CDirAndDFView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();
	
	h_BlackBrush=(HBRUSH)GetStockObject(BLACK_BRUSH);
}

/////////////////////////////////////////////////////////////////////////////
// CDirAndDFView printing

BOOL CDirAndDFView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CDirAndDFView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CDirAndDFView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CDirAndDFView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CDirAndDFView diagnostics

#ifdef _DEBUG
void CDirAndDFView::AssertValid() const
{
	CFormView::AssertValid();
}

void CDirAndDFView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CDirAndDFDoc* CDirAndDFView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDirAndDFDoc)));
	return (CDirAndDFDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDirAndDFView message handlers

void CDirAndDFView::OnDraw(CDC* pDC) 
{					// 
	
		CFont m_fontLogo;
		m_fontLogo.CreateFont(30,0,0, 0, 40, FALSE, FALSE,0,0,0,0,0,0, "Arial");
		pDC->SetBkMode(TRANSPARENT);
		CFont * OldFont =pDC->SelectObject(&m_fontLogo);
		COLORREF OldColor = pDC->SetTextColor( ::GetSysColor(COLOR_3DSHADOW));
        pDC->SetTextColor(RGB(255,0,255));
  //  pDC->SetTextColor(RGB(255,0,0));

		pDC->SetBkColor(RGB(255,0,0));
		
		
	// TODO: Add your specialized code here and/or call the base class
	pDC->TextOut(25,30,"        本实验是有关指向性遗忘的研究。在实验你会看到一些常用汉语词,每个词");
	pDC->TextOut(25,80,"后会跟着出现一个指示符。指示符有三种:其一是√,看到它你要力争记住它前");
	pDC->TextOut(25,130,"面呈现的那个词;其二是Χ,看到它你要努力遗忘它前面呈现的那个词;还有一");
	pDC->TextOut(25,180,"种О符号,它表示前面呈现的词与实验目的无关,可以不用管它。下面是几个练");
	pDC->TextOut(25,230,"习:(水果Χ  汽车√  玩具О)有问题吗?好,下面开始正式实验。");
	pDC->SelectObject(OldFont);
//	ReleaseDC(pDC);
}

void CDirAndDFView::OnStart() 
{
	// TODO: Add your control notification handler code here
	

//	g=0;
//	SetTimer( 0, 300, NULL);

	CShowDlg dlg;
	dlg.DoModal();
		
//	SetTimer(1,3500,NULL);
//	SetTimer(2,6500,NULL);
}

void CDirAndDFView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	//CTextDlg dlg;
	//dlg.DoModal();
	//KillTimer(0);
	CFormView::OnTimer(nIDEvent);
}

HBRUSH CDirAndDFView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	if(nCtlColor == CTLCOLOR_DLG){
		pDC->SetBkColor(RGB(0,0,0));
		return h_BlackBrush;
	}
	if(nCtlColor == CTLCOLOR_BTN){
		pDC->SetBkColor(RGB(0,0,0));
		return h_BlackBrush;
	}
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

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