Click here to Skip to main content
13,864,533 members
Click here to Skip to main content
Add your own
alternative version


37 bookmarked
Posted 30 May 2006
Licenced CPOL

Desktop Puzzle Game

, 12 Sep 2006
Rate this:
Please Sign up or sign in to vote.
A Desktop puzzle game.


This is a known but a different puzzle game. The images of puzzles are not included; in fact, the images are captured from your desktop! First of all, you can select the game difficulty: easy, medium, hard, and by pressing the Start button, the game will begin after the number of seconds you have specified (default is 2 seconds).

Game instructions

  • to move a rectangle, select the first and then a second one by clicking on the rectangles.
  • to rotate a rectangle by 180 degrees, right click on the rectangle.
  • to reveal the borders of each slice, you can click the middle button of the mouse.

Sample Image - Desktop_Puzzle_Game.jpg

Here are the main methods:

// - Saves the bitmap of display DC to a memory DC
void        CaptureDesktop();

// - Replaces two rects in memory device context
void        ReplaceRects(CRect rectSource, CRect rectDest);

// - Inverts selected rect
void        InvertRect(CRect rect);

// - Draws a frame around a rectangle
void        FrameRect(CRect rect, BOOL bClear=FALSE);

// - Draws a frame around all rectangles
void        DrawFrames();

// - Checks if user has been corrected all rectangles
int        CheckForWin();

// - Returns rect of selected square
CRect        GetSquareFromPoint(CPoint point);

// - Select a rectangle (source) or Replace first selected rectangle (source) 
//   with new selected rectangle (destination)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

// - Draw all frames for help or clear them all
afx_msg void OnMButtonDown(UINT nFlags, CPoint point);

// - Invert selected rectangle
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);

// - Checks for number of wrong items
afx_msg void OnExit();

// - Draws wrong items
afx_msg void OnTimer(UINT nIDEvent);

This is not a new game, just an attempt to help others on how to write such programs and may be find some techniques from this. Any suggestions and refinements are welcome. Enjoy the game!


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


About the Author

Hadi Dayvary
Software Developer
Iran (Islamic Republic of) Iran (Islamic Republic of)
Hadi Dayvary graduated from Azad University in spring 2003 in Apply Mathematics.
Started Visual C++ in 1999.
He likes to program all the time.
He lives in Iran.

You may also be interested in...

Comments and Discussions

Generalnice one i like it Pin
zzx_12345625-Jun-09 0:13
memberzzx_12345625-Jun-09 0:13 
Generalsend project Pin
farzaneh13651-May-08 1:06
memberfarzaneh13651-May-08 1:06 
GeneralRe: send project Pin
Hadi Dayvary2-May-08 19:50
memberHadi Dayvary2-May-08 19:50 
Generalnice Pin
bhage15-Sep-06 20:22
memberbhage15-Sep-06 20:22 
GeneralNice Idea Pin
NormDroid12-Sep-06 5:54
professionalNormDroid12-Sep-06 5:54 
GeneralGood idea & some suggestion. Pin
jcem16-Jul-06 23:04
memberjcem16-Jul-06 23:04 
GeneralA great idea, and some challenges ahead... Pin
Jun Du31-May-06 4:14
memberJun Du31-May-06 4:14 
GeneralRe: A great idea, and some challenges ahead... Pin
Hadi Dayvary31-May-06 22:10
memberHadi Dayvary31-May-06 22:10 
GeneralRe: A great idea, and some challenges ahead... Pin
Jun Du1-Jun-06 14:20
memberJun Du1-Jun-06 14:20 
GeneralGreat Article Pin
SBaghestani31-May-06 1:17
memberSBaghestani31-May-06 1:17 
GeneralRe: Rubbish Article but interesting project Pin
Michael P Butler16-Jul-06 0:07
memberMichael P Butler16-Jul-06 0:07 
GeneralI like it Pin
qiuqianren31-May-06 0:45
memberqiuqianren31-May-06 0:45 

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

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

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06 | 2.8.190214.1 | Last Updated 12 Sep 2006
Article Copyright 2006 by Hadi Dayvary
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid