原创
Labwindows/cvi8.5 按键不放的检测程序
2010-6-12 14:03
3443
9
9
分类:
软件与OS
https://static.assets-stash.eet-china.com/album/old-resources/2010/6/7/7cf98e7b-0dfd-433b-b3c8-11fdf2733348.RAR//*********************************************************
// Labwindows/cvi8.5 按键不放的检测程序
// szlihongtao
// 2010-06-07
//*********************************************************
#include <cvirte.h>
#include <userint.h>
#include "toolbox.h"
#include "按键不放的检测.h"
//*********************************************************
static int panelHandle;
static int cnt,tmr,f_keypress;
//*********************************************************
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "按键不放的检测.uir", PANEL)) < 0)
return -1;
EnableExtendedMouseEvents(panelHandle,PANEL_COMMANDBUTTON,0.0); // 响应鼠标扩展事件
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 callback_tmr (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
default:
{
if (f_keypress)
{
if (tmr)
--tmr;
else
SetCtrlVal(panelHandle,PANEL_NUMERIC,++cnt);
}
break;
}
}
return 0;
}
//*********************************************************
int CVICALLBACK callback_inc (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_LEFT_CLICK: // 按键刚刚按下
{
SetCtrlVal(panelHandle,PANEL_NUMERIC,++cnt);
tmr=5; // 延时一会儿后连续动作
f_keypress=1;
break;
}
case EVENT_LEFT_CLICK_UP: // 按键释放
{
f_keypress=0; // 标志
break;
}
default:
break;
}
return 0;
}
//*********************************************************
//*********************************************************
//*********************************************************
文章评论(0条评论)
登录后参与讨论