关于LabWindows/CVI的操作问题 怎么样可以输入一个数据,包括面板和.c 程序,
面板见图
程序如下:
#include <cvirte.h>
#include <userint.h>
#include "计算.h"
static int panelHandle;
int i;
double x,y,val;
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;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
int CVICALLBACK Jisuan (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal(panelHandle,PANEL_NUMERIC,&x);
GetCtrlVal(panelHandle,PANEL_NUMERIC_1,&y);
GetCtrlVal(panelHandle,PANEL_RINGSLIDE,&i);
switch(i)
{
case 0:
val=x+y;
break;
case 1:
val=x-y;
break;
case 2:
val=x*y;
break;
case 3:
if(y==0)
{
MessagePopup("Warning","被除数不能为“0”");
}
else
val=x/y;
break;
}
SetCtrlVal(panelHandle,PANEL_NUMERIC_2,val);
break;
}
return 0;
}
2024-08-19 广告
#include <cvirte.h>
#include <userint.h>
#include <math.h>
#include "计算两数和.h"
static int panelHandle;
double *c;
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;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
int CVICALLBACK jisuan (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
double a,b,c;
case EVENT_COMMIT:
GetCtrlVal (panelHandle, PANEL_A, &a); //获取A数值
GetCtrlVal (panelHandle, PANEL_B, &b);//获取B数值
c=(a+b);
SetCtrlVal(panelHandle, PANEL_C, c);
break;
}
return 0;
}
int CVICALLBACK QUIT (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}