Add MessageBeep() API.

This commit is contained in:
Guido van Rossum 2003-04-09 19:38:08 +00:00
parent ed538d8b39
commit e1252684be
2 changed files with 23 additions and 2 deletions

View File

@ -56,6 +56,9 @@ PyDoc_STRVAR(sound_beep_doc,
"code doing direct port manipulation is used; it's unknown whether that\n" "code doing direct port manipulation is used; it's unknown whether that\n"
"will work on all systems."); "will work on all systems.");
PyDoc_STRVAR(sound_msgbeep_doc,
"MessageBeep(x) - call Windows MessageBeep(x). x defaults to MB_OK.");
PyDoc_STRVAR(sound_module_doc, PyDoc_STRVAR(sound_module_doc,
"PlaySound(sound, flags) - play a sound\n" "PlaySound(sound, flags) - play a sound\n"
"SND_FILENAME - sound is a wav file name\n" "SND_FILENAME - sound is a wav file name\n"
@ -173,10 +176,22 @@ sound_beep(PyObject *self, PyObject *args)
return Py_None; return Py_None;
} }
static PyObject *
sound_msgbeep(PyObject *self, PyObject *args)
{
int x = MB_OK;
if (!PyArg_ParseTuple(args, "|i:MessageBeep", &x))
return NULL;
MessageBeep(x);
Py_INCREF(Py_None);
return Py_None;
}
static struct PyMethodDef sound_methods[] = static struct PyMethodDef sound_methods[] =
{ {
{"PlaySound", sound_playsound, METH_VARARGS, sound_playsound_doc}, {"PlaySound", sound_playsound, METH_VARARGS, sound_playsound_doc},
{"Beep", sound_beep, METH_VARARGS, sound_beep_doc}, {"Beep", sound_beep, METH_VARARGS, sound_beep_doc},
{"MessageBeep", sound_msgbeep, METH_VARARGS, sound_msgbeep_doc},
{NULL, NULL} {NULL, NULL}
}; };
@ -216,6 +231,12 @@ initwinsound(void)
ADD_DEFINE(SND_LOOP); ADD_DEFINE(SND_LOOP);
ADD_DEFINE(SND_APPLICATION); ADD_DEFINE(SND_APPLICATION);
ADD_DEFINE(MB_OK);
ADD_DEFINE(MB_ICONASTERISK);
ADD_DEFINE(MB_ICONEXCLAMATION);
ADD_DEFINE(MB_ICONHAND);
ADD_DEFINE(MB_ICONQUESTION);
version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&version); GetVersionEx(&version);
whichOS = Win9X; whichOS = Win9X;

View File

@ -54,7 +54,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib winmm.lib /nologo /base:"0x1D160000" /dll /machine:I386 /out:"./winsound.pyd" # ADD LINK32 kernel32.lib winmm.lib user32.lib /nologo /base:"0x1D160000" /dll /machine:I386 /out:"./winsound.pyd"
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "winsound - Win32 Debug" !ELSEIF "$(CFG)" == "winsound - Win32 Debug"
@ -82,7 +82,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo # ADD BSC32 /nologo
LINK32=link.exe LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib winmm.lib /nologo /base:"0x1D160000" /dll /debug /machine:I386 /out:"./winsound_d.pyd" /pdbtype:sept # ADD LINK32 user32.lib kernel32.lib winmm.lib /nologo /base:"0x1D160000" /dll /debug /machine:I386 /out:"./winsound_d.pyd" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none # SUBTRACT LINK32 /pdb:none
!ENDIF !ENDIF