Mike Blaszczak's Sample Programs
These samples are provided without warranty; they are notguaranteed to be fit
for any purpose or application. The samples are provided in order to support
presentations or otherdocumentation; they are not endorsed or supported by
Microsoft Corporation. The samples are provided on an "as-is" basis.
Files found on this page which note that they contain long file namescan be
properly unzipped with utilities like
All samples on this page are covered by at least one copyright:
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 Mike Blaszczak.
Copyright (C) 1996, 1997, 1999, Wrox Press Limited.
The page itself is covered by copyright:
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000 by Mike Blaszczak.
Absolutely: link to this page all you want. Scraping the code and/or
descriptions and republishing them is absolutely forbidden. Using the
code for your education is strongly encouraged. Resusing bits of the
code in your own commercial product is fine by me, as is creating a
derivative work based on the code you've found here. But remember
that there is no warranty or support for any bit of code you find here.
Sorry for the leaglese, but there are lots of vultures out there. Everyone
wants to turn a buck and they don't care where they get the
intellectual property that serves for their content, it seems.
ADD.ZIP 12675 bytes; UNZIP with directory preservation.
This sample was developed on stage at the Washington Software Association's WinSIG
meeting on the ninth of September, 1996 using Visual C++ 4.2. The sample shows an
ISAPI extension that generates a form which allows you to add two numbers.
The server extension may be started by specifying a path to the DLL and using a
question mark after the name of the DLL. If your srever is named
MOOSEBOY, for example, and the
file is installed in thedirectory you've configured as a root for
your web server, you can executethe extension using the URL
APIBROW.ZIP 16230 bytes; UNZIP with directory preservation.
This project is designed to be used with Visual C++ 4.1. The project demonstrates the
use of common control callback items in an MFC applicationthat manages a
CListCtrl control in a
CListView. The sample parses any
comma-separated variable file, such as the
found in your
COLORLB.ZIP 53420 bytes; UNZIP with directory preservation. This sample contains long file names. Uploaded on 24 April, 2000.
The COLORLB sample shows how to implement an owner-draw list box. The
box is drawn LBS_OWNERDRAWFIXED and also uses the LBS_HASSTRINGS style.
The box allows you to individually set the color of each item in the box.
COMPER.ZIP 125740 bytes; UNZIP with directory preservation. This sample contains long file names. Uploaded on 28 February, 2000.
COMPER is an example of the ATL Composite Control. It holds an instance
of the XCTRL sample, which you can download on from this page. When the
COMPER control is resized, it resizes the control within it to be the
exactly fit the client area of the composite control. It demonstrates
a couple of important ways to talk to a contained control from the
encompassing control. First, COMPER exposes an Edit methodinvoking
this method causes the control to turn around and invoke the same method
on the contained control. The control also manages its dirty bit, and
demonstrates the use of
CUSTFILE.ZIP 23526 bytes; UNZIP with directory preservation. Posted on 18 October, 1998.
This sample shows how to add a couple of extra buttons to a
The sample derives its own class from
CFileDialog, then glues in a
dialog template. The sample includes
//SAMPLE comments for the changed code,
but pay particular attention to the styles used on the additional dialog box
template. This is a Visual C++ 6.0 project.
CUSTLIST.ZIP 22550 bytes; UNZIP with directory preservation. Posted 6 March, 1999.
CUSTLIST shows how to use custom draw in a list view control. The exampleis a simple
MFC dialog-based project that has a single list view control (in report mode) on
its client area. The sample adds some items to the control. The sample handles
NM_CUSTOMDRAW notifications and changes the colours of every other
item in the control. You'll see that the custom draw technique is very easy to
implementand far, far simpler than doing full-blown owner-draw implementations
if you only want to change a few attributes of the control. Written with VC++ 6.0.
DIV.ZIP 14129 bytes; UNZIP with directory preservation. Posted 1 January, 1998.
This sample shows how floating-point exceptions may be captured and handled
in an MFC application. Review the code for
the DIVDLG.CPP sample file. The call to
will enable or disable exceptions from floating-point operations. Note
also that the program behaves the same way in debug and release builds.
DOODADS.ZIP 84485 bytes; UNZIP with directory preservation.
This project is designed to be used with Visual C++ 4.1. The project
demonstrates many Windows common controls, including the extensive
use of image lists. The project was used in the book "The Revolutionary
Guide To MFC 4 Programming With Visual C++", published by
Wrox Press. The sample was also used during
the talk "Using Windows Common Controls", offered at Boston University's WinDev
DOUBLEEDIT.ZIP 18010 bytes; UNZIP with directory preservation. Contains long file names. Posted on 14 January, 1999.
DOULBEEDIT shows how to sublcass an edit control inside a form view and react
to double-clicks on the edit control by handling the
message. As usual, look for
//SAMPLE comments to see where
all the action is!
DUMPSOME.ZIP 7775 bytes; UNZIP with directory preservation.
DUMPSOME is a project for Visual C++ 4.x that shows how to write a CGI
server extension which uses MFC and DAO. The sample dynamically generates
a web page that shows the first three records from a
sample database that's included in the DAO SDK. The
file included inthe archive explains how to build and set up the
sample on your server.
EDPOS.ZIP 34989 bytes; UNZIP with directory preservation, this archive contains long file names. Posted on 19 February, 2000.
EDPOS is a MDI-based MFC application that shows an edit control in its
primary view. It adds a pane to the status bar in the window, and uses
ON_UPDATE_UI mechanism to find the row and column
position of the cursor in the edit control.
This sample clearly shows the use of the
CEdit::LineIndex() member functions. Written with
Visual C++ 6.0.
EDSTREAM.ZIP 35875 bytes; UNZIP with directory preservation, this archive contains long file names. Posted on 16 February, 1999.
Written for VC++ 6.0, this sample shows how to use the
StreamOut() members of the
CRichEditCtrl class in MFC. The code sets up a proper
EDITSTREAM structure and implements a callback. The sample provides
a dialog-based user interface that streams in (or out) a file of your choice.
FINDRICH.ZIP 26628 bytes; UNZIP with directory preservation. This archive contains long file names. Posted on 14 October, 2000.
RICHFIND is a dialog-based MFC application for Visual C++ 6.0. It shows
how to use the
FindText() method of
to find text in the control.
The user interface allows you to find a string, then search for subsequent
occurences of that string. The UI also provides a button that reads a file
from disk to populate the control; this button's implementation is a good
example of using the
StreamIn() method to load text from a file.
FLOATLIST.ZIP 49759 bytes; UNZIP with directory preservation. This archive contains long file names. Posted on 28 October, 1999.
The FloatList sample is an MFC-based SDI application with an edit view as its
main window. When you press CTRL+B in the edit, the application will display a
pick list. You can choose an item from the pick list with the arrow keys
and then press [ENTER] to select it, or press [ESC] to dismiss the list. The sample
shows how to display a floating list control, and how to communicate with it
from the application. Written for Visual C++ 6.0.
FULLY.ZIP 43403 bytes; UNZIP with directory preservation. Posted on 25 July, 1996.
FULLY shows how to make an MFC application make one of its views go full-screen
active. It was written to be published in one of the staple-bound newsletter-style
journals on Visual C++. After the editor for the magazine requested it, he
summarily ignored my communication surrounding the program and its supporting article.
The article, completely unedited, is included in this archive and describes the
sample. Complete source for the program is included. This sample was written
with a beta version of VC++ 4.1 and tested with the shipping version of VC++ 4.2.
The sample was not tested to work correctly under Windows NT 3.51: it's
only been testedfor "new shell" versions of Windows: namely, Windows NT 4.0 and
HOLDER.ZIP 68009 bytes; UNZIP with directory preservation. Updated on 26 January, 2000.
HOLDER contains the Internet Explorer web browser control using
CHtmlView in an MFC application. To enable extensibility, HOLDER
IDispatch interface on the contained control's site,
allowing the application to expose OLE Automation methods and variables to script
on the contained HTML page. The application holds a simple script page and lets
the container uses DHTML to modify the formatting of the page. The sample also uses
IDocHostUIHandler interface it supplies to optionally disallow
the context menu to appear when the user right-clicks the contained page.
On 1 November, 1999, this sample was updated to demonstrate the use of
IPersistStreamInitfor retrieving the HTML source code of the displayed page.
On 26 January, 2000, this sample was enhanced to allow programatically
inserting and displaying any arbitrary HTML into the control.
LANGLOAD.ZIP 1790 bytes. Posted on 18 October, 1999.
LANGLOAD shows how to use the
LANGUAGE keyword in a resource file to
mark language-specific resources. The sample builds two string tables,
one for French and one for English. The code in the sample sets the locale ID
LoadString(). First, the English locale is setthen,
the French locale. As a result, the code is able to load each string to be printed.
Setting the locale just proves the sample. In a real applciation, you'd rely
on the default locale set by the user for their preferences in the system. Note that
the API used to set the locale is only available on Windows NT, so the sample only
works on Windows NT. But the locale setting is available on Windows 98 and Windows 95,
so the technique of using the
LANGUAGE to manage different resources for
each locale is applicable even on those operating systems.
LISTFIND.ZIP 8536 bytes. Posted on 1 November, 1999.
This sample shows how to use the
CList<> template. The
sample creates a class called
CPlayer, and instantiates a few objects.
The sample inserts those objects into a
Then, it calls
CList::Find() to cause MFC to call the specialization.
The point of this sample is to show a properly declared tempalte function
specialization for the
NDBROW.ZIP 20136 bytes. Posted on 13 October, 2000. Unzip with directory preservation.
This Visual C++ 6 project shows how to create an MDI
application that hosts
CHtmlView, but doesn't use
the doc/view architecture. Since views don't require
a document to be instantiated, this code is really very simple!
MFCTALK.ZIP 22567 bytes; UNZIP with directory preservation. Posted on 27 June, 1996.
MFCTALK was originally published with Mike's article on ISPAI programming
with MFC in the May, 1996 issue of
Microsoft Systems Journal.
The sample demonstrates how to write an ISAPI application with the MFC classes
introduced in MFC version 4.1. The sample shows how to use synchronization
objects (specifically, a
CCriticalSection) to protect data
handled by individual requests from corruption across threads.
MFCTLIST.ZIP 28636 bytes; UNZIP with directory preservation. Posted on 3 May, 1998.
MCTTLIST is a dialog-based application that provides the same
functionality as the TLIST sample in the SDK. That is, it enumerates the
processes on the system and puts information about them into a list view
control. You can use the application to kill processes. Works on Windows 95,
Windows 98, and Windows NT 4.0. This is a VC++ 5.0 project.
MRULESS.ZIP 32414 bytes; UNZIP with directory preservation. This archive has long file names. Posted on 13 October, 2000.
MRULESS shows a way to strip the empty "Recent Files" item off the
"File" menu when there are no entries in the MRU. The program makes
agressive use of the
CMenu class and the
WM_INITMENU message, and flirts with MFC's widely misunderstood
CRecentFileList class. This project was written for VC++ 6.0.
MTPRINT.ZIP 21497 bytes; UNZIP with directory preservation. Posted on 1 December, 1996.
MTPRINT demonstrates the use of a secondary thread to perform printing
in an application that uses MFC's document/view architecture. The application was
intended to be included on the CD to The Revolutionary Guide to MFC 4 Programming
With Visual C++ published by
Wrox Press. This is a VC++ 4.2 project.
MULTITOP.ZIP 30430 bytes; UNZIP with directory preservation. Posted on 8 March, 1998.
MULTITOP shows how to write an SDI application which has multiple top level
windows and uses the MFC doc/view architecture. The application creates a
single SDI frame and provides an extra "Create New Frame" command in the
"File" menu. That command causes the application to create a new view, document,
and top-level frame. The application continues to manage a main window: when
the main window is closed, the other frame windows are closed as well. The
non-main windows can be closed an opened at will without affecting the other
windows. The resulting UI is very similar to the "project" style user
interface that the Visual Basic 4.0 IDE provided.
//SAMPLE comments highlight the changes made to a
normal AppWizard-produced project. This is a VC++ 5.0 project.
NJFIND16.ZIP 33057 bytesThis 16-bit DOS
tool traverses all directories on all drives on your
machine and finds files which match the template you specify. Searches inside ZIP,
ARC, ARJ, DWC, ZOO, and PAK files for matches, too! Extremely fast, with powerful
command-line user interface. Formerly Shareware.
NOFORM.ZIP 33690 bytes; UNZIP with directory preservation.
This sample shows how to make an application that doesn't havethe doc/view
architecture but still offers a form in the client area of the application's main window.
This sample started out as an MDI app without doc/view support from the
Visual C++ 6.0 AppWizard. Look for
//SAMPLE comments in all
files to see the changes that were necessary to hook-up the form view.
ODCOMBO.ZIP 22958 bytes; UNZIP with directory preservation. This archive has long file names.
ODCOMBO.ZIP is a VC++ 6.0 dialog-based project that contians
an onwer-drawn combo box. The combo is implemented in its own
class, so it'll be easy to rip out and use in
your own code. The code supports fixed-size ownerdraw to make the combo box
show all of its items text centered horizontally in each line of the box.
Most of the code was ripped off from MFC's
PICKNEW.ZIP 49614 bytes; UNZIP with directory preservation. This archive has long file names.
This VC++ 5.0 project shows how to have multiple document templates
registered and avoid the "New File Type" dialog that MFC will automatically
generate. It demonstrates calling
PRIMECON.ZIP 60888 bytes; UNZIP with directory preservation. This archive contains long file names.
PrimeCon is a VC++ 6.0 sample which uses MFC in a console application.
This executable spins off one thread which works at finding prime numbers.
The thraed uses PostThreadMessage() to notify another thread about the
primes that it has found. The secondary thread owns and displays a dialog
box. When a prime is found, the console thread uses printf() to show the
prime found, while the dialog lists all the founds prime numbers in a
list box. The sample shows the proper use of MFC in a console application,
and furhter demonstrates the use of custom thread messages and the creation
of graphical user interface components from a
Q1.ZIP 79910 bytes; UNZIP with directory preservation. This archive has long file names. Posted on 16 November, 1999.
Q1 is a VC++ 6.0 project that creates two threads. The first thread does
not have a message queue. The main thread tries to send the first thread amessage,
and shows that the return from the
FALSE in that situation. The app creates a second thread that does
have a message queue. The main thread shows that
TRUE in that situation. This sample does not use MFC.
SCRL.ZIP 13613 bytes; UNZIP with directory preservation. Posted on 9 November, 1997.
This dialog-based application shows how to use the
member. It subclasses a list view control which is in report mode, and forces
the control to "snap" its horizontal scrolling to the exact start of each column.
The code shows how to retrieve the count of columns in the control, and also
demonstrates how to find information about each column. This is a VC++ 5.0 project.
Differences from a stock AppWizard dialog-based application are marked
SPINRANGE.ZIP 23986 bytes; UNZIP with directory preservation. This archive has long file names. Posted on 10 November, 1999.
SpinRange is a VC++ 6.0 project that shows how to subclass a
CSpinButtonControl to dramatically extend the range of the control.
CHugeSpinButton implements a spin buttoncontrol that can range over
signed or unsigned
__int64 values. The class is very reusable:
after test-driving it in the sample's harness, you can readily move it to your
own project with ease.
SPLITS.ZIP 36459 bytes; UNZIP with directory preservation. This archive has long file names.
This VC++ 5.0 project shows how to manage views within a splitter window.
The static splitter will contain two windows; one remains attached to a
particular view type and the other may be toggled using a menu items between
one view type and another. The app features an MDI user interface and demonstrates
STEALTH.ZIP 29539 bytes; UNZIP with directory preservation. This archive has long file names. Updated on 9 November, 1997.
This SDI application shows how to create an application that doesn't
show up in the task bar in Windows 95 or Windows NT 4.0. (The application
shouldn't show up in the task list in Windows NT 3.51, either, but I'm not at
liberty to test that, I'm afraid.) The application shows how to override
PreCreateWindow() for your
AfxRegisterWndClass() for your own windows, and stresses
the difference between a parent window and an owner window. The changes in
this application, above and beyond what the AppWizard produces for an
SDI application, are all marked with
This is an VC++ 5.0 project.
TENHOOK.ZIP 19108 bytes; UNZIP with directory preservation.
Because the Windows dialog manager eats all keystrokes, you'll need to
install a Windows keyboard hook if you want to get keyboard input to your
dialog without other controls getting in the way. This sample does just
that, in a VC++ 6.0 MFC Dialog-based application. The code reacts to any
keystroke being made, but shows when ALT+F10 is pressed. This sample
SetWindowsHookEx() API to set a Windows
hook. It also shows proper use of
GetAsyncKeyState(), as well as a good implementation
TREESTORE.ZIP 41736 bytes; UNZIP with directory preservation. This archive has long file names. Uploaded 17 January, 2000.
Tree views are capable of storing hierarchical data, which isn't intuitively
serialized. The TreeStore sample is an MDI application which
shows a view based on
CTreeView and demonstrates loading and
saving the content of the control with MFC's
serialization. The code is also rife with calls to the item navagation
WRITERES.ZIP 579568 bytes; UNZIP with directory preservation. Uploaded on 11 December, 1999.
This console application shows how to bake resources into console applications. The
sample also demonstrates using
SizeofResource() APIs to access the
bytes in the image resources directly. The sample uses an
stdio FILE to write the bytes of the resource out to new files.
XCTRL.ZIP 101659 bytes; UNZIP with directory preservation. This archive has long filenames. Uploaded on 28 February, 2000.
The XCTRL sample is an ATL "full control" ATL Control. It's really just
a stock OLE control that draws an "X" through it's client area. It features
a single property that allows you to set the thickness of the line. It also
features a single method, Edit, that increments the size of the line by one.
I'm providing this control just to have a stock control of my own that I
can use in other control containment sample apps.
This page has been hit approximately
times since April 20th, 1997, and was last Updated on 14 October, 2000.
Back to Mike's home page.