資源簡介
c++.win32.掃雷游戲代碼
win32編程入門學習代碼
有助于了解windows編程原理

代碼片段和文件信息
#include????
#include????
#include????
#include?“resource.h“???//?菜單資源頭文件???
#define?SHADOW_WIDTH1?1?//陰影寬度???
#define?SHADOW_WIDTH2?2????
#define?SHADOW_WIDTH3?3????
#define?BORDER?8????//邊界的寬度???
#define?BOX_WIDTH?20//box的寬度???
#define?BOX_HEIGHT?20?//box的高度???
#define?RESERVED_AREA?32?//保留區(qū)高度???
//******************************???
//自定義的函數(shù)聲明???
//******************************???
LRESULT?CALLBACK?WndProc?(HWND?UINT?WPARAM?LPARAM)?;???
void?DrawBorder(HDC?hdcint?xint?yint?widthint?heightint?BorderWidthCOLORREF?&color1COLORREF?&color2bool?WTop);???
void?AutoOpenBoxes(HDC?&hdcint?iint?j);???
void?drawRect(HDC?&hdcint?xint?y);???
bool?allRoundIsOpened(int?rowint?col);???
void?InitBox();???
void?UpdateTheWindow(HWND?&hwndint?rowsint?colsint?mineNO);???
void?ComputeRoundMineNo();???
void?RandomSetMines();???
//**************************************???
//結構體BoxroundMineNO表示周圍雷的個數(shù)???
//containMine表示是否里面是否有雷,???
//isOpened表示box是否已經(jīng)打開???
//**************************************???
static?HMENU?hMenu;???
struct?Box???
{???
?int??roundMineNO;???
?bool?containMine;???
?bool?isOpened;???
};???
static?int?mineNumber;???
static?int?ROWS;?????//行數(shù)???
static?int?COLS;?????//列數(shù)????
static?int?iSM_BorderX;???
static?int?iSM_BorderY;???
static?int?iSM_CaptionY;????
static?int?iSM_MenuY;???
static?Box?**box;???
static?int?ijnumberOpened;???
static?RECT?mineRect;???
//********???
//main函數(shù)???
//********???
int?WINAPI?WinMain?(HINSTANCE?hInstance?HINSTANCE?hPrevInstance???
???PSTR?szCmdLine?int?iCmdShow)???
{???
?static?TCHAR?szAppName[]?=?TEXT?(“SineWave“)?;???
?HWND???hwnd?;???
?MSG????msg?;???
?WNDCLASS??wndclass?;???
??
?//地雷的個數(shù),此處似乎多余,因為下面又賦值成了10個
?mineNumber?=?5;??
?//可能有雷的區(qū)域為10?X?10個
????ROWS?=?10;?COLS?=?10;???
????mineNumber?=?10;?
//新建COLS雷區(qū),每行這些雷區(qū)列
?box?=?new?Box*?[COLS];
?//每列這些行
?for(int?k=0;k ??box[k]?=?new?Box[ROWS];???
??
???//獲取窗口邊界的寬度、高度、標題區(qū)域的高度、菜單的高度等信息,可能翻譯不太準確,請查msdn
?iSM_BorderX?=?GetSystemMetrics(SM_CXBORDER);???
?iSM_BorderY?=?GetSystemMetrics(SM_CYBORDER);???
?iSM_CaptionY?=?GetSystemMetrics(SM_CYCAPTION);???
?iSM_MenuY?=?GetSystemMetrics(SM_CYMENU);???
????int?cx?=?BOX_WIDTH?*?COLS?+?2?*?SHADOW_WIDTH3?+?2?*?SHADOW_WIDTH2?+?2?*?iSM_BorderX?+?2?*?BORDER;???
?int?cy?=?BOX_HEIGHT?*?ROWS?+?2?*?SHADOW_WIDTH3?+?4?*?SHADOW_WIDTH2?+?2?*?iSM_BorderY?+?3?*?BORDER?+?RESERVED_AREA+iSM_CaptionY+iSM_MenuY;???
?mineRect.left?=?SHADOW_WIDTH3+BORDER+SHADOW_WIDTH2;???
?mineRect.right?=mineRect.left?+?BOX_WIDTH?*?COLS;???
?mineRect.top?=?SHADOW_WIDTH3+2*BORDER+RESERVED_AREA+3*SHADOW_WIDTH2;???
?mineRect.bottom?=?mineRect.top?+?BOX_HEIGHT?*?ROWS;???
???????
?wndclass.style??=?CS_HREDRAW?|?CS_VREDRAW?;???
?wndclass.lpfnWndProc=?WndProc?;???
?wndclass.cbClsExtra?=?0?;???
?wndclass.cbWndExtra?=?0?;???
?wndclass.hInstance?=?hInstance?;???
?wndclass.hIcon??=?LoadIcon?(NULL?IDI_APPLICATION)?;???
?wndclass.hCursor?=?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3990??2009-09-05?19:15??掃雷\3.dsp
?????文件????????527??2009-09-05?17:59??掃雷\3.dsw
?????文件??????48640??2009-09-10?09:59??掃雷\3.opt
?????文件????????750??2009-09-10?09:57??掃雷\3.plg
?????文件????????867??2009-09-14?10:41??掃雷\3.sln
????..A..H.??????8704??2009-09-14?10:42??掃雷\3.suo
?????文件???????5843??2009-09-12?20:35??掃雷\3.vcproj
?????文件???????1425??2009-09-14?10:42??掃雷\3.vcproj.quande-notepad.quande.user
?????文件????????738??2009-09-05?18:01??掃雷\resource.h
?????文件??????17204??2009-09-05?19:16??掃雷\sc
?????文件???????2033??2009-09-05?18:01??掃雷\sc
?????文件??????18644??2009-09-12?09:06??掃雷\winmain.cpp
?????目錄??????????0??2012-08-16?09:52??掃雷\Debug
?????目錄??????????0??2012-08-16?09:52??掃雷
-----------?---------??----------?-----??----
???????????????109365????????????????????14
評論
共有 條評論