电磁组面向对象程序设计_第1页
电磁组面向对象程序设计_第2页
电磁组面向对象程序设计_第3页
电磁组面向对象程序设计_第4页
电磁组面向对象程序设计_第5页
已阅读5页,还剩37页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、;DDX_Text(pDX,m_uHeight);DDX_Text(pDX, m_uNumber);DDX_Text(pDX, m_uWidth);IDC_HEIGHT,IDC_NUMBER,扫雷程序简介IDC_WIDTH,一功能介绍在 VC+中运行程序出现扫雷界面(如图)。1.BEGIN_MESSAGE_MAP(CDlgCustom,CDialog)END_MESSAGE_MAP()void CDlgCustom:OnOK()UpdateData();if (m_uWidth 30) m_uWidth= 30;if (m_uHeight 24) m_uHeight= 24;开始时候,可以再其

2、中则难度,2.还可以自定义雷的个数(如图)。中当出现数字是,说明在其相邻的格子里有这个数量的雷( 如图)。3.右键可以标记有雷,有小表示,4.再点击右键有问号出现代表有不确定(如图)。完成后图)。程序代码胜利或者中途失败(如5.二1#include stdafx.h #include mine.h #include DlgCustom.h #include MineWnd.h #ifdef _DEBUG#define new DEBUG_NEW #undef THIS_FILEsic char THIS_FILE = FILE ; #endif CDlgCustom:CDlgCustom(CW

3、nd*pParent )if(m_uNumber m_uWidth * m_uHeight) m_uNumber = m_uWidth * m_uHeight - 1;CMineWnd*pMine=(CMineWnd*)AfxGetMainWnd();pMine-SetCustom(m_uWidth, m_uHeight, m_uNumber);CDialog:OnOK();:CDialolgCustom:IDD,pParent)voidxNum, UCDlgCustom:InitData(Um_uHeight = 0;m_uNumber = 0;m_uWidth = 0;yNum, UmNu

4、m)m_uWidth = xNum;m_uHeight = yNum; m_uNumber = mNum;void CDlgCustom:DoDataExchange(CDataExc hange* pDX)CDialog:DoDataExchange(pDX)。2.#include stdafx.h #include mine.h#include DlgHero.h#include MineWnd.h #include MineDefs.h #ifdef _DEBUG#define new DEBUG_NEW #undef THIS_FILEsic char THIS_FILE = FILE

5、 ; #endif CDlgHero:CDlgHero(CWnd*pParent /*=NULL*/)m_szBHolder = holder;void record)CDlgHero:SetBRecord(Um_szBRecord.Format(%d 秒,record);void holder)CDlgHero:SetIHolder(CString:CDialolgHero:IDD,pParent)m_szIHolder = holder;m_szBHolder = _T();m_szEHolder = _T(); m_szBRecord = _T(); m_szERecord = _T()

6、; m_szIHolder = _T();m_szIRecord = _T();void record)CDlgHero:SetIRecord(Um_szIRecord.Format(%d 秒,record);void CDlgHero:SetEHolder(CString holder)m_szEHolder = holder;void CDlgHero:DoDataExchange(CDataExcha nge* pDX)CDialog:DoDataExchange(pDX);voidrecord)CDlgHero:SetERecord(UDDX_Text(pDX,m_szBHolder)

7、;DDX_Text(pDX, m_szEHolder);DDX_Text(pDX, m_szBRecord);DDX_Text(pDX, m_szERecord);DDX_Text(pDX, m_szIHolder);DDX_Text(pDX, m_szIRecord);IDC_B_H,秒,IDC_E_H,m_szERecord.Format(%drecord);void CDlgHero:OnReset()IDC_B_R,IDC_E_R,CMineWnd*pMine=IDC_I_H,(CMineWnd*)AfxGetMainWnd();pMine-ResetRecord(); m_szBHo

8、lderDEFAULT_HOLDER;m_szBRecord.Format(%d DEFAULT_RECORD);m_szIHolderDEFAULT_HOLDER;IDC_I_R,=秒,BEGIN_MESSAGE_MAP(CDlgHero,CDialog)END_MESSAGE_MAP()void CDlgHero:SetBHolder(CString holder)=m_szIRecord.Format(%d 秒,DEFAULT_RECORD);m_szEHolderDEFAULT_HOLDER;m_szERecord.Format(%d DEFAULT_RECORD);UpdateDat

9、a(FALSE);3. #include stdafx.h #include mine.h#include DlgNewRecord.h #include MineDefs.h #ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILE=elseif(level=LEVEL_SECONDRY) szLevel = 中级;秒,elseif(level=LEVEL_ADVANCE) szLevel = 高级; m_szDesc.Format(已破%s录nr 请留尊姓大名, szLevel);记CStrinlgNewRecord:GetName()retur

10、n m_szName;4. #include stdafx.h#include Mine.h #include MineDefs.h #ifdef _DEBUG#define new DEBUG_NEW #undef THIS_FILEsic char THIS_FILE = FILE ; #endif BEGIN_MESSAGE_MAP(CMineApp,CWinApp)END_MESSAGE_MAP()CMineApp:CMineApp() CMineApp theApp;sic char THIS_FILE = FILE ;#endif CDlgNewRecord:CDlgNewReco

11、rd(CWnd* pParent /*=NULL*/): CDialolgNewRecord:IDD,pParent)m_szName = _T(m_szDesc = _T(););void CDlgNewRecord:DoDataExchange(CData Exchange* pDX)CDialog:DoDataExchange(pDX);DDX_Text(pDX, IDC_EDIT_NAME, m_szName);constCStringclaame=_T(MineClass);BOOL CMineApp:InitInstance()SetRegistryKey(CSER_513_2);

12、m_uXMineNumGetProfile(GAME_SETTING, CUSTOM_XNUM, PRIMARY_XNUM);m_uYMineNum GetProfile(GAME_SETTING,CUSTOM_YNUM, PRIMARY_YNUM);=DDX_Text(pDX,m_szDesc);IDC_DESCRIBE,=BEGIN_MESSAGE_MAP(CDlgNewRecord, CDialog)END_MESSAGE_MAP()void CDlgNewRecord:SetLevel(U level)CString szLevel;if (level = LEVEL_PRIMARY)

13、 szLevel = 初级;m_pMineWndCMineWnd();WNDCLASS wc;=newZeroMemory(&wc, sizeof(wc);wc.hInstanceAfxGetInstanceHandle();wc.lpfnWndProc= :DefWindowProc;=wc.hbrBackground = NULL;wc.hCursor LoadCursor(IDC_ARROW);wc.hIconLoadIcon(IDR_MAINFRAME);=m_pMainWndm_pMineWnd;=m_pMineWnd-ShowWindow(SW_NORMAL);return TRU

14、E;CMineApp:ExitInstance()delete m_pMineWnd; returnCWinApp:ExitInstance();5. #include stdafx.h #include Mine.h #include MineWnd.h #include MineDefs.h #include Mmsystem.h#include DlgNewRecord.h #include DlgHero.h #include DlgCustom.h #ifdef _DEBUG#define new DEBUG_NEW #undef THIS_FILEsic char THIS_FIL

15、E = FILE ; #endifextern CMineApp theApp;wc.lpszClaame;wc.lpszame=claName=MAKERESOURCE(IDR_);if (!AfxRegisterClass(&wc)AfxMessageBox(类失败!);return FALSE;UuWidth=DEFAULT_FRAME_X + m_uXMineNum *MINE_WIDTH +LINE_WIDTH_0* 3 + SIDE_WIDTH_0 + SIDE_WIDTH_1;UuHeight=DEFAULT_FRAME_Y + m_uYMineNum *MINE_HEIGHT

16、+LINE_WIDTH_0*3+SIDE_WIDTH_0*2+SIDE_WIDTH_1 + SU_S_H;uX=2 -GetSystemMetrics(SM_CXSCREEN)uWidth / 2;/#defineWM_USER + 1ID_TIMER_EVENTUuY=-GetSystemMetrics(SM_CYSCREEN)uHeight / 2;if(!m_pMineWnd-CreateEx( claame, _T(扫雷),WS_SYSWS_CAPTION | WS_MINIMIZEBOX,/2CMineWnd:CMineWnd()m_pSndDead = NULL; m_pSndVi

17、ctory = NULL; m_pSndClock = NULL; m_uTimer = 0; m_brsBG.CreateSolidBrush(COLOR_GRAY);oadConfig();NULL,|uX,uY,uWidth,uHeight,NULL, NULL) )ifLoadWaveSrc();InitGame();(m_bSoundful)AfxMessageBox( 创建主 窗口失败!);return FALSE;CMineWnd:CMineWnd()ON_WM_CLOSE()MAND(IDM_HERO,OnMemuHero)MAND(IDM_CHEAT,OnMemuCheat)

18、/AFX_MSG_MAP END_MESSAGE_MAP()void CMineWnd:LoadConfig()FreeMines();FreeWaveSrc(); SaveConfig();BEGIN_MESSAGE_MAP(CMineWnd,CWnd)/AFX_MSG_MAP(CMineWnd)ON_WM_PA()char exeFullPathMAX_PATH;CString strPath;ON_WM_SHOWWINDOW()ON_WM_TIMER() ON_WM_LBUTTONUP() ON_WM_RBUTTONUP() ON_WM_LBUTTONDOWN() ON_WM_RBUTT

19、ONDOWN() ON_WM_MOUSEMOVE()MAND(IDM_START,OnMemuStart)MAND(IDM_PRIMARY,OnMemuPrimary)MAND(IDM_SECOND,OnMemuSecond)MAND(IDM_ADVANCE,OnMemuAdvance)MAND(IDM_CUSTOM,OnMemuCustom)MAND(IDM_MARK,OnMemuMark)MAND(IDM_COLOR,OnMemuColor)MAND(IDM_SOUND,OnMemuSound)MAND(IDM_EXIT,OnMemuExit)MAND(IDM_HELP_LIST,OnMe

20、muHelpList)MAND(IDM_HELP_FIND,OnMemuHelpFind)MAND(IDM_HELP_USE,OnMemuHelpUse)MAND(IDM_ABOUT,OnMemuAbout) ON_WM_KEYDOWN()GetModuleFileNaexeFullPath, MAX_PATH);LL,strPath = CString(exeFullPath);strPathstrPath.Left(strPath.ReverseFind();=/-*/strPath += config.ini;char strPrimary80; char strSecond80; ch

21、ar strAdvance80;m_uXNum=GetPrivateProfile(WINDOW,XNum,10,strPath);m_uYNum=GetPrivateProfile(WINDOW,YNum,10,strPath);m_uMineNum=GetPrivateProfile(MINE,MineNum,10,strPath);m_uLevelGetPrivateProfile(MINE,Level, 0,strPath);m_uPrimary=GetPrivateProfile(SCORE,Primary,999,strPath);m_uSecondGetPrivateProfil

22、e(SCORE,Second, 999,strPath);m_uAdvance=GetPrivateProfile(SCORE,Advance,999,strPath);GetPrivateProfileString(HOLDON_WM_INIT()ER,PrimaryHolder,strPrimary,80,strPath);GetPrivateProfileString(HOLD ER,SecondHolder, ,strSecond,80,strPath);GetPrivateProfileString(HOLDER,AdvanceHolder, ,strAdvance,80,strPa

23、th);anceHolder;CStringstrMarkful,strColorful,strSoundful;strXNum.Format(%u,m_uXNum);strYNum.Format(%u,m_uYNum);m_szPrimary = strPrimary;m_szSecond = strSecond; m_szAdvance= strAdvance; m_bMarkful=GetPrivateProfile(CONFIG,Markful,0,strPath);strMineNum.Format(%u,m_uMineNum);strLevel.Format(%u,m_uLevel

24、);strPrimary.Format(%u,m_uPrimary);m_bColorful=GetPrivateProfile(CONFIG,Colorful,1,strPath);strSecond.Format(%u,m_uSecond);m_bSoundful=strAdvance.Format(%u,m_uAdvance);GetPrivateProfile, 1,strPath);(CONFIG,SoundfulstrPrimaryHolder.Format(%s,m_szPrimary);/ 保存/void CMineWnd:SaveConfig()char exeFullPat

25、hMAX_PATH; CString strPath;strSecondHolder.Format(%s,m_szSecond);strAdvanceHolder.Format(%s,m_szAdvance);strMarkful.Format(%d,m_bMarkful);GetModuleFileNaexeFullPath, MAX_PATH);LL,strColorful.Format(%d,m_bColorful);strPath = CString(exeFullPath);strPathstrPath.Left(strPath.ReverseFind();=strSoundful.

26、Format(%d,m_bSoundful);/-*/WritePrivateProfileString(WINDOW,XNum, strXNum,strPath);strPath += config.ini;CString strXNum,strYNum;CString strMineNum,strLevel;CString strPrimary,strSecond,strAdvance;CStringstrPrimaryHolder,strSecondHolder,strAdvWritePrivateProfileString(WINDOW,YNum, strYNum,strPath);W

27、ritePrivateProfileString(MINE,MineNum, strMineNum,strPath);WritePrivateProfileString(MINE,Level,strLevel,strPath);m_bmpButton.DeleteObject();WritePrivateProfileString(SCORE,Primary, strPrimary,strPath);m_bmpButton.LoadBitmaB_BTN_COLOR);elsem_clrDark COLOR_BLACK;WritePrivateProfileString(SCORE,Second

28、, strSecond,strPath);WritePrivateProfileString(SCORE,Adva=nce, strAdvantrPath);WritePrivateProfileString(HOLDER,PrimaryHolder, strPrimaryHolder,strPath);m_bmpMine.DeleteObject();m_bmpMine.LoadBitmaE_GRAY);B_MINWritePrivateProfileString(HOLDER,SecondHolder, strSecondHolder,strPath);m_bmpNumber.Delete

29、Object();WritePrivateProfileString(HOLDER,AdvanceHolder, strAdvanceHolder,strPath);m_bmpNumber.LoadBitmaUM_GRAY);B_NWritePrivateProfileString(CONFIG,Markful, strMarkful,strPath);m_bmpButton.DeleteObject();WritePrivateProfileString(CONFIG,Colorful, strColorful,strPath);m_bmpButton.LoadBitmaN_GRAY);vo

30、id CMineWnd:InitGame()/位图的初始化 LoadBitmap(); m_nLeaveNumm_uMineNum;m_uSpendTime = 0; m_uBtnSeBUTTON_NORMAL;B_BTWritePrivateProfileString(CONFIG,Soundful, strSoundful,strPath); void CMineWnd:LoadBitmap()if (m_bColorful)=m_clrDarkCOLOR_DARK_GRAY;=m_bmpMine.DeleteObject();m_uGameSe = GS_WAIT;m_bmpMine.L

31、oadBitmaE_COLOR);B_MINif (m_uTimer)m_bmpNumber.DeleteObject();KillTimer(ID_TIMER_EVENT);m_uTimer = 0;m_bmpNumber.LoadBitmaUM_COLOR);B_Nm_pNewMine = NULL;m_pOldMine = NULL;if(m_pMinesij.uAttribATTRIB_MINE)!=FreeMines();/初始化地图for (Ui =0;im_uYNum;m_pMinesij.uAttribATTRIB_MINE;/修改属性为雷=i+)forjm_uXNum; j+

32、)(Uj=0;index+;m_pMinesij.uRowCMineWnd:ExpandMines(U col)= i;voidUrow,m_pMinesij.uCol= j;UUi, j;minRow = (row = 0) ? 0 :m_pMinesij.uSeE_NORMAL;=Srow - 1;UUmaxRow = row + 2;minCol = (col = 0) ? 0 :m_pMinesij.uAttribATTRIB_EMPTY;=col - 1;UUmaxCol = col + 2;aroundm_pMinesij.uOldSE_NORMAL;e=SGetAroundNum

33、(row, col);m_pMinesrowcol.uSe=15 - around;m_pMinesrowcol.uOldSe= 15 - around;voidrow, UCMineWnd:LayMines(Ucol)/埋下随机srand( (unsigned)time( NULL ) )/ “打开”该区域,重绘DrawSpelMine(row, col);Ui, j;/ 对周围一个没有的空白区域for(Um_uMineNum;)index=0;indexif (around = 0)for (i = minRow; i maxRow; i+)for (j = minCol; j maxCo

34、l; j+)/ 对于周围可以拓/取随即数i = rand() % m_uYNum; j = rand() % m_uXNum;if (i = row & j = col)continue;展的区域进行的规拓展if (!(i = row &j = col) &return around;/获取某个块区域相邻 8 个区域的已标志状态数Um_pMinesij.uSeE_NORMAL=S&m_pMinesij.uAttrib != ATTRIB_MINE)CMineWnd:GetAroundFlags(Urow,Ucol)ifUU Ui, j;flags = 0;minRow = (row = 0)

35、? 0 :(!IsineArea(i, j) continue;ExpandMines(i, j);row - 1;UUmaxRow = row + 2;minCol = (col = 0) ? 0 :col - 1;UmaxCol = col + 2;for (i = minRow; i maxRow;UCMineWnd:GetAroundNum(Ui+)row,Ucol)for (j = minCol; j maxCol;j+)UU Ui, j;around = 0;minRow = (row = 0) ? 0 :if (!IsineArea(i, j)continue;row - 1;i

36、f(m_pMinesij.uSe = S flags+;return flags;BOOL CMineWnd:IsMine(UUUmaxRow = row + 2;minCol = (col = 0) ? 0 :E_FLAG)col - 1;UmaxCol = col + 2;for (i = minRow; i maxRow;i+)row,Ucol)for (j = minCol; j = 0&rowcol=0voidcol)CMineWnd:Dead(Urow,else /失败错误雷for (i = 0; i m_uYNum;U/按钮所在的区域CRect rcBtn(m_uBtnRect1

37、, 15,m_uBtnRect2, 39);/雷区所在的区域 CRectrcMineArea(MINE_AREA_LEFT,MINE_AREA_TOP,i+)for(j=0;jm_uXNum; j+)m_pMinesrowcol.uSeE_ERROR;=MINE_AREA_LEFTm_uXNum * MINE_WIDTH,MINE_AREA_TOPm_uYNum * MINE_HEIGHT);+S+m_pMinesrowcol.uOldSeE_ERROR;if=SUi, j;if (m_pMinesrowcol.uAttrib= ATTRIB_MINE)/失败点中雷for (i = 0; i

38、m_uYNum;i+)(m_pMinesij.uAttrib = ATTRIB_MINE&m_pMinesij.uSe != SE_FLAG)m_pMinesij.uSeE_MINE;=for(j=0;jSm_uXNum; j+)m_pMinesij.uOldSE_MINE;/失败处理e=Sm_pMinesrowcol.uSE_BLAST;e=Sm_pMinesrowcol.uOldSE_BLAST;ife=SInvalidateRect(rcMineArea);m_uBtnSe = BUTTON_DEAD; InvalidateRect(rcBtn); m_uGameSe = GS_DEAD

39、;if (m_uTimer != 0)/将定时器去激活(m_pMinesij.uAttrib = ATTRIB_MINE&m_pMinesij.uSe != SE_FLAG)m_pMinesij.uSeE_MINE;=SKillTimer(ID_TIMER_EVENT);m_uTimer = 0;m_pMinesij.uOldSe=if (m_bSoundful)/失败声音ce(m_pSndVictory),SND_MEMORYSND_ASYNC | SND_NODEFAULT);|sndPlaySound(LPCTSTR)LockResour榜uRecord;(m_uLevelce(m_pS

40、ndDead),SND_MEMORY|/UifSND_ASYNC | SND_NODEFAULT);BOOL CMineWnd:Victory()=LEVEL_PRIMARY) uRecord = m_uPrimary;elseif(m_uLeveluRecord=LEVEL_SECONDRY)m_uSecond;Ui, j;CRect rcBtn(m_uBtnRect1, 15,m_uBtnRect2, 39);/ 检测是否胜利for (i = 0; i m_uYNum; i+)for (j = 0; j m_uSpendTime)CDlgNewRecord dlg; dlg.SetLeve

41、l(m_uLevel); dlg.DoModal();swit_uLevel)(m_pMinesij.uSe=SE_NORMAL) return FALSE;ifcase LEVEL_PRIMARY:m_uPrimarym_uSpendTime;m_szPrimarydlg.GetName();break;case LEVEL_SECONDRY:m_uSecondm_uSpendTime;m_szSeconddlg.GetName();break;case LEVEL_ADVANCE:m_uAdvancem_uSpendTime;m_szAdvancedlg.GetName();break;c

42、ase LEVEL_CUSTOM:return TRUE; default:break;=(m_pMinesij.uSreturn FALSE;e=SE_DICEY)=/胜利则作胜利处理 m_uBtnSeBUTTON_VICTORY;=m_uGameSInvalidate();e = GS_VICTORY;if (m_uTimer != 0)/将定时器去激活=KillTimer(ID_TIMER_EVENT);m_uTimer = 0;/胜利声音if (m_bSoundful)=sndPlaySound(LPCTSTR)LockResourOnMemuHero();SE_DICEY_DOWN;

43、return TRUE;/ 鼠标右键,根据原先不同的标记作状态循环修改/ 以便用户可以修改其原先标志/ voidvoid CMineWnd:OnLRBtnUp(Urow, Ucol)UUi, j;minRow = (row = 0) ? 0 :CMineWnd:OnLRBtnDown(Urow,Ucol)row - 1;UUmaxRow = row + 2;minCol = (col = 0) ? 0 :UUi, j;minRow = (row = 0) ? 0 :col - 1;row - 1;UmaxCol = col + 2;UUmaxRow = row + 2;minCol = (co

44、l = 0) ? 0 :for (i = minRow; i maxRow;i+)col - 1;UmaxCol = col + 2;for (j = minCol; j maxCol;j+)for (i = minRow; i maxRow;i+)if (!IsineArea(i, j)continue;for (j = minCol; j maxCol;/row & j = col) continue;if (m_pMinesij.uOldSeif (i =j+)if (!IsineArea(i, j)=continue;SE_NORMAL)/row & j = col) continue

45、;if (m_pMinesij.uSeif (i =m_pMinesij.uSeE_NORMAL;else=SSE_NORMAL)if=(m_pMinesij.uOldSem_pMinesij.uSE_EMPTY;elsee=SE_DICEY)Sifm_pMinesij.uSeE_DICEY;=(m_pMinesij.uSe = SE_DICEY)Sm_pMinesij.uSe=/Invalidate();void CMineWnd:OpenAround(Urow, Ucol)/ 判断是否胜利,是则将地图中所有雷标识出来if (Victory()for (i = 0; i m_uYNum;i+

46、)for(j=0;jm_uXNum; j+)if (m_pMinesij.uAttrib = ATTRIB_MINE)/ 如果周围相邻的标志雷数 != 周围相邻的雷数 则返回if (GetAroundFlags(row, col) !=GetAroundNum(row, col) return;UU Ui, j;around = 0;minRow = (row = 0) ? 0 :row - 1;UUmaxRow = row + 2;minCol = (col = 0) ? 0 :col - 1;UmaxCol = col + 2;m_pMinesij.uSeE_FLAG;=for (i =

47、minRow; i maxRow;Si+)m_pMinesij.uOldSeE_FLAG;m_nLeaveNum = 0; Invalidate();=for (j = minCol; j maxCol;Sj+)if (!IsineArea(i, j)continue;if(m_pMinesij.uSe=SE_NORMAL)/ 如果该区域为正常区域BOOLCMineWnd:ErrorAroundFlag(Urow,/拓展该雷区ExpandMines(i,Ucol)/ 如果周围相邻的标志!= 周围相邻的雷数 则返回if (GetAroundFlags(row, col) !=j);雷数aroun

48、d=GetAroundNum(i, j);GetAroundNum(row, col) return FALSE;m_pMinesij.uSaround;e=15-UUi, j;minRow = (row = 0) ? 0 :m_pMinesij.uOldSaround;e = 15-row - 1;UmaxRow = row + 2;UminCol = (col = 0) ? 0 :/delete m_pMines;m_pMines = NULL;col - 1;UmaxCol = col + 2;for(Ufor (i = minRow; i maxRow;row=0;i+)rowm_uY

49、Num; row+) /if (m_pMinesrow) deletefor (j = minCol; j maxCol;j+)m_pMinesm_uXNum;/m_pMinesrow;/deleteif (!IsineArea(i, j)continue;if(m_pMinesij.uSe = Sif/E_FLAG)voidCMineWnd:SizeWindow( void )(m_pMinesij.uAttrib != ATTRIB_MINE)Dead(i, j); returnTRUE;return FALSE;void CMineWnd:OpenByCheat()UDEFAULT_FR

50、AME_X MINE_WIDTH +uWidth+m_uXNum=*LINE_WIDTH_0*3SIDE_WIDTH_0 + SIDE_WIDTH_1;+UDEFAULT_FRAME_Y MINE_HEIGHT +uHeight=*+m_uYNumLINE_WIDTH_0*3+SIDE_WIDTH_0 * 2 + SIDE_WIDTH_1 +S_S_H;SetWindowUi, j;(&wndTopMost,for (i = 0; i m_uYNum; i+)for (j = 0; j m_uXNum;0, 0, uWidth, uHeight,SWP_NOZORDER|SWP_NOMOVE|

51、SWP_NOCOPYBITS);j+)/ SWP_NOCOPYBITS doesfunction?GetCntRect(&m_rcCnot doif(m_pMinesij.uSe = S continue;nt);E_FLAG)/ Buttonitionm_uBtnRect0m_rcCnt.right / 2 - 12; left side of the start(s without 3d borderm_uBtnRect1m_rcCnt.right / 2 - 13;=/ the buttonOpenAround(i, j);e)void CMineWnd:FreeMines()=/ th

52、eleft side of the start(se) button with3d border/if (m_pMines) m_uBtnRect2m_rcCnt.right / 2 + 12;/ the right side of the start(s button=24, SRCCOPY);e)dc.Draw3dRect(m_uBtnRect1,15, 26, 26, m_clrDark, m_clrDark);/ Numbositionm_uNumRect0m_rcCnt.right - 55;=voidCMineWnd:DrawNumber(CPaDC &dc)CDC dcMemor

53、y;patibleDC(&dc);dcMemory.SelectObject(m_bm pNumber);/ the left side of the spend timerect with 3d borderm_uNumRect1m_rcCnt.right - 15;=/ the right side of the spend timerectm_uNumRect2m_rcCnt.right - 54;=/ the left side of the spend timerect without 3d borderdc.Draw3dRect(16, 15, 41, 25,m_clrDark,

54、COLOR_WHITE);dc.Draw3dRect(m_uNumRect/m_uNumRect3=m_rcCnt.right - 41;0,15,41,25,m_clrDark,/m_uNumRect4=COLOR_WHITE);num;m_rcCnt.right - 28;/ Sm_uS nt.right;itionRcX0/drawremainingmine=numbersm_rcC/num = (m_nLeaveNum0) ? 11 :m_nLeaveNum/100;tretchBlt(17, 16, 13, 23,&dcMemory, 0, 276-23*(num+1), 13, 2

55、3, SRCCOPY);num = (m_nLeaveNum 0) ?m_uSRcX1=m_rcCnt.right - 14;/ the width of the small(big) sm_uSRcY0=m_rcC/nt.bottom;-(m_nLeaveNum-num*100)/10(m_nLeaveNum-num*100)/10;:m_uSRcY1=_L_START_Y -tretchBlt(30, 16, 13, 23,&dcMemory, 0, 276-23*(num+1), 13, 23, SRCCOPY);num = (m_nLeaveNum0) ?m_rcC5;nt.botto

56、m - S/ the height of the big svoidCMineWnd:DrawButton(CPaCDC cdc;-m_nLeaveNum%10m_nLeaveNum%10;:DC &dc)tretchBlt(43, 16, 13, 23,&dcMemory, 0, 276-23*(num+1), 13, 23, SRCCOPY);/ draw take secondsnum = m_uSpendTime / 100; tretchBlt(m_uNumRect0,patibleDC(&dc);electObject(m_bmpButtocn);tretchBlt(m_uBtnR

57、ect0,16, 24, 24, &cdc, 0, 24 * m_uBtnSe, 24,16,13,23,&dcMemory,0,276-23*(num+1), 13, 23, SRCCOPY);num_X + 2, S_L_START_Y + 2,=m_uSRcX1-4,(m_uSpendTim*100)/10;tretchBlt(m_uNumRect0m_uSRcY1-4,m_clrDark,COLOR_WHITE);CMineWnd:DrawMineArea(CPaDC+ 13, 16, 13, 23, &dcMemory,276-23*(num+1), 13, 23, SRCCOPY)

58、;num = m_uSpendTime%10;0,void&dc)tretchBlt(m_uNumRect0+CDC dcMemory; /用作内存设26,16,13,23,&dcMemory,276-23*(num+1), 13, 23, SRCCOPY);void0,备patibleDC(&dc); /使得这个设备与 dc 兼容dcMemory.SelectObject(m_bm pMine); /将内存设备与位图资源关联CMineWnd:DrawS(CPaDC &dc)/ 绘画 2 条白条dc.FillSolidRect(0,0,m_uSRcX0,LINE_WIDTH_0,for (Ui

59、 = 0; im_uYNum;COLOR_WHITE);dc.FillSolidRect(0,i+)0,RcY0,LINE_WIDTH_0,COLOR_WHITE);m_uSforjuSe = 15 - num;mine-uOldSe = 15 - num; CRect rcMine(mine-uCol * 16,mine-uRow * 16, (mine-uCol+1) *16, (mine-uRow+1) * 16);InvalidateRect(rcMine);_L_START_X + 1, S_L_START_Y + 1,m_uSRcX1-2,m_uSRcY1-2,m_clrDark,

60、COLOR_WHITE);dc.Draw3dRect(S_L_STARTM_ADVANCE,MF_UNCHECKED|/重新绘制雷区域的某个方块voidMAND);CMineWnd:DrawSpelMine(Urow,m_pSubM_CUSTOM,-CheckItem(IDUcol)MF_UNCHECKED|MAND);switCRect rcMine(col * 16, row *16, (col+1) * 16, (row+1) * 16);InvalidateRect(rcMine); MINEWND*CMineWnd:GetMine(long x, long y)/保证参数合格if (

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论