Click here to Skip to main content
Click here to Skip to main content


, 25 Feb 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
A simulation of the famous MineSweeper game by Microsoft.

Sample Image - XMineSweeper.jpg


The XMineSweeper is a simulation for the famous 'MineSweeper' game by Microsoft which is shipped with its Windows operating system.

It is a light game that can help you spend some minutes with fun, far from coding problems.


I know it sounds silly to make the MineSweeper which is already developed for best outputs by the software gurus at Microsoft, but it was first an assignment for joining a job in a firm (without mentioning its name, Sakhr).

But after development, it was really fun, and it made me learn some practical skills.


Using the resources bitmap files from the original MineSweeper (%windir%\System32\winmine.exe) for drawing with GDI, I tried to make it look like the original by drawing 3D-like lines (by drawing white line on one side, and a gray one on the other side to make it feels like the effect of light and shadow).

The CMineSweeper Class

Here comes the main class for the game which manages the sequence of the game (this is how we learn the Game Engine from game developers). The class responds to user clicks, checks for mines, and draws the output for the 'Device Context' passed to it.

void CMineSweeper::Draw(CDC *pDC);

The draw function is essential for rendering the game to the CDC object passed to it. This design avoids the problem of flicker, by calling this function in the WM_PAINT message, and also call it when we need to update the view for the user.

Handle both right and left mouse button down

Handling the middle mouse button down is straight (ON_WM_MBUTTONUP()), but to handle both right-left mouse buttons down, you have to add a small check for the other button using the API function GetKeyState() which is used by game developers when they can't wait for the message to be sent, rather they go checking for it by themselves.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Egypt Egypt

Comments and Discussions

Questioncan I use the GNU License Agreement [modified] Pinmemberzach callaway9-Nov-08 7:47 
GeneralDebug Assertion Failed! Pinmembersandeepkavade24-Oct-07 1:52 
Generalbrilliant plus an improvement Pinmemberdysfunctional@freesurf.fr24-Aug-07 3:57 
QuestionHow to look into resource file of exe? PinmemberMuhammed Nasir5-Jun-07 21:33 
AnswerRe: How to look into resource file of exe? PinmemberGarth J Lancaster5-Jun-07 22:19 
AnswerRe: How to look into resource file of exe? Pinmemberahmadaa6-Jun-07 0:39 
QuestionRe: How to look into resource file of exe? PinmemberMuhammed Nasir6-Jun-07 20:55 
GeneralTouch Screen Edition Pinmemberphm3713-Jan-07 8:40 
AnswerRe: Touch Screen Edition Pinmemberahmadaa15-Jan-07 10:10 
Questionhow do i compile the source code Pinmemberlyhlyh10-Mar-06 22:03 
AnswerRe: how do i compile the source code Pinmemberahmadaa11-Mar-06 7:14 
GeneralRe: how do i compile the source code Pinmemberlyhlyh11-Mar-06 7:31 
GeneralRe: how do i compile the source code Pinmemberahmadaa12-Mar-06 8:24 
AnswerRe: how do i compile the source code PinmemberHomero De la Garza25-Mar-06 11:42 
Generalsource code PinmemberRoger6526-Feb-06 13:05 
GeneralRe: source code Pinmemberahmadaa27-Feb-06 8:18 
Generalabout sakhr PinmemberMohamad Al Husseiny25-Feb-06 14:43 
GeneralRe: about sakhr Pinmemberahmadaa26-Feb-06 8:23 
GeneralRe: about sakhr PinmemberMohamad Al Husseiny26-Feb-06 15:23 
GeneralBrilliant PinmemberAshraf_s25-Feb-06 11:47 
GeneralRe: Brilliant Pinmemberahmadaa26-Feb-06 8:27 
GeneralRe: Brilliant PinmemberAshraf_s28-Feb-06 1:21 
GeneralRe: Brilliant Pinmemberahmadaa28-Feb-06 2:39 
Generalgood job Pinmemberkhalouda25-Feb-06 7:47 
GeneralRe: good job Pinmemberahmadaa25-Feb-06 10:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141216.1 | Last Updated 25 Feb 2006
Article Copyright 2006 by Ahmad_Hashem
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid