home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Mother of All Windows Books
/
CD-MOM.iso
/
cd_mom
/
newsletr
/
vbz
/
vbz1-3
/
dll_src.exe
/
MSGMUSIC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-02-17
|
2KB
|
66 lines
//MSGMUSIC.C
//Main module for MSGMUSIC.DLL - replacements for:
//MessageBeep and MessageBox
//by Jonathan Zuck
//Copyright 1992 Jonathan Zuck & The Windows Tech Journal
#include <windows.h>
#define NSOUNDS 5
#define MAXNOTES 7
int FREQ [NSOUNDS][MAXNOTES * 2 + 2] =
{
//This is my lookup table (0 based)
//{Repeat, nNotes, Freq, Duration, Freq, Duration... etc.}
{1, 2, 750, 15, 600, 25}, //Normal (Doorbell)
{3, 2, 900, 15, 700, 15}, //STOP (Claxon)
//Question ("Huh?!")
{1, 7, 220, 1, 330, 1, 440, 1, 660, 1, 880, 1, 1319, 1, 1760, 1},
{1, 2, 75, 15, 45, 20}, //Exclamation ("Oh, oh!")
{10, 2, 600, 1, 800, 1}, //Info (Phone)
};
int FAR pascal
LibMain(HANDLE hModule, WORD wDataSeg, WORD cbHeapSize, LPSTR lpszCmdLine)
{
if (cbHeapSize > 0)
UnlockData(0);
return (1);
}
void El2Queue (WORD El) //Send notes from corresponding array element
{
int c, n, nDur;
long lFreq;
OpenSound ();
for (c = 1; c <= FREQ[El][0]; ++c)
for (n = 2; n <= (FREQ[El][1] * 2); n=n+2)
{
lFreq = MAKELONG (0, FREQ[El][n]);
nDur = FREQ[El][n+1] * 10;
SetVoiceSound (1, lFreq, nDur);
StartSound ();
}
}
void FAR pascal MusicBeep (WORD wType)
{
El2Queue (wType / 16);
WaitSoundState (S_QUEUEEMPTY);
CloseSound ();
}
int FAR pascal
MusicBox (HWND hWndParent, LPSTR lpText, LPSTR lpCaption, WORD wType)
{
int Result;
El2Queue (wType / 16);
Result = MessageBox (hWndParent, lpText, lpCaption, wType);
CloseSound ();
return (Result);
}