A set of Microsoft Visual C++ projects for your pleasure.  All projects are zipped and include source code and executable (in case you want to play but don't have the tools required to build).

Coloured Controls - Demonstrates using a WM_CTLCOLOR message handler to create different coloured dialog controls.

Input Panel - A virtual keyboard ActiveX control.

Knight's Tour - Solves the Knight's Tour of the chess board problem.

Lottery Picker - Random number generator.

Net Send - Send messages to other people on your network.

Obfuscated C - The most mysterious piece of C code in the world (Not written by us, but so good we just had to include it).

Reminder - Simple alarm clock.

Round Clock - Demonstrates a non rectangular window.


Coloured Controls

Demonstrates the use of the WM_CTLCOLOR message to create coloured edit boxes and static text.  This is the clever bit:

HBRUSH CColouredControlsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
    HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here
    static CBrush* pBrush = NULL;
    if (m_bColour)
    {
        if (pBrush != NULL)
        delete pBrush;
        pBrush = new CBrush(RGB(rand() % 0xff, rand() % 0xff, rand() % 0xff));
        return *pBrush;
    }

    // TODO: Return a different brush if the default is not desired
    return hbr;
}

Download here.


Input Panel

An ActiveX control that implements a Windows CE style input panel for simulate keyboard input.  The panel has two built in layouts - qwerty and numeric, as well as allowing user configurable keyboard layouts.  Here it is running a a test harness (also provided).

Download here.


Knight's Tour

The knight's tour of the chess board is an ancient chess puzzle that this program solves.  The program implements a very slow brute force "tree search" algorithm and well as a highly efficient "least exits" algorithm.  Allows the user to run or step through the generation of the solution, which is presented graphically.

Download here.


Lottery Picker

Designed to pick random numbers for the UK National Lottery.  Used by several UK National Lottery syndicates.

Download here.


Net Send

A simple wrapper around the netsend command.  Allows the user to send a message box to any networked computer.  Note that you must have Microsoft's net.exe installed on your machine.

Download here.


Obfuscated C

Console application that prints out the words to the one of the most famous Christmas songs.  But nobody knows how!  Possibly the most convoluted piece of C code ever written. This one was NOT written in house - acknowledgement and respect due to the original author.  Here's a screenshot of the last verse:

And here's the abomination that produces the whole song:

Download here.


Reminder

A simple alarm clock.  Set the time you want the alarm to go off and the program minimises until the specified time is reached.  The Program then restores it's original screen position and give an audible alarm.

Download here.


Round Clock

An example of how to implement non rectangular windows.  Displays a round analogue clock showing the current time.

The code is so simple it's a wonder anybody still uses square windows at all:

SetWindowPos(NULL, 0, 0, 150, 150, SWP_NOZORDER | SWP_NOMOVE);
CRect rect;
GetWindowRect(rect);
CRgn region;
region.CreateRoundRectRgn(rect.left, rect.top, rect.right, rect.bottom, 150, 150);
SetWindowRgn(region, FALSE);

Download here.


Home