原创
Labwindows/cvi8.5学习日志(24)-- windows API函数---电脑驱蚊程序
2010-6-19 19:33
3752
9
10
分类:
软件与OS
//*********************************************************
// Labwindows/cvi8.5 windows API函数---电脑驱蚊程序
// 演示了扬声器的使用
// szlihongtao
// 2010-06-19
// 参照 王建新的<Labwindows/cvi测试技术及工程应用> page245
// 稍有改写
//*********************************************************
#include "windows.h" //包含文件,调用Windows API函数
#include <cvirte.h>
#include <userint.h>
#include "mos.h"
//*********************************************************
static int duration;
static int frequency;
static int panelHandle;
//*********************************************************
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "mos.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
//*********************************************************
int CVICALLBACK QuitCallback (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
//*********************************************************
int CVICALLBACK start (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 1);// 允许定时器的运行
break;
}
return 0;
}
//*********************************************************
int CVICALLBACK timer (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_TIMER_TICK:
//声音频率(从37Hz到32767Hz),在windows95中忽略
GetCtrlVal (panelHandle, PANEL_NUMERIC, &frequency);
//声音的持续时间,以毫秒为单位
GetCtrlVal (panelHandle, PANEL_NUMERIC_2, &duration);
Beep(frequency, duration);
break;
}
return 0;
}
//*********************************************************
int CVICALLBACK stop (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
SetCtrlAttribute (panelHandle, PANEL_TIMER, ATTR_ENABLED, 0); // 禁止定时器的运行
break;
}
return 0;
}
//*********************************************************
//*********************************************************
//*********************************************************
用户1724215 2014-1-9 15:59