1、VC+ PROJECTECJTUNAME STUDENT IDLIU * 2*LI * 2*DAI * 2*WANG * 2*ZUO * 2*STUDENT CLASS:CLASS 1MAJOR: 2*CertificateThis to certify that the following students:1. Liu *,and Student ID No is 2*2. Li * and Student ID No is 2*3. Dai * and Student ID No is 2*4. Wang * and Student ID No is 2*5. Zuo * and Stu
2、dent ID No is 2*are done this project under the guidance and supervision of MR.RAVI and it is submitted to the East China JiaoTong University as partial fulfillment of Software and Machanic / Overrides/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CSkyblue_LLKApp)public:virtual BOOL
3、InitInstance();/AFX_VIRTUAL/ Implementation/AFX_MSG(CSkyblue_LLKApp)/ NOTE - the ClassWizard will add and remove member functions here./ DO NOT EDIT what you see in these blocks of generated code !/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarat
4、ions immediately before the previous line.#endif / !defined(AFX_SKYBLUE_LLK_H_A2AA2546_B9F0_4250_9623_03889A3B311A_INCLUDED_)skyblue_LLK.cpp/ skyblue_LLK.cpp : Defines the class behaviors for the application./#include “stdafx.h“#include “skyblue_LLK.h“#include “skyblue_LLKDlg.h“#ifdef _DEBUG#define
5、new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CSkyblue_LLKAppBEGIN_MESSAGE_MAP(CSkyblue_LLKApp, CWinApp)/AFX_MSG_MAP(CSkyblue_LLKApp)/ NOTE - the ClassWizard will add and remove mapping macros here./ DO NOT EDIT what you see in these blocks of generated code!/AFX_MSGON_COMMAND(
6、ID_HELP, CWinApp:OnHelp)END_MESSAGE_MAP()/ CSkyblue_LLKApp constructionCSkyblue_LLKApp:CSkyblue_LLKApp()/ TODO: add construction code here,/ Place all significant initialization in InitInstance/ The one and only CSkyblue_LLKApp objectCSkyblue_LLKApp theApp;/ CSkyblue_LLKApp initializationBOOL CSkybl
7、ue_LLKApp:InitInstance()AfxEnableControlContainer();/ Standard initialization/ If you are not using these features and wish to reduce the size/ of your final executable, you should remove from the following/ the specific initialization routines you do not need.C_LLK_Dlg dlg;m_pMainWnd = int nRespons
8、e = dlg.DoModal();if (nResponse = IDOK)/ TODO: Place code here to handle when the dialog is/ dismissed with OKelse if (nResponse = IDCANCEL)/ TODO: Place code here to handle when the dialog is/ dismissed with Cancel/ Since the dialog has been closed, return FALSE so that we exit the/ application, ra
9、ther than start the applications message pump.return FALSE;Resource.h/NO_DEPENDENCIES/ Microsoft Developer Studio generated include file./ Used by skyblue_LLK.rc/#define IDD_SKYBLUE_LLK_DIALOG 102#define IDD_LLK_DIALOG 102#define IDR_MAINFRAME 128#define IDB_BMP_ANIMAL 130#define IDB_BITMAP_3D_FRAME
10、S 131/ Next default values for new objects/ #ifdef APSTUDIO_INVOKED#ifndef APSTUDIO_READONLY_SYMBOLS#define _APS_NEXT_RESOURCE_VALUE 132#define _APS_NEXT_COMMAND_VALUE 32771#define _APS_NEXT_CONTROL_VALUE 1000#define _APS_NEXT_SYMED_VALUE 101#endif#endifskyblue_LLKDlg.h/*+Copyright (c) AFE(Active-Fr
11、ee-Elegance)Module Name:skyblue_LLKDlg.hAbstract:LLK-Games kernal-solving DialogAuthor:Weijian Luo (Arthur Luo) 15-Jun-2005E-mail: Revision History: 1.0-*/#if !defined(AFX_SKYBLUE_LLKDLG_H_F043F328_5562_4EEC_921D_508E1DBDC900_INCLUDED_)#define AFX_SKYBLUE_LLKDLG_H_F043F328_5562_4EEC_921D_508E1DBDC90
12、0_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000/ C_LLK_Dlg dialogclass C_LLK_Dlg : public CDialog/ Constructionpublic:/GameDrawvoid GameDraw(CDC * pDC);/StartNewGamevoid StartNewGame();BOOL IsLink(int x1,int y1,int x2,int y2);BOOL IsWin(void);/X=BOOL X1_Link_X2(int x,int y1,int y2);/Y
13、=BOOL Y1_Link_Y2(int x1,int x2,int y);BOOL OneCornerLink(int x1,int y1,int x2,int y2);BOOL TwoCornerLink(int x1,int y1,int x2,int y2);BOOL YThrough(int x,int y,BOOL bAdd);BOOL XThrough(int x,int y,BOOL bAdd);BOOL LineX(int x,int y1,int y2);BOOL LineY(int x1,int x2,int y);C_LLK_Dlg(CWnd* pParent = NU
14、LL);/ standard constructorC_LLK_Dlg();/ Dialog Data/AFX_DATA(CTemp2Dlg)enum IDD = IDD_LLK_DIALOG ;/ NOTE: the ClassWizard will add data members here/AFX_DATA/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CTemp2Dlg)public:virtual BOOL PreTranslateMessage(MSG* pMsg);protected:virtual v
15、oid DoDataExchange(CDataExchange* pDX); / DDX/DDV support/AFX_VIRTUAL/ Implementationprotected:HICON m_hIcon;CDC m_mem3DBkDC; CBitmap m_mem3DBkBmp; CDC m_memAnimalDC; CBitmap m_memAnimalBmp; CDC m_MemDC; CBitmap m_memBitmap; /地图位置相关属性组int* m_map; int m_nRow; int m_nCol; int m_nX1; int m_nY1; / Gener
16、ated message map functions/AFX_MSG(CTemp2Dlg)virtual BOOL OnInitDialog();afx_msg void OnPaint();afx_msg HCURSOR OnQueryDragIcon();afx_msg void OnLButtonDown(UINT nFlags, CPoint point);/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediat
17、ely before the previous line.#endif / !defined(AFX_SKYBLUE_LLKDLG_H_F043F328_5562_4EEC_921D_508E1DBDC900_INCLUDED_)stdafx.h/ stdafx.h : include file for standard system include files,/ or project specific include files that are used frequently, but/ are changed infrequently/#if !defined(AFX_STDAFX_H
18、_F66DEF85_CF00_4F60_8D9D_B3BBB3169771_INCLUDED_)#define AFX_STDAFX_H_F66DEF85_CF00_4F60_8D9D_B3BBB3169771_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 extensi
19、ons#include / MFC Automation classes#include / MFC support for Internet Explorer 4 Common Controls#ifndef _AFX_NO_AFXCMN_SUPPORT#include / MFC support for Windows Common Controls#endif / _AFX_NO_AFXCMN_SUPPORT/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately b
20、efore the previous line.#endif / !defined(AFX_STDAFX_H_F66DEF85_CF00_4F60_8D9D_B3BBB3169771_INCLUDED_)skyblue_LLKDlg.cpp/*+Copyright (c) AFE(Active-Free-Elegance)Module Name:skyblue_LLKDlg.cppAbstract:LLK-Games kernal-solving DialogAuthor:Weijian Luo (Arthur Luo) 15-Jun-2005E-mail: Revision History:
21、 1.0-*/#include “stdafx.h“#include “skyblue_LLK.h“#include “skyblue_LLKDlg.h“#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ C_LLK_Dlg dialog#define BKCOLOR RGB(128,128,128)#define FRONTWIDTH (39+2) #define FRONTHEIGHT (39+12) #define BKWIDTH 46#define BKHEIG
22、HT 56#define ROWCOUNT 7#define COLCOUNT 12#define BLANK_STATE -1 / C_LLK_Dlg dialogC_LLK_Dlg:C_LLK_Dlg(CWnd* pParent /*=NULL*/): CDialog(C_LLK_Dlg:IDD, pParent)/AFX_DATA_INIT(C_LLK_Dlg)/ NOTE: the ClassWizard will add member initialization here/AFX_DATA_INIT/ Note that LoadIcon does not require a su
23、bsequent DestroyIcon in Win32m_hIcon = AfxGetApp()-LoadIcon(IDR_MAINFRAME);m_nY1= BLANK_STATE;m_nX1= BLANK_STATE;m_nRow=ROWCOUNT;m_nCol=COLCOUNT;m_map=new intm_nRow*m_nCol;C_LLK_Dlg:C_LLK_Dlg()delete m_map;void C_LLK_Dlg:DoDataExchange(CDataExchange* pDX)CDialog:DoDataExchange(pDX);/AFX_DATA_MAP(C_L
24、LK_Dlg)/ NOTE: the ClassWizard will add DDX and DDV calls here/AFX_DATA_MAPBEGIN_MESSAGE_MAP(C_LLK_Dlg, CDialog)/AFX_MSG_MAP(C_LLK_Dlg)ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_WM_LBUTTONDOWN()/AFX_MSG_MAPEND_MESSAGE_MAP()/ C_LLK_Dlg message handlersBOOL C_LLK_Dlg:OnInitDialog()CDialog:OnInitDialog();/ S
25、et the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big iconSetIcon(m_hIcon, FALSE); / Set small iconCDC *pWinDC = GetDC();m_mem3DBkDC.CreateCompatibleDC(pWinDC);m_mem3DBkBmp.LoadBitmap(IDB_BITMAP_3D_FRAME
26、S);m_mem3DBkDC.SelectObject(m_memAnimalDC.CreateCompatibleDC(pWinDC);m_memAnimalBmp.LoadBitmap(IDB_BMP_ANIMAL);m_memAnimalDC.SelectObject(m_MemDC.CreateCompatibleDC(pWinDC);m_memBitmap.CreateCompatibleBitmap(pWinDC,m_nCol*FRONTWIDTH+5,m_nRow*FRONTHEIGHT+5);m_MemDC.SelectObject(StartNewGame();HWND hW
27、nd = :AfxGetMainWnd()-m_hWnd;:SetWindowPos(hWnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);return TRUE; / return TRUE unless you set the focus to a controlvoid C_LLK_Dlg:StartNewGame()for(int iNum=0;iNumFillSolidRect(0,0,m_nCol*FRONTWIDTH+5,m_nRow*FRONTHEIGHT+5,BKCOLOR);for(int i=0;iBitBlt(j*FRONTW
28、IDTH,i*FRONTHEIGHT,BKWIDTH,BKHEIGHT,pDC-BitBlt(j*FRONTWIDTH,i*FRONTHEIGHT,FRONTWIDTH-2,FRONTHEIGHT-12,pDC-BitBlt(j*FRONTWIDTH,i*FRONTHEIGHT,FRONTWIDTH-2,FRONTHEIGHT-12,/ The system calls this to obtain the cursor to display while the user drags/ the minimized window.HCURSOR C_LLK_Dlg:OnQueryDragIcon
29、()return (HCURSOR) m_hIcon;/ If you add a minimize button to your dialog, you will need the code below/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void C_LLK_Dlg:OnPaint() CPaintDC dc(this); / device context for painting
30、GameDraw(dc.BitBlt(0,0,m_nCol*FRONTWIDTH,m_nCol*FRONTHEIGHT,/void C_LLK_Dlg:OnLButtonDown(UINT nFlags, CPoint point) int x=point.x/FRONTWIDTH+(point.x%FRONTWIDTH?1:0)-1;int y=point.y/FRONTHEIGHT+(point.y%FRONTHEIGHT?1:0)-1;if(xSelectObject(pWinDC-MoveTo(x*FRONTWIDTH,y*FRONTHEIGHT);pWinDC-LineTo(x*FR
31、ONTWIDTH,(y+1)*FRONTHEIGHT);pWinDC-LineTo(x+1)*FRONTWIDTH,(y+1)*FRONTHEIGHT);pWinDC-LineTo(x+1)*FRONTWIDTH,y*FRONTHEIGHT);pWinDC-LineTo(x*FRONTWIDTH,y*FRONTHEIGHT);pWinDC-SelectObject(pOldPen);else if(m_nX1!=x|m_nY1!=y)m_mapy*m_nCol+x=BLANK_STATE;m_nX1=BLANK_STATE; m_nY1=BLANK_STATE;Invalidate(FALSE
32、);if(IsWin()MessageBox(“恭喜您胜利闯关,即将开始新局“);StartNewGame();/BOOL C_LLK_Dlg:X1_Link_X2(int x, int y1,int y2)if(y1y2)int n=y1;y1=y2;y2=n;for(int i=y1+1;ix2)int x=x1;x1=x2;x2=x;for(int i=x1+1;iy2)int y=y1;y1=y2;y2=y;for(int y=y1;yx2)int x=x1;x1=x2;x2=x;for(int x=x1;xx2)int n=x1;x1=x2;x2=n;n=y1;y1=y2;y2=n;
33、if(y2x2)int n=x1;x1=x2;x2=n;n=y1;y1=y2;y2=n;if(XThrough(x1+1,y1,TRUE)if(XThrough(x1-1,y1,FALSE)if(YThrough(x1,y1-1,FALSE)if(YThrough(x1,y1+1,TRUE)for(int x=x1+1;x-1)break;if(OneCornerLink(x,y1,x2,y2)return TRUE;for(x=x1-1;x-1;x-)if(m_mapy1*m_nCol+x!=BLANK_STATE)break;if(OneCornerLink(x,y1,x2,y2)retu
34、rn TRUE;for(int y=y1-1;y-1;y-)if(m_mapy*m_nCol+x1!=BLANK_STATE)break;if(OneCornerLink(x1,y,x2,y2)return TRUE;for(y=y1+1;ym_nRow;y+)if(m_mapy*m_nCol+x1!=BLANK_STATE)break;if(OneCornerLink(x1,y,x2,y2)return TRUE;return FALSE;BOOL C_LLK_Dlg:XThrough(int x, int y, BOOL bAdd)if(bAdd)for(int i=x;im_nCol;i
35、+)if(m_mapy*m_nCol+i!=BLANK_STATE)return FALSE;elsefor(int i=0;i=x;i+)if(m_mapy*m_nCol+i!=BLANK_STATE)return FALSE;return TRUE;BOOL C_LLK_Dlg:YThrough(int x, int y,BOOL bAdd)if(bAdd)for(int i=y;im_nRow;i+)if(m_mapi*m_nCol+x!=BLANK_STATE)return FALSE;elsefor(int i=0;i=y;i+)if(m_mapi*m_nCol+x!=BLANK_STATE)return FALSE;