# SPEAKN Sample: Demonstrates Multimedia Sound Using User-Defined Resources

The SPEAKN sample brings together graphics output and sound output. The SPEAKN sample illustrates multimedia extensions with the following programming techniques:

- Implementing sound output using the multimedia APIs defined in the Platform SDK MMSYSTEM.H header file.

- Using user-defined resources to store multimedia data like sounds and bitmaps. See Technical Note 35: Using Multiple Resource Files and Header Files with Visual C++ for a discussion of maintaining user-defined resources in a separate .rc file not maintained directly by Microsoft Visual C++.

- Using bitmap buttons. (The CTRLTEST sample application provides a more exhaustive illustration of using CBitmapButton.)

A sound card is required if you want to hear the sound output, but you can run the application without a sound card.

Security Note
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

# Building and Running the Sample

#### To build and run the SPEAKN sample

1. Open the solution Speakn.sln.

2. On the Build menu, click Build.

3. On the Debug menu, click Start Without Debugging.

When you first run SPEAKN, it plays a "welcome" sound and displays a What is this dialog box. When the sound play completes, SPEAKN displays the first of a series of images — a picture of a dog. Type "dog" into the edit box. When you enter the correct word, SPEAKN rewards you with a sound and moves on to the next image.

The happy-face bitmap initially has no smile or frown. If the first character you type is correct, the face turns to a smile; if it is incorrect, the face turns to a frown.

# Keywords

This sample demonstrates the following keywords:

AfxGetResourceHandle; AfxMessageBox; CBitmapButton::AutoLoad; CBitmapButton::LoadBitmaps; CDialog::DoModal; CDialog::EndDialog; CDialog::OnInitDialog; CDialog::OnOK; CFont::CreateFontIndirect; CString::GetLength; CString::IsEmpty; CString::LoadString; CString::MakeUpper; CWinApp::InitInstance; CWnd::DoDataExchange; CWnd::EnableWindow; CWnd::GetDlgItem; CWnd::GetWindowText; CWnd::Invalidate; CWnd::SetFocus; CWnd::SetFont; CWnd::SetWindowText; CWnd::ShowWindow; CWnd::SubclassDlgItem; CWnd::UpdateData; CWnd::UpdateWindow; DestroyIcon; FindResource; FreeResource; LoadIcon; LoadResource; LockResource; MAKEINTRESOURCE; PlaySound; PostQuitMessage; lstrcpy; mbstowcs; memset; sndPlaySound; strlen

Note
Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.