static void _cbDialog(WM_MESSAGE * pMsg) {
// char acBuffer[50];
WM_HWIN hww;
WM_HWIN hItem;
WM_HWIN _hMenu;
WM_HWIN hDlg;
WM_HWIN hWin;
MENU_ITEM_DATA ItemData;
int NCode;
int Id;
static u8 flag = 0;
MENU_MSG_DATA *pData;
int index;
hDlg = pMsg->hWin;
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
break;
case WM_INIT_DIALOG:
//初始化对话框
hItem = pMsg->hWin;
// FRAMEWIN_SetTitleHeight(hItem, 0);
FRAMEWIN_SetText(hItem, "单井口控制系统界面");
FRAMEWIN_SetFont(hItem, &GUI_FontHZ24);
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
FRAMEWIN_SetTextColor(hItem,0x0000FFFF);
//初始化ID_TEXT_0即液位开关
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetTextColor(hItem, 0x00000000);
TEXT_SetText(hItem,"1号液位开关:");
//初始化BUTTON0
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetBitmapEx(hItem,0,&buttonbmp_tab[0],0,0);
BUTTON_SetText(hItem, "");
//
// 初始化1号电磁阀DCF1
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
TEXT_SetText(hItem,"1号电磁阀:");
//初始化BUTTON1
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetBitmapEx(hItem,0,&buttonbmp_tab[0],0,0);
BUTTON_SetText(hItem, "");
//
// 初始化ID_TEXT_2即2号液位开关
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem,&GUI_FontHZ16);
TEXT_SetTextColor(hItem, 0x00000000);
TEXT_SetText(hItem,"2号液位开关:");
//初始化BUTTON2
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
BUTTON_SetBitmapEx(hItem,0,&buttonbmp_tab[0],0,0);
BUTTON_SetText(hItem, "");
// 初始化1号电磁阀'DCF2:' ID_TEXT_3
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem,"2号电磁阀:");
//初始化BUTTON3
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
BUTTON_SetBitmapEx(hItem,0,&buttonbmp_tab[0],0,0);
BUTTON_SetText(hItem, "");
//初始化图表
hItem = WM_GetDialogItem(pMsg->hWin,ID_GRAPH_0);
//添加图表‘
for(int i = 0;i < GUI_COUNTOF(_aColor);i++)
{
_aValue[i] = rand() % 180;
_ahData[i] = GRAPH_DATA_YT_Create(_aColor[i],500,0,0);//创建 GRAPH_DATA_YT 对象。
GRAPH_AttachData(hItem,_ahData[i]);//将数据对象附加到现有图形小工具
}
//设置图表属性
GRAPH_SetGridDistY(hItem,25);//这些函数设置从一条网格线到下一网格线的距离
GRAPH_SetGridVis(hItem, 1);//设置网格线的可见性。
GRAPH_SetGridFixedX(hItem, 1);//固定 X 轴方向的网格
GRAPH_SetBorder(hItem,40,1,1,10);
GRAPH_SetUserDraw(hItem, _UserDraw);
//垂直刻度
_hScaleV = GRAPH_SCALE_Create( 35, GUI_TA_RIGHT, GRAPH_SCALE_CF_VERTICAL, 25);//创建刻度对象。
GRAPH_SCALE_SetTextColor(_hScaleV, GUI_YELLOW);
GRAPH_AttachScale(hItem, _hScaleV);//将刻度对象附加到现有图形小工具
//水平刻度
_hScaleH = GRAPH_SCALE_Create(130, GUI_TA_HCENTER, GRAPH_SCALE_CF_HORIZONTAL, 50);
GRAPH_SCALE_SetTextColor(_hScaleH, GUI_DARKGREEN);
GRAPH_AttachScale(hItem, _hScaleH);
//水平滚动条
GRAPH_SetVSizeX(hItem,500);
//垂直滚动条
GRAPH_SetVSizeY(hItem,500);
break;
case WM_NOTIFY_PARENT://操作触发消息处理(操作屏幕程序会跑道这里),比如点击按键,点击编辑框等
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;//获取通知代码
switch(Id) {
case ID_BUTTON_0: //button的通知代码
hItem = WM_GetDialogItem(pMsg->hWin,ID_BUTTON_0);//返回小工具对话框的窗口句柄
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
flag = ~flag;
BUTTON_SetBitmapEx(hItem,0,flag?&buttonbmp_tab[1]:&buttonbmp_tab[0],0,0);
break;
}
break;
case ID_BUTTON_1: // Notifications sent by 'Button'
hItem = WM_GetDialogItem(pMsg->hWin,ID_BUTTON_1);
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
flag = ~flag;
BUTTON_SetBitmapEx(hItem,0,flag?&buttonbmp_tab[1]:&buttonbmp_tab[0],0,0);
break;
}
break;
case ID_BUTTON_2: // Notifications sent by 'Button'
hItem = WM_GetDialogItem(pMsg->hWin,ID_BUTTON_2);
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
flag = ~flag;
BUTTON_SetBitmapEx(hItem,0,flag?&buttonbmp_tab[1]:&buttonbmp_tab[0],0,0);
break;
}
break;
case ID_BUTTON_3: // Notifications sent by 'Button'
hItem = WM_GetDialogItem(pMsg->hWin,ID_BUTTON_3);
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
flag = ~flag;
BUTTON_SetBitmapEx(hItem,0,flag?&buttonbmp_tab[1]:&buttonbmp_tab[0],0,0);
break;
}
break;
}
break;
case WM_MENU:
pData = (MENU_MSG_DATA *)pMsg->Data.p;
switch(pData->MsgType){
case MENU_ON_ITEMPRESSED:
MENU_GetItem(pMsg->hWinSrc,pData->ItemId,&ItemData);
if(ItemData.Flags & MENU_IF_DISABLED){
_MessageBox("THE PRESSED ITEM WAS DISABLE","Message");
}
break;
case MENU_ON_ITEMACTIVATE:
break;
case MENU_ON_ITEMSELECT:
switch(pData->ItemId){
case ID_MENU_10://主界面触发事件
GUI_MessageBox("hahahah","hahah",GUI_MESSAGEBOX_CF_MODAL);
break;
case ID_MENU_11:
GUI_MessageBox("hahahah","hahah",GUI_MESSAGEBOX_CF_MODAL);
break;
case ID_MENU_20:
GUI_MessageBox("hahahah","hahah",GUI_MESSAGEBOX_CF_MODAL);
// OnICON00Clicked(1);
break;
case ID_MENU_30://设置按钮
GUI_EndDialog(pMsg->hWin,0);
GUI_EndDialog(_hMain,0);
GUI_EndDialog(_hMenu,0);
int a = GUI_ALLOC_GetNumFreeBytes();
printf("%d ",a);
int r = GUI_ALLOC_GetNumFreeBytes();
printf("%d ",r);
printf("clear");
OnICON_Main = 1;
OnICON_Setter =1;
Buttonbmp_Demo();
}
//GUI_MessageBox("hahahah","hahah",GUI_MESSAGEBOX_CF_MODAL);
break;
}
break;
}
default:
WM_DefaultProc(pMsg);
break;
}
}
//创建一个对话框
WM_HWIN CreateFramewin(void)
{
WM_HWIN hWin;
buttonbmp_tab[0]=bmBUTTONOFF;
buttonbmp_tab[1]=bmBUTTONON;
int a = GUI_ALLOC_GetNumFreeBytes();
printf("%d ",a);
hWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
return hWin;
}
//BUTTON按钮上显示位图
void Buttonbmp_Demo(void)
{
WM_HWIN hWin;
WM_HWIN _hMenu;
hWin=CreateFramewin();
_hMain = hWin;
_hMenu=_CreateMenu(hWin);
int a = GUI_ALLOC_GetNumFreeBytes();
printf("%d ",a);
printf("hahahhah");
printf("%d",OnICON_Main);
while(OnICON_Main)
{
GUI_Delay(100);
_AddValues();
}
}
一周热门 更多>