中级会员
- 积分
- 322
- 金钱
- 322
- 注册时间
- 2020-7-7
- 在线时间
- 113 小时
|
楼主 |
发表于 2020-11-25 10:10:55
|
显示全部楼层
本帖最后由 zxc199701 于 2020-11-25 10:12 编辑
大神,这样不行啊,我一点击按钮就卡死了,代码如下:WM_HWIN hControl
//点灯程序
void Fill(WM_MESSAGE * pMsg)
{
LED2_Toggle;
GUI_Delay(3000);
LED2_Toggle;
LED4_Toggle;
GUI_Delay(3000);
LED4_Toggle;
LED3_Toggle;
GUI_Delay(3000);
LED3_Toggle;
LED5_Toggle;
GUI_Delay(3000);
LED5_Toggle;
}
//主界面对话框
static void _cbDialogPage1(WM_MESSAGE * pMsg)
{
int NCode;
int Id;
WM_HWIN hItem =pMsg->hWin;
unsigned int i;
u8 tbuf[20];
switch (pMsg->MsgId) {
//窗口重绘消息
case WM_PAINT:
GUI_SetBkColor(GUI_WHITE);
GUI_Clear();
DSO_Init(0); //示波器界面初始化
break;
//对话框初始化消息
case WM_INIT_DIALOG:
WM_CreateTimer(hItem,ID_TimerData,1000,0);
WM_CreateTimer(hItem,ID_TimerTime,1000,0);
//TEXT控件初始化
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"测试信息");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"产品条码");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"检测压力");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem, GUI_WHITE);
TEXT_SetText(hItem,"当前压差");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"检测数量");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"合格品率");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"Kpa");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"Pa");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"PCS");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_9);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"%");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_10);
TEXT_SetFont(hItem,&GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"泄露量");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_11);
TEXT_SetFont(hItem,&GUI_FontHZ24);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"Pa");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_12);
TEXT_SetFont(hItem, &GUI_FontHZ32);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetText(hItem,"0.0");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_17);
TEXT_SetFont(hItem, &GUI_FontHZ24);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetTextAlign(hItem, GUI_TA_VCENTER|GUI_TA_CENTER);
TEXT_SetText(hItem, "00:00");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_18);
TEXT_SetFont(hItem, &GUI_FontHZ24);
TEXT_SetTextColor(hItem,GUI_WHITE);
TEXT_SetTextAlign(hItem, GUI_TA_VCENTER|GUI_TA_CENTER);
TEXT_SetText(hItem, "2020/11/24");
//按钮控件初始化
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_0);
BUTTON_SetFont(hItem,&GUI_FontHZ24);
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetText(hItem,"测试记录");
WM_SetHasTrans(hItem);
WM_SetCallback(hItem,_cbButton);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_1);
BUTTON_SetFont(hItem,&GUI_FontHZ24);
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetText(hItem,"参数设置");
WM_SetHasTrans(hItem);
WM_SetCallback(hItem,_cbButton);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_2);
BUTTON_SetFont(hItem,&GUI_FontHZ24);
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetText(hItem,"起 动");
WM_SetHasTrans(hItem);
WM_SetCallback(hItem,_cbButton);
hItem = WM_GetDialogItem(pMsg->hWin, ID_BUTTON_3);
BUTTON_SetFont(hItem,&GUI_FontHZ24);
BUTTON_SetTextColor(hItem,BUTTON_CI_UNPRESSED,GUI_WHITE);
BUTTON_SetText(hItem,"停 止");
WM_SetHasTrans(hItem);
WM_SetCallback(hItem,_cbButton);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0); // 编辑框
EDIT_SetFont(hItem, &GUI_FontHZ32);
EDIT_EnableBlink(hItem, 500, 1);
EDIT_SetTextAlign(hItem,GUI_TA_LEFT | GUI_TA_VCENTER);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1); // 编辑框
EDIT_SetFont(hItem, &GUI_FontHZ32);
EDIT_EnableBlink(hItem, 500, 1);
EDIT_SetTextAlign(hItem,GUI_TA_LEFT | GUI_TA_VCENTER);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2); // 编辑框
EDIT_SetFont(hItem, &GUI_FontHZ32);
EDIT_EnableBlink(hItem, 500, 1);
EDIT_SetTextAlign(hItem,GUI_TA_LEFT | GUI_TA_VCENTER);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3); // 编辑框
EDIT_SetFont(hItem, &GUI_FontHZ32);
EDIT_EnableBlink(hItem, 500, 1);
break;
//定时器消息
case WM_TIMER:
if(WM_GetTimerId(pMsg->Data.v) == ID_TimerData)
{
hItem = WM_GetDialogItem(pMsg->hWin,ID_EDIT_1);
EDIT_SetText(hItem,Detectpressure);
WM_RestartTimer(pMsg->Data.v,1000);
}
else if(WM_GetTimerId(pMsg->Data.v) == ID_TimerTime)
{
Caculate_RTC(pMsg);
WM_RestartTimer(pMsg->Data.v,1000);
}
else if(WM_GetTimerId(pMsg->Data.v) == ID_TimerControl)
{
Fill(pMsg);
}
break;
//通知父窗口,其子窗口中发生了某些改变。
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_EDIT_0:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_EDIT_1:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_EDIT_2:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_EDIT_3:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
case ID_EDIT_4:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
}
break;
//打开测试记录界面按钮
case ID_BUTTON_0:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(hItem, 1);
CreateWindow2();
break;
}
break;
//打开参数设置界面按钮
case ID_BUTTON_1:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
GUI_EndDialog(hItem, 1);
CreateWindow3();
break;
}
break;
//开始循环按钮
case ID_BUTTON_2:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
hControl = WM_CreateTimer(hItem,ID_TimerControl,0,0);
break;
}
break;
//停止循环按钮
case ID_BUTTON_3:
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
WM_DeleteTimer(hControl);
break;
}
break;
}
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
WM_HWIN CreateWindow1(void) {
WM_HWIN hWin;
hWin = GUI_CreateDialogBox(_aDialogCreatePage1, GUI_COUNTOF(_aDialogCreatePage1), _cbDialogPage1, WM_HBKWIN, 0, 0);
return hWin;
}
//主函数
void f_MainTask(void) {
WM_HWIN hItemPage1;
GUI_Init();
WM_SetCallback(WM_HBKWIN,_cbDialogPage1);
WM_MULTIBUF_Enable(1);
/* 第3步:绘制各种背景到存储设备 ***************************************************/
hMemDSO = GUI_MEMDEV_CreateFixed(0,
0,
600,
400,
GUI_MEMDEV_HASTRANS,
GUI_MEMDEV_APILIST_16,
GUICC_M565);
/* 绘制示波器窗口背景 */
GUI_MEMDEV_Select(hMemDSO);
DSO_DrawBakFrame(0,0,599,399);
GUI_MEMDEV_Select(0);
WM_HideWindow(WM_HBKWIN);
DSO_Init(1);
WM_ShowWindow(WM_HBKWIN);
GUI_Exec();
DSO_Graph();
hItemPage1 = GUI_CreateDialogBox(_aDialogCreatePage1,GUI_COUNTOF(_aDialogCreatePage1),_cbDialogPage1,WM_HBKWIN,0,0);
}
|
|