//*********************************************************
// Labwindows/cvi8.5 弹出式面板
// szlihongtao
// 2010-06-12
// 参照 王建新的<Labwindows/cvi测试技术及工程应用> page62
// 稍有改写
//*********************************************************
#include "toolbox.h"
#include "popup.h"
//*********************************************************
static int panelHandle;
int selectionstatus;
int size;
int color;
int just;
int italic;
int strikeout;
int underline;
int bold;
//char typeface[1000] = {"宋体"};
char typeface[1000] = {"NIApp"};
//*********************************************************
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "popup.uir", PANEL)) < 0)
return -1;
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
//*********************************************************
//"MessagePopup"按钮的回调函数
//*********************************************************
int CVICALLBACK messagepopup (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
{
MessagePopup ("Message Popup", "这是一个 Message Popup 窗口!\n第2行信息!");
break;
}
}
return 0;
}
//*********************************************************
//"GenericMessagePopup"按钮的回调函数
//*********************************************************
int CVICALLBACK genericpopup (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int selbutton;
char responsebuffer[101];
switch (event)
{
case EVENT_COMMIT:
selbutton = GenericMessagePopup ("Generic Message Popup", "这是一个 Generic Message Popup 窗口!", "按钮1", "按钮2", "按钮3", responsebuffer,
100, 0, VAL_GENERIC_POPUP_BTN2, VAL_GENERIC_POPUP_BTN1, VAL_GENERIC_POPUP_BTN3);
break;
}
return 0;
}
//*********************************************************
//"romptPopup"按钮的回调函数
//*********************************************************
int CVICALLBACK promptpopup (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char responsebuffer[101];
switch (event)
{
case EVENT_COMMIT:
PromptPopup ("Prompt Popup", "这是一个 Prompt Popup 窗口!", responsebuffer, 4);
break;
}
return 0;
}
//*********************************************************
//"ConfirmPopup"按钮的回调函数。
//*********************************************************
int CVICALLBACK confirmpop (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int confirm;
switch (event)
{
case EVENT_COMMIT:
confirm = ConfirmPopup ("Confirm Popup", "这是一个 Confirm Popup 窗口!");
if (confirm == 1)
{
QuitUserInterface (0);
}
break;
}
return 0;
}
//*********************************************************
//"FileSelectPopup"按钮的回调函数
//*********************************************************
int CVICALLBACK fileselectpopup (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char pathname[MAX_PATHNAME_LEN];
switch (event)
{
case EVENT_COMMIT:
FileSelectPopup ("", "*.c", "*.c;*.h;*.uir", "File Select Popup", VAL_OK_BUTTON, 0, 0, 1, 0, pathname);
break;
}
return 0;
}
//*********************************************************
//"YGraphPopup"按钮的回调函数
//*********************************************************
int CVICALLBACK ygraphpopup (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
double value[300];
int i;
switch (event)
{
case EVENT_COMMIT:
{
for (i = 0; i < 300; i ++)
value = Random (0, 100);
YGraphPopup ("Y Graph Popup", value, 50, VAL_DOUBLE);
break;
}
}
return 0;
}
//*********************************************************
//"FontSelectPopup"按钮的回调函数
//*********************************************************
int CVICALLBACK font (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
{
selectionstatus = FontSelectPopup ("Font Select Popup", "Sample Text", 0, typeface, &bold, &underline, &strikeout, &italic, &just,
&color, &size, 6, 48, 0, 0);
if (selectionstatus > 0)
{
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_BOLD, bold);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_COLOR, color);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_FONT, typeface);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_ITALIC, italic);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_JUSTIFY, just);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_STRIKEOUT, strikeout);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_UNDERLINE, underline);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_LABEL_BGCOLOR, color);
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_LABEL_SIZE_TO_TEXT, size);
}
break;
}
}
return 0;
}
//*********************************************************
//"DirSelectPopup"按钮的回调函数
//*********************************************************
int CVICALLBACK dirpopup (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
char dirpathname[MAX_PATHNAME_LEN];
switch (event)
{
case EVENT_COMMIT:
{
DirSelectPopup ("d:\\temp", "Dir Select Popup", 0, 1, dirpathname);
dirpathname[200]=88; // 用于在此处放置一个断点,观察 dirpathname 的值
break;
}
}
return 0;
}
//*********************************************************
int CVICALLBACK quitsys (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
QuitUserInterface (0);
break;
}
return 0;
}
//*********************************************************
//*********************************************************
//*********************************************************
用户1859993 2015-10-29 19:43
用户377235 2015-5-8 21:45
用户1756693 2014-5-8 11:48