MFC Samples

Name

Date Size Platform
ADD.ZIP 9 September, 1996 12675 2000, XP
 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 server is named MOOSEBOY, for example, and the ADD.DLL file is installed in the directory you've configured as a root for your web server, you can execute the extension using the URL http://mooseboy/add.dll      
       
APIBROW.ZIP   16230 98, ME, 2000, XP
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 application that manages a CListCtrl control in a CListView. The sample parses any comma-separated variable file, such as theWIN32API.CSV file found in your \MSDEV\LIB directory.      
       
COLORLB.ZIP 24 April, 2000 53420 98, ME, 2000, XP
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 28 February, 2000 125740 98, ME, 2000, XP
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 method—invoking 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 GetDlgControl().      
       
CUSTFILE.ZIP 18 October, 1998 23526 98, ME, 2000, XP
This sample shows how to add a couple of extra buttons to a CFileDialog. 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 6 March, 1999 22550 98, ME, 2000, XP
CUSTLIST shows how to use custom draw in a list view control. The example is 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 MN_CUSTOMDRAW notifications and changes the color of every item in the control. You'll see that the custom draw technique is very easy to implement--and 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 1 January, 1998 14129 98, ME, 2000, XP
This sample shows how floating-point exceptions may be captured and handled in an MFC application. Review the code for CDivDlg::OnOK() in the DIVDLG.CPP sample file. The call to _control87() 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 98, ME, 2000
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 conference.      
       
DOUBLEEDIT.ZIP 14 January, 1999 18010 98, ME, 2000, XP
DOULBEEDIT shows how to sublcass an edit control inside a form view and react to double-clicks on the edit control by handling the WM_LBTNDOUBLECLICK message. As usual, look for //SAMPLE comments to see where all the action is!       
       
DUMPSOME.ZIP   7775 98, ME, 2000, XP
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 README.TXT file included in the archive explains how to build and set up the sample on your server.      
       
EDPOS.ZIP 19 February, 2000 34989 98, ME, 2000, XP
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 MFC's 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::LineFromChar() and CEdit::LineIndex() member functions. Written with Visual C++ 6.0.      
       
EDSTREAM.ZIP 16 February, 1999 35875 98, ME, 2000, XP
Written for VC++ 6.0, this sample shows how to use the StreamIn() and 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 14 October, 2000 26628 98, ME, 2000, XP
FINDRICH is a dialog-based MFC application for Visual C++ 6.0. It shows how to use the FindText() method of CRichEditCtrl to find text in the control. The user interface allows you to find a string, then search for subsequent occurrences 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 28 October, 1999 49759 98, ME, 2000, XP
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 25 July, 1996 43403 98, ME, 2000
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 tested for "new shell" versions of Windows: namely, Windows NT 4.0 and Windows 95.      
       
HOLDER.ZIP 26 January, 2000 68009 98, ME, 2000
HOLDER contains the Internet Explorer web browser control using CHtmlView in an MFC application. To enable extensibility, HOLDER implements an 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 the 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.      
       
LISTFIND.ZIP 1 November, 1999 8536 98, ME, 2000
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 CList<> collection. 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 theCompareElements() function.      
       
NDBROW.ZIP 13 October, 2000 20136 98, ME, 2000
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 27 June, 1996 22567 98, ME, 2000, XP
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 3 May, 1998 28636 98, ME, 2000, XP
MFCTLIST 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 13 October, 2000 32414 98, ME, 2000, XP
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 1 December, 1996 21497 98, ME, 2000, XP
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 8 March, 1998 30430 98, ME, 2000, XP
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. As usual, //SAMPLE comments highlight the changes made to a normal AppWizard-produced project. This is a VC++ 5.0 project.       
       
MULTITOP.ZIP 8 March, 1998 30430 98, ME, 2000, XP
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. As usual, //SAMPLE comments highlight the changes made to a normal AppWizard-produced project. This is a VC++ 5.0 project.       
       
NOFORM.ZIP   33690 98, ME, 2000, XP
This sample shows how to make an application that doesn't have the 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 98, ME, 2000, XP
ODCOMBO.ZIP is a VC++ 6.0 dialog-based project that contains an owner-drawn combo box. The combo is implemented in its own < code />class, so it'll be easy to rip out and use in your own code. The code supports fixed-size owner-draw 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 CCheckedListBox class.      
       
PICKNEW.ZIP   49614 98, ME, 2000, XP
This VC++ 5.0 project shows how to have  multiple document templates registered and not activate the "New File Type" dialog that MFC would otherwise automatically generates. It demonstrates calling CDocTemplate::OpenDocumentFile().      
       
SCRL.ZIP 9 November, 1997 13613 98, ME, 2000, XP
This dialog-based application shows how to use the CListCtrl::Scroll() 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 with //SAMPLE comments.      
       
SPINRANGE.ZIP 10 November, 1999 23986 98, ME, 2000, XP
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 button control 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 98, ME, 2000, XP
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 item. It switches between one view type and another. The app features an MDI user interface and demonstrates the CSplitterWnd::DeleteView() and CSplitterWnd::CreateView() member functions.      
       
STEALTH.ZIP 9 November, 1997 29539 98, ME, 2000, XP
This SDI application does not appear in the task bar in Windows. The application shows how to override PreCreateWindow() for your CMainFrame, using 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 //SAMPLE comments. This is a VC++ 5.0 project.      
       
TENHOOK.ZIP   19108 98, ME, 2000, XP
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-based dialog application. The code reacts to any keystroke being made, but shows when ALT+F10 is pressed. This sample demonstrates the SetWindowsHookEx() API to set a Windows hook. It also shows proper use of UnhookWindowsHook() and, GetAsyncKeyState(), as well as a good implementation of a KeyboardProc().      
       
       
TREESTORE.ZIP 17 January, 2000 41736 98, ME, 2000, XP
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 CArchive-based serialization. The code is also rife with calls to the item navigation routines of CTreeCtrl, including GetNextSiblingItem(), GetPrevSiblingItem(), and GetParentItem().