VC中如何响铃?

韩雷 2005-12-26 04:30:39
如果我生成的是win32 project
那么我可以用printf("\a");
来响铃,但如果我生成的是MFC Dialog project
该如何响铃呢?
...全文
153 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kugou123 2005-12-26
  • 打赏
  • 举报
回复
BOOL MessageBeep(
UINT uType
);



用这个可以调用一些windows的声音提示
j805 2005-12-26
  • 打赏
  • 举报
回复
MessageBeep

The MessageBeep function plays a waveform sound. The waveform sound for each sound type is identified by an entry in the registry.


BOOL MessageBeep(
UINT uType
);

Parameters
uType
[in] Sound type, as identified by an entry in the registry. This parameter can be one of the following values. Value Meaning
-1 Simple beep. If the sound card is not available, the sound is generated using the speaker.
MB_ICONASTERISK SystemAsterisk
MB_ICONEXCLAMATION SystemExclamation
MB_ICONHAND SystemHand
MB_ICONQUESTION SystemQuestion
MB_OK SystemDefault

Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks
After queuing the sound, the MessageBeep function returns control to the calling function and plays the sound asynchronously.

If it cannot play the specified alert sound, MessageBeep attempts to play the system default sound. If it cannot play the system default sound, the function produces a standard beep sound through the computer speaker.

The user can disable the warning beep by using the Sound control panel application.


Terminal Services: To send a beep to a client, use the Beep function. The Beep function is redirected to the client, whereas MessageBeep is not, except on Windows NT 4.0 where MessageBeep(-1) calls Beep.


Example Code
For an example, see Notifying the User of Errors.

Requirements
Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
Header: Declared in Winuser.h; include Windows.h.
Library: Use User32.lib.


xx_jj 2005-12-26
  • 打赏
  • 举报
回复
Beep( 750, 300 );
bobob 2005-12-26
  • 打赏
  • 举报
回复
给多少都可以,差别就是声音听起来不一样
韩雷 2005-12-26
  • 打赏
  • 举报
回复
dwFreq 参数代表频率,正常的频率应该是多少?
谢谢
pomelowu 2005-12-26
  • 打赏
  • 举报
回复
BOOL Beep(
DWORD dwFreq,
DWORD dwDuration
);

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧