基于vc++的图的遍历算法的动态演示系统的设计与实现(含源文件)(6)

2019-04-14 10:11

3.2 stdafx.cpp和stdafx.h的实现

// stdafx.cpp : source file that includes just the standard includes // DFSearch.pch will be the pre-compiled header

// stdafx.obj will contain the pre-compiled type information #include \

// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but

#if !defined(AFX_STDAFX_H__B9C8068F_6175_4F03_B600_59C5D13E7899__INCLUDED_) #define

AFX_STDAFX_H__B9C8068F_6175_4F03_B600_59C5D13E7899__INCLUDED_

#if _MSC_VER > 1000 #pragma once

#endif // _MSC_VER > 1000

#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers

#include // MFC core and standard components #include // MFC extensions

#include // MFC support for Internet Explorer 4 Common Controls

#ifndef _AFX_NO_AFXCMN_SUPPORT #include Controls

#endif // _AFX_NO_AFXCMN_SUPPORT //{{AFX_INSERT_LOCATION}}

// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif

// !defined(AFX_STDAFX_H__B9C8068F_6175_4F03_B600_59C5D13E7899__INCLUDED_)

23

// MFC support for Windows Common

3.3TextWnd.cpp和TextWnd.h的实现 // TextWnd.cpp : implementation file #include \#include \#ifdef _DEBUG

#define new DEBUG_NEW #undef THIS_FILE

static char THIS_FILE[] = __FILE__; #endif // CTextWnd

//设置与窗口相关的静态Control. CTextWnd::CTextWnd(int IDC) { }

//按相关静态Control设置窗口大小,创立窗口。

BOOLCTextWnd::Create(LPCTSTRlpszClassName,LPCTSTRlpszWindowName, DWORDdwStyle,const RECT& rect, CWnd* pParentWnd, {

24

int i;

m_BK_Color = RGB(192, 192, 192); m_HI_BColor = RGB(255, 0, 0); m_Text_Color= RGB( 0, 128, 0); m_HI_TColor = RGB(255, 255, 255); m_Sentence_num = 0; for(i=0; i<50; i++)

m_Sentence_Flag[i] = 'A'; memset(m_Pos_Flag, 0, 6); m_ResetWnd = FALSE;

m_IDC=IDC;

m_X_Blank = 0;

UINTnID,CCreateContext* pContext)

// TODO: Add your specialized code here and/or call the base class CWnd *TextReg;

CRect Origin_Rect;

TextReg=pParentWnd->GetDlgItem(m_IDC); if(TextReg==NULL)throw(0);

TextReg->GetWindowRect(&Origin_Rect); Origin_Rect.DeflateRect(5,5);

m_Origin_Rect = Origin_Rect;

pParentWnd->ScreenToClient(&Origin_Rect); m_Width = Origin_Rect.Width(); m_Heigh = Origin_Rect.Height();

return

CWnd::Create(lpszClassName,

dwStyle,

Origin_Rect, pParentWnd, nID, pContext); }

void CTextWnd::SetTextWnd() { CPaintDC dc(this); // device context for painting CSize Size;

Size = dc.GetOutputTextExtent(\ \ m_X_Blank = Size.cx/10; m_Y = Size.cy + 1;

m_Blank_Num = m_Width/m_X_Blank; m_X_Start = m_X_Blank * 10; m_Blank_String.Empty();

for(int i=0; i

m_Blank_String += ' ';

m_Brush = dc.GetCurrentBrush(); CTextWnd::~CTextWnd() {

for(int i=0; i<50; i++)

25

lpszWindowName,

}

{

if(!m_Sentence[i].IsEmpty()) }

m_Sentence[i].Empty();

m_Blank_String.Empty();

BEGIN_MESSAGE_MAP(CTextWnd, CWnd)

//{{AFX_MSG_MAP(CTextWnd) ON_WM_PAINT() //}}AFX_MSG_MAP

END_MESSAGE_MAP() // CTextWnd message handlers void CTextWnd::OnPaint() {

CPaintDC dc(this); // device context for painting // TODO: Add your message handler code here int i, j;

if(m_ResetWnd) { }

for(i=0,j=1; i

if(m_Sentence_Flag[i]=='L') {

26

for(i=0,j=1; i<50; i++) //进行50次的循环 { }

m_ResetWnd = FALSE;

dc.TextOut(m_X_Blank, j, m_Blank_String); dc.TextOut(m_X_Start, j, m_Blank_String); j += m_Y;

dc.SetBkColor(m_HI_BColor);

dc.TextOut(m_X_Blank, j, m_Pos_Flag, 4); //\● \or \

dc.TextOut(m_X_Start, j, m_Blank_String); dc.TextOut(m_X_Start, j, m_Sentence[i]);

}

else if(m_Sentence_Flag[i]=='A') //判断数组是否等于A { dc.SetBkColor(m_HI_TColor); dc.SetTextColor(m_HI_TColor);

dc.TextOut(m_X_Blank, j, m_Pos_Flag, 4); //\● \

dc.SetBkColor(m_BK_Color);

dc.SetTextColor(m_Text_Color);

dc.TextOut(m_X_Start, j, m_Blank_String); dc.TextOut(m_X_Start, j, m_Sentence[i]);

} j += m_Y;

}

dc.SetBkColor(m_HI_TColor); dc.SetTextColor(m_HI_TColor);

dc.TextOut(m_X_Blank, j, m_Pos_Flag, 4); //\● \ dc.TextOut(m_X_Start, j, m_Blank_String);

// Do not call CWnd::OnPaint() for painting messages

3.4 resource.h的实现 //{{NO_DEPENDENCIES}}

// Microsoft Developer Studio generated include file. // Used by DFSearch.rc

#define IDCANCEL2 3 #define IDD_DFSEARCH_DIALOG 102 #define IDR_MAINFRAME 128

27

\or


基于vc++的图的遍历算法的动态演示系统的设计与实现(含源文件)(6).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:餐饮业客户关系管理研究

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: