Beep sound, delay function in VS
2013-04-03 08:09
411 查看
VC中让软件发出Beep声,用Beep函数,另需添加头文件, #include <windows.h>,例如,Beep(1000,500);
C++
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; //访问其中的变量
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; //访问其中的变量
相关文章推荐
- C/C++: Inline function, calloc vs malloc
- C/C++: Inline function, calloc vs malloc
- vs 2005链接时错误的解决方案 error LNK2019: unresolved external symbol __security_cookie referenced in function
- VS2015 MSVCRTD.lib(_chandler4gs_.obj) : error LNK2019: unresolved external symbol __except_handler4_common referenced in function __except_handler4
- vs2015编译gdal出错:error LNK2019: unresolved external symbol _vsnwprintf_s referenced in function String
- Object.create() vs new SomeFunction() in javascript
- vs 2005链接时错误的解决方案 error LNK2019: unresolved external symbol __security_cookie referenced in function
- 在VS13上编译通过的代码放在12上编译-错误:l __dtoui3 referenced in function _event_debug_map_HT_GROW
- C/C++: Inline function, calloc vs malloc
- C/C++: Inline function, calloc vs malloc
- C/C++: Inline function, calloc vs malloc
- What is the difference between a function expression vs declaration in JavaScript?
- C/C++: Inline function, calloc vs malloc
- Inline SVG vs Icon Fonts
- Duplicate range boundary values are not allowed in partition function boundary value list.
- OD: Memory Attach Technology - Off by One, Virtual Function in C++ & Heap Spray
- crtbegin_dynamic.o: in function _start:crtbrand.c(.text+0x78): error: undefined reference to 'main
- Fatal error: Call to undefined function imagecreatetruecolor() in
- 实现kernel-mode inline function hook的简单方法
- Function in loop and closure