//头文件声明
#include "mscomctl.h"
#include <formatio.h>
#include <cvirte.h>
#include <userint.h>
#include "StatusBar控件.h"
//全局静态变量
static MSComctlLibObj_IPanel SubPanel;
static CAObjHandle ObjectHandle;
static int panelHandle;
//控件回调函数声明
HRESULT CVICALLBACK DoubleClickPanelCallback (CAObjHandle caServerObjHandle, void *caCallbackData, MSComctlLibObj_IPanel panel);
//主函数
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
if ((panelHandle = LoadPanel (0, "StatusBar控件.uir", PANEL)) < 0)
return -1;
//获得ActiveX控件句柄
GetObjHandleFromActiveXCtrl (panelHandle, PANEL_STATUSBAR, &ObjectHandle);
//安装控件回调函数
MSComctlLib_IStatusBarEventsRegOnPanelDblClick (ObjectHandle, DoubleClickPanelCallback, NULL, 1, NULL);
//设置控件在面板最底端
PanelCB (panelHandle, EVENT_PANEL_SIZE, 0, 0, 0);
DisplayPanel (panelHandle);
RunUserInterface ();
DiscardPanel (panelHandle);
return 0;
}
//面板回调函数
int CVICALLBACK PanelCB (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
VARIANT var;
int CHeight;
int PHeight;
int value;
char *Text;
char str[50];
char pos[20];
switch (event)
{
case EVENT_MOUSE_POINTER_MOVE:
//初始化字符串
str[0] = '\0';
pos[0] = '\0';
//设置光标位置
strcat (str, "光标位置:X→");
Fmt (pos, "%s<%i", eventData2);
strcat (str, pos);
strcat (str, ", ");
pos[0] = '\0';
Fmt (pos, "%s<%i", eventData1);
strcat (str, "Y→");
strcat (str, pos);
//将整型数据转换为变体型数据
value = 8;
var = CA_VariantInt (value);
//获得控件的第8个窗格
MSComctlLib_IPanelsGetControlDefault (ObjectHandle, NULL, var, &SubPanel);
//向该窗格写入文本数据
MSComctlLib_IPanelSetText (SubPanel, NULL, &str[0]);
break;
case EVENT_PANEL_SIZE:
//设置控件在最底端位置
GetPanelAttribute (panelHandle, ATTR_HEIGHT, &PHeight);
GetCtrlAttribute (panelHandle, PANEL_STATUSBAR, ATTR_HEIGHT, &CHeight);
SetCtrlAttribute (panelHandle, PANEL_STATUSBAR, ATTR_TOP, PHeight - CHeight);
SetCtrlAttribute (panelHandle, PANEL_STATUSBAR, ATTR_LEFT, 0);
break;
case EVENT_CLOSE:
QuitUserInterface (0);
break;
}
return 0;
}
//双击控件时触发事件
HRESULT CVICALLBACK DoubleClickPanelCallback (CAObjHandle caServerObjHandle, void *caCallbackData, MSComctlLibObj_IPanel panel)
{
char *PanelKey;
//通过控件窗格句柄获得关键字(字符串)
MSComctlLib_IPanelGetKey (panel, NULL, &PanelKey);
//判断鼠标双击的窗格并显示相关信息
if (strcmp (PanelKey, "Caps") == 0)
{
MessagePopup ("提示", "您双击了CAPS!");
}
if (strcmp (PanelKey, "Num") == 0)
{
MessagePopup ("提示", "您双击了NUM!");
}
if (strcmp (PanelKey, "Ins") == 0)
{
MessagePopup ("提示", "您双击了INS!");
}
if (strcmp (PanelKey, "Scrl") == 0)
{
MessagePopup ("提示", "您双击了SCRL!");
}
if (strcmp (PanelKey, "Time") == 0)
{
MessagePopup ("提示", "您双击了时间!");
}
if (strcmp (PanelKey, "Date") == 0)
{
MessagePopup ("提示", "您双击了日期!");
}
if (strcmp (PanelKey, "Kana") == 0)
{
MessagePopup ("提示", "您双击了KANA!");
}
//释放资源
CA_FreeMemory (PanelKey);
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
StatusBar-kongjian.rar_statusbar
共1个文件
txt:1个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 188 浏览量
2022-09-22
23:25:09
上传
评论
收藏 1KB RAR 举报
温馨提示
Labview CVI的StatusBar控件的使用示例
资源详情
资源评论
资源推荐
收起资源包目录
StatusBar-kongjian.rar (1个子文件)
StatusBar kongjian.txt 3KB
共 1 条
- 1
周楷雯
- 粉丝: 93
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0