原创 Labwindows/cvi8.5 弹出式面板

2010-6-12 16:03 5524 12 14 分类: 软件与OS

//*********************************************************
// 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;
}
//*********************************************************
//*********************************************************
//*********************************************************

PARTNER CONTENT

文章评论2条评论)

登录后参与讨论

用户1859993 2015-10-29 19:43

下载既然要积分~~

用户377235 2015-5-8 21:45

最好的结婚就是忘记你结婚这件事情

用户1756693 2014-5-8 11:48

酷。好入门资料啊。
相关推荐阅读
sz_lihongtao 2011-04-20 21:32
32bit无符号数快速开平方根
//*******************************************************************************// 32bit无符号数开平方根// ...
sz_lihongtao 2011-04-20 12:12
STM32学习日志(24)----使用dsp库的FFT函数测相位
attachment download/**  ****************************************************************************...
sz_lihongtao 2011-04-19 14:57
STM32学习日志(23)----使用dsp库的FFT函数.rar
attachment download/**  ****************************************************************************...
sz_lihongtao 2011-04-19 10:39
stm32 dsp lib V2.0
attachment downloadattachment download...
sz_lihongtao 2011-04-19 10:37
STM32学习日志(22)----使用DMA功能自动更新PWM的输出
attachment download/*******************************************************************************编...
sz_lihongtao 2010-09-08 21:59
Labwindows/cvi8.5学习日志(56)----任意波形发生器
//******************************************************************************// Labwindows/cvi8.5...
EE直播间
更多
我要评论
2
12
关闭 站长推荐上一条 /3 下一条