资源简介
我是北京交大教师程轶平,这是我为我开设的课程“ Windows程序设计”编写的扫雷代码,是基于ReactOS的WinEMine改写的,采用Win32 API。界面完全模仿微软自带的扫雷,完整地实现了整个功能。而且代码很简洁。

代码片段和文件信息
/*===========================================================================
This is the fifth step toward building the WinMine application
Adapted for educational purpose by Yiping Cheng
Beijing Jiaotong University Mar. 2011
based on the WinMine program written by the ReactOS team
Original Copyright Notice:
* WineMine (main.c)
*
* Copyright 2000 Joshua Thielen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not write to the Free Software
* Foundation Inc. 51 Franklin Street Fifth Floor Boston MA 02110-1301 USA
---------------------------------------------------------------------------*/
#include
#include
#include “resource.h“
#include “WinMine.h“
// the only global variable
extern BOARD board;
void TranslateMouseMsg(UINT* puMsg WPARAM wParam)
{
if (*puMsg == WM_LBUTTONDOWN)
SetCapture(board.hWnd);
else if (*puMsg == WM_LBUTTONUP)
ReleaseCapture();
else if ((*puMsg == WM_MOUSEMOVE) && (wParam & MK_LBUTTON))
{
*puMsg = WM_LBUTTONDOWN;
}
}
void ProcessMouseMsg(UINT uMsg LPARAM lParam)
{
POINT pt;
int row col;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (PtInRect(&board.FaceRect pt))
{
if (uMsg == WM_LBUTTONDOWN)
{
DisplayFace(FACE_DOWN);
}
else if (uMsg == WM_LBUTTONUP)
{
NewGame();
}
return;
}
if (board.GameState == GAMEWON)
{
DisplayFace(FACE_WIN);
return;
}
else if (board.GameState == GAMELOST)
{
DisplayFace(FACE_LOSE);
return;
}
Pt2RowCol(pt &row &col);
if (uMsg == WM_LBUTTONDOWN)
{
if (row != board.rowPressed || col != board.colPressed)
{
UnPressBox();
PressBox(row col);
}
DisplayFace(FACE_CAUTION);
}
else
{
UnPressBox();
if (row < 0)
{
// row<0 means we clicked outside the grid
DisplayFace(FACE_HAPPY);
return;
}
if (uMsg == WM_LBUTTONUP)
{
if (board.GameState == WAITING)
{
LayMines(row col);
board.GameState = PLAYING;
SetTimer
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 537 2011-03-08 10:24 WinMine\WinMine.dsw
文件 115712 2011-04-19 08:28 WinMine\WinMine.ncb
文件 1412 2011-04-19 08:27 WinMine\WinMine.plg
文件 48640 2011-04-19 08:28 WinMine\WinMine.opt
文件 4238 2011-04-19 07:55 WinMine\WinMine.h
文件 13820 2011-04-19 00:41 WinMine\WinMine.c
文件 8104 2011-04-19 08:13 WinMine\MineGame.c
文件 7325 2011-04-18 21:09 WinMine\WinMine.dsp
文件 3033 2011-04-19 08:15 WinMine\WinMine.rc
文件 1048 2011-04-19 00:22 WinMine\resource.h
文件 62168 2011-04-19 08:15 WinMine\WinMine.aps
文件 5322 2011-04-19 08:13 WinMine\MinePaint.c
..A.SH. 22528 2011-03-08 14:53 WinMine\res\Thumbs.db
文件 22542 2011-03-07 00:19 WinMine\res\Mine.ico
文件 2326 2011-03-08 11:33 WinMine\res\leds.BMP
文件 1558 2011-03-08 11:33 WinMine\res\faces.bmp
文件 2166 2011-03-08 11:33 WinMine\res\mines.BMP
文件 65536 2011-04-19 08:27 WinMine\Release\WinMine.exe
目录 0 2011-04-19 08:29 WinMine\res
目录 0 2011-04-19 08:29 WinMine\Unicode Debug
目录 0 2011-04-19 08:29 WinMine\Unicode Release
目录 0 2011-04-19 08:29 WinMine\Release
目录 0 2011-04-19 08:29 WinMine\Debug
目录 0 2011-04-19 08:29 WinMine
----------- --------- ---------- ----- ----
388015 24
- 上一篇:计算机网络编程vc++学生管理系统
- 下一篇:C语言socket编程实现网络数据传输
相关资源
- C++头文件转delphi工具 + 源码
- 基于MFC的TCP调试助手源码95706
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- 安科瑞智能电能表MODBUS通讯程序 VC6
- 九齐单片机源码
- Qt画图工具源码(qgraphics draw)
- qt 串口助手源码
- modbus 主机源码
- 《LINUX C编程从初学到精通》光盘源码
- OLED驱动源码
- tm1650+stm32f103源码(board_tm1650.c)
- cheat engine 7.2源码
- CrySearch内存搜索器源码
- FTP客户端源码(c++)
- MFC视频播放器源码(支持avi/wma/mp3等格
- CreatBitmap图片合成源码
- vs2008 can总线通讯源码
- 宠物管理系统课程设计(源码+数据库
- Windows扩展命令程序(源码)
- c语言实现火车订票系统(控制台)源
- 鼠标连点器(附源码)
- c++ 简易贪吃蛇源码
- 杀毒软件源码
- 经典外汇智能交易程序Amazing3.1源码(
- 微型文件系统源码(FatFs)
- 海康私有流分析接口源码(附使用说
- VC6 USB开发源码
- SVM算法实现(源码+文档)
- 俄罗斯方块游戏源码(Tetris)
评论
共有 条评论