您的位置:首页 > 其它

Beep sound, delay function in VS

2013-04-03 08:09 411 查看
VC中让软件发出Beep声,用Beep函数,另需添加头文件, #include <windows.h>,例如,Beep(1000,500);


Syntax

C++

BOOL WINAPI Beep(
_In_  DWORD dwFreq,
_In_  DWORD dwDuration
);



Parameters

dwFreq [in]

The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).
dwDuration [in]

The duration of the sound, in milliseconds.

延迟函数如下,

int sTime, eTime;
sTime = ::GetTickCount();
eTime = ::GetTickCount();
while (eTime - sTime < 500)
{
MSG msg;
GetMessage(&msg, NULL, 0, 0);
TranslateMessage(&msg);
DispatchMessage(&msg);
eTime = ::GetTickCount();
}

 使用Sleep函数,或者使用循环来导致延迟,会出现窗口死的情况,用以上函数则没有,或者使用Timer和线程也可以。

转载:

在一个对话框中访问另一个对话框的变量

HWND mHwnd = ::FindWindow(NULL,"dlgok");//通过windowname得到该窗体的句柄
 DlgOk* mDlgok= (DlgOk*)CWnd::FromHandle(mHwnd ); //有该句柄得到对话框类的指针
 int ntemp= mDlgok->m_temp; //访问其中的变量
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  VS Beep delay