VC++ 2005 Example Programs

A first Windows application (winapp1.cpp)

A Windows application that displays something and responds to mouse and keyboard input (winapp2.cpp)

Dialog Box Example for CS-580H students (Dialog-test-09.cpp)

An MFC App/Win Program (draws characters, responds to mouse)-- implemention file (msgnew.cpp)

An MFC, App/Win Program -- declaration header file (msgnew.h)

SKETCH--An MFC AppWizard/ClassWizard-assisted Doc/View program that permits color sketching--view class implementation (sketchvw.cpp)

The view class declarations for SKETCH (sketchvw.h)
 

VC++ 2002/2003 Example Programs

Example 1: A simple console application (hello.c)

Example 2: A first Windows application (winapp1.cpp)

Example 3: A Windows application that displays something and responds to mouse and keyboard input (winapp2.cpp)

Example 3: The resource script file generated for winapp2 by Visual Studio (winapp2.rc)

Example 3: The header file generated for winapp2 by Visual Studio (resource.h)

Example 4: A First MFC, App/Win Program (an application skeleton)-- implemention file (prog1.cpp)

Example 4: A First MFC, App/Win Program (an application skeleton)-- declaration header file (prog1.h)

Example 5: A second MFC, App/Win Program (draws characters, responds to mouse)-- implemention file (msgnew.cpp)

Example 5: A Second MFC, App/Win Program (draws characters, responds to mouse)-- declaration header file (msgnew.h)

Example 6: SKETCH--An MFC AppWizard/ClassWizard-assisted Doc/View program that permits color sketching--view class implementation (sketchvw.cpp)

Example 6: The view class declarations for SKETCH (sketchvw.h)
 

VC# Example Programs

HelloWorld

HelloWorld-designer

Hello-in-window

Hello-in-window-designer

HelloWorld-override

SeparateMain

HelloWorld-inherit-base

HelloWorld-inherit

TwoPaintHandlers

RandRect100

CloseInTen

RandomRectangles-timer

BouncingBall

SimpleClock

ImageFromFile

ImgFromFileBetter

ImgCenter

ImgScaleToWindow

ImgPart

ImgPartScale

ImgAtPoints

ImgDrawOn

ImgShadowBitmap

ImgShadowBitmap2

Sketch-dotNet

Sketch-dotNet-ArrayList

Sketch-dotNet-Bitmap

Mouse-Enter-Leave-Hover

MouseCursors

Key

KeyArrows

ButtonLabel

Button-Image

GroupBox-Panel

Scroll-Image

Radio-Check

Font-Bold-Italic

Font-Name

Font-Sizes

Font-Properties

Common-Color-Dialog

Common-Color-Font-Dialog

Dialog-Manual

Dialog-Designer-Form1
Dialog-Designer-SimpleDialogBox

ImgEmbedded

DlgBoxPropertiesTest-Form1
DlgBoxPropertiesTest-DlgBox

Radio-Check-Dialog-Form1.cs
Radio-Check-Dialog-ColorFillDialogBox

TextBox-Simple

TextBox-Multiline

Compute-Interest

ListBox-Simple

Menu-Drawing-Manual

Menu-Drawing-Designer

Context-Menu-Manual

Context-Menu-CDlgBox

Print-Simple

Print-Simple-Designer

Print-Preview-Simple

Listbox-Simple-Print

PrintableForm.cs

Sketch-Print (Form1.cs)
Sketch-Print (PrintableForm.cs)

FileStream-Write

FileStream-Read

File-Write-OpenFileDialog

File-Read-OpenFileDialog

File-Serializable-Book-Class (Book.cs)
File-Serializable-Form1-Class (Form1.cs)

Ten-Centimeter-Ruler (Form1.cs)
Ten-Centimeter-Ruler (PrintableForm.cs)

World-Transformation

Clipboard-Simple

Threads-OneThread

Threads-TwoThreads

StartProcess

MCI-PlayCD

mciSendString-Test

MCI-Record-Play

MCI-Sendstring-Errorstring-Stringbuilder

CountedControl
CountedControlTester

UserControlTest

DisplayNameControl
DisplayNameTester

GetIpAddress

Simple Chat Client

Simple Chat Server

DataReadingWithDataSet

DataSelectRow

DatabaseWeb

DataUpdate06

DataDisplay

DataSQLSelect

DataFillAddUpdate

DataBooks

DataBooksCombo


Old VC++ Example Programs

Example 4-1: A Windows application that illustrates Bitblt() and Stretchblt() (bitmap1.cpp)

Example 4-1: A resource script file generated manually for bitmap1 (bitmap1.rc)

Example 4-1: A header file generated manually for bitmap1 (bitmap1.h)

Example 4-2: A Demonstration of Bitblt() RasterOps (bitmap3.cpp)

Example 4-2: A resource script file generated manually for bitmap3 (bitmap3.rc)

Example 4-2: A header file generated manually for bitmap3 (bitmap3.h)

Example 4-3: A Bouncing Ball Animation using a PeekMessage() Loop (ball.cpp)

Example 4-3: A resource script file generated manually for ball (ball.rc)

Example 4-3: A header file generated manually for ball (ball.h)

Example 4-4: Bouncing Ball Animation with Bitblt() to Preserve Background (ballblt.cpp)

Example 4-5: Bouncing Ball Animation using a Timer (balltime.cpp)

Example 4-6: Bounding Ball Animation using a Timer in MFC, implementation view file (balltimeView.cpp)

Example 4-6: Bouncing Ball Animation using a Timer in MFC, declaration view file (balltimeView.h)

Example 4-6 for DOTNET (balltime animation, balltimeView.cpp file)

Example 4-6 for DOTNET (balltime animation, balltimeView.h file)

Example 4-6 for DOTNET (balltime animation, balltime.rc file)

Example 4-6: lineminimum DirectX Example--draws horizontal lines on DirectDraw surface (horlines.cpp)

Example 4-6: lineminimum DirectX Example--cdirdraw class implementation (cdirdraw.cpp)

Example 4-6: lineminimum DirectX Example--cdirdraw class declaration (cdirdraw.h)

Example 5-1: Using Child Window Static Controls (static.cpp)

Example 5-1a: Using Child Window Static Controls from MFC (static_mfcView.cpp)

Example 5-1a: Using Child Window Static Controls from MFC (static_mfcView.h)

Example 5-1: A resource script file generated manually for static (static.rc)

Example 5-1: A header file generated manually for static (static.h)

Example 5-2: Using Child Window Static Controls with Variable Numeric Output (static1.cpp)

Example 5-3: Using Button Controls (button.cpp)

Example 5-3: A resource script file generated manually for button (button.rc)

Example 5-3: A header file generated manually for button (button.h)

Example 5-3a: Using Button Controls from MFC (button_mfcView.cpp)

Example 5-3a: Using Button Controls from MFC (button_mfcView.h)

Example 5-3b: Using Bitmap Button Controls from MFC (button_bitmap.cpp)

Example 5-3b: Using Bitmap Button Controls from MFC (button_bitmap.h)

Using Standalone Scroll Bar Controls in MFC - View Class (scroll1_mfc_cpp)

Using Standalone Scroll Bar Controls in MFC - View Class (scroll1_mfc_h)

Using Attached Scroll Bar Controls in MFC - View Class (scroll2_mfc_cpp)

Using Attached Scroll Bar Controls in MFC - View Class (scroll2_mfc_h)
 

Using a Programmer-defined Child Window  in MFC - Cchild_cpp

Using a Programmer-defined Child Window  in MFC - Cchild_h

Using a Programmer-defined Child Window  in MFC - child_mfcView_cpp

Using a Programmer-defined Child Window  in MFC - child_mfcView_h
 

Example 5-4: Using Listbox Controls (listbox.cpp)

Example 5-4: A resource script file generated manually for listbox (listbox.rc)

Example 5-4: A header file generated manually for listbox (listbox.h)

Example 5-5: Using Combo Box Controls (combo.cpp)

Example 5-5: A resource script file generated manually for combo (combo.rc)

Example 5-5: A header file generated manually for combo (combo.h)

Example 5-6: Using Standalone Scroll Bar Controls (scroll1.cpp)

Example 5-6: A resource script file generated manually for scroll1 (scroll1.rc)

Example 5-6: A header file generated manually for scroll1 (scroll1.h)

Example 5-7: Using a Scroll Bar Attached to a Window (scroll2.cpp)

Example 5-7: A resource script file generated manually for scroll2 (scroll2.rc)

Example 5-7: A header file generated manually for scroll2 (scroll2.h)

Example 5-7a: Using attached scroll bars from MFC (scroll2_mfc_cpp)

Example 5-7a: Using attached scroll bars from MFC (scroll2_mfc_h)

Example 5-8: Using an Edit Control (edit1.cpp)

Example 5-8: A resource script file generated manually for edit1 (edit1.rc)

Example 5-8: A header file generated manually for edit1 (edit1.h)

Example 6-1: Sketcher program--modification of winapp2, responds to mouse and keyboard input (sketch.cpp)

Example 6-1: The resource script file generated for sketch by Developer Studio (sketch.rc)

Example 6-1: The header file generated for sketch by Developer Studio (resource.h)

Example 6-2: Changing the mouse cursor, using the caret (mouscurs.cpp)

Example 6-2: The resource script file generated for mouscurs by Developer Studio (mouscurs.rc)

Example 6-2: The header file generated for mouscurs by Developer Studio (resource.h)

Example 6-3: A simple keyboard interface (keybd1.cpp)

Example 6-3: A resource script file generated manually for keybd1 (keybd1.rc)

Example 6-3: A header file generated manually for keybd1 (keybd1.h)

Example 6-4: Changing Fonts (font1.cpp)

Example 6-4: A resource script file generated manually for font1 (font1.rc)

Example 6-4: A header file generated manually for font1 (font1.h)

Example 6-5: Changing Fonts, Using Keyboard Accelerators, Adding a Caret (font2.cpp)

Example 6-5: A resource script file generated manually for font2 (font2.rc)

Example 6-5: A header file generated manually for font2 (font2.h)

Example 7-1: Using a Complex Menu (menu1.cpp)

Example 7-1: A resource script file generated manually for menu1--one layout (menu1a.rc)

Example 7-1: A resource script file generated manually for menu1--another layout (menu1b.rc)

Example 7-1: A header file generated manually for menu1 (menu1.h)

Example 7-2: Using Dynamic Menus with Graphics menu items (menu2.cpp)

Example 7-2: A resource script file generated by Developer Studio for menu2--has no menu (menu2.rc)

Example 7-2: A header file generated manually for menu2--contains the menu IDs (menu2.h)

Example 7-2: The header file generated for menu2 by Developer Studio (resource.h)

Example 8: Using Child Windows (child.cpp)

Example 8: A resource script file generated manually for child (child.rc)

Example 8: A header file generated manually for child (child.h)

Example 9-1: Using a Simple Dialog Box (dlg1.cpp)

Example 9-1: The resource script file generated for dlg1 by Developer Studio (dlg1.rc)

Example 9-1: The header file generated for dlg1 by Developer Studio (resource.h)

Example 9-2: Dialog Box with Edit & Listbox Controls, Data Exchanged in Globals (dlg2.cpp)

Example 9-2: The resource script file generated for dlg2 by Developer Studio (dlg2.rc)

Example 9-2: The header file generated for dlg2 by Developer Studio (resource.h)

Example 9-3: A simple dialog-box based application (dlgbasedapp.cpp)

Example 10-1: Changing the Device Context Mapping Mode (mapmode1.cpp)

Example 10-1: A resource script file generated manually for mapmode1 (mapmode1.rc)

Example 10-1: A header file generated manually for mapmode1 (mapmode1.h)

Example 10-2: The Anisotropic Mapping Mode (mapmode2.cpp)

Example 10-2: A resource script file generated manually for mapmode2 (mapmode2.rc)

Example 10-2: A header file generated manually for mapmode2 (mapmode2.h)

Example 11-1: Simple Output to Printer (print1.cpp)

Example 11-1: A resource script file generated manually for print1 (print1.rc)

Example 11-1: A header file generated manually for print1 (print1.h)

Example 11-2: LOMETRIC Mapping Mode Output to Printer (print2.cpp, uses print1.rc & print1.h)

Example 11-3: Getting the capabilities of a device (devcaps.cpp)

Example 12-1: Simple File I/O (file1.cpp)

Example 12-1: A resource script file generated manually for file1 (file1.rc)

Example 12-1: A header file generated manually for file1 (file1.h)

Example 12-2: File I/O Using the File Open and File Save Common Dialog Boxes (filecomd.cpp)

Example 12-2: A resource script file generated manually for filecomd (filecomd.rc)

Example 12-2: A header file generated manually for filecomd (filecomd.h)

Example 13-1: A Simple Clipboard Application with Text (clip1.cpp)

Example 13-1: A resource script file generated manually for clip1 (clip1.rc)

Example 13-1: A header file generated manually for clip1 (clip1.h)

Example 13-2: A Multiple-format Clipboard Application (clip2.cpp)

Example 13-2: A resource script file generated manually for clip2 (clip2.rc)

Example 13-2: A header file generated manually for clip2 (clip2.h)

Example 13.3: A Simple Text Editor with File Handling, Cut/Copy/Paste/Delete Capability (editccpd.cpp)

Example 13.3: The resource script file generated for editccpd by Developer Studio (editccpd.rc)

Example 13.3: The header file generated for editccpd by Developer Studio (resource.h)

OLD Source code for a REVSTR DLL containing a function that reverses a string (revstr.c)

NEW Source code for a REVSTR DLL containing a function that reverses a string (revstr.cpp)

OLD Header file for REVSTR DLL (revstr.h)

NEW Header file for REVSTR DLL (revstr.h)

DLLCALL: An OLD VERSION of an Application that uses the REVSTR DLL (dllcall.c)

DLLCALL: NEW VERSION of an Application that uses the REVSTR DLL (dllcall.c)

Header file for DLLCALL (dllcall.h)

Resource script file for DLLCALL (dllcall.rc)

Example 14.1: A First MFC Program (an application skeleton)-- implemention file (prog1.cpp)

Example 14.1: A First MFC Program (an application skeleton)-- declaration header file (prog1.h)

Example 14.2: An MFC Program that handles mouse, character, and paint messages-- implemention file (msg1.cpp)

Example 14.2: The msg1 MFC Message-Processing program's declaration header file (msg1.h)

Example 14.3: An MFC Program that uses menu bars and message boxes-- implemention file (menu1.cpp)

Example 14.3: The menu1 program's resource script file--generated by Dev Studio & edited (menu1.rc)

Example 14.3: The menu1 program's class declaration header file (menu1.h)

Example 14.3: The menu1 program's resource header file--generated by Dev Studio & Edited (resource.h)

Example 14.4: An MFC Program that uses a simple dialog box (dialog1.cpp)

Example 14.4: The dialog1 program's resource script file--generated by Dev Studio & edited (dialog1.rc)

Example 14.4: The dialog1 program's class declaration header file (dialog1.h)

Example 14.4: The dialog1 program's resource header file--generated by Dev Studio & Edited (resource.h)

Example 14.5: An MFC Program that uses a dialog box with a Listbox control to get user data (dialog2.cpp)

Example 14.5: The dialog2 program's resource script file--generated by Dev Studio & edited (dialog2.rc)

Example 14.5: The dialog2 program's class declaration header file (dialog2.h)

Example 14.5: The dialog2 program's resource header file--generated by Dev Studio & Edited (resource.h)

Example 15.1: SKETCH--An MFC AppWizard/ClassWizard-assisted Doc/View program that permits color sketching--view class implementation (sketchview.cpp)

Example 15.1: The view class declarations for SKETCH (sketchview.h)

Example 15.2: SKETCH3--An MFC AppWizard/ClassWizard-assisted Doc/View program that permits color sketching and uses a modal dialog box to get text to be displayed--view class implementation (sketchview.cpp)

Example 15.2: The view class declarations for SKETCH3 (sketchview.h)

Example 15.2: The Dialog class implementation for SKETCH3 (textdlg.cpp)

Example 15.2: The Dialog class declarations for SKETCH3 (textdlg.h)

Serializing a simple document (serial0doc.cpp)

Serializing a simple document (serial0view.cpp)

Sketching with serialization (sktchdoc.cpp)

Sketching with serialization (sktchview.cpp)

Sketching with serialization -- the Line class (line.cpp)

Using ActiveX Controls  (GridCtrlDlg.cpp)

A Simple X Window System XLIB Example Program (xhello.c)

An X Window System (XLIB) Drawing Program (drawz.c)