点击QUIT后执行的代码,这里我给背景窗口发了个消息,要它更新窗口,然后删除当前任务
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
switch (NCode)
{
case WM_NOTIFICATION_CLICKED:
switch (Id)
{
case GUI_ID_BUTTON0:
_ToggleFullScreenMode(hDlg);
break;
case GUI_ID_BUTTON1:
{
WM_MESSAGE Message;
GUI_EndDialog(hDlg,1);
GUI_Clear();
Message.MsgId=wm_mypaint;
Message.Data.p="hehe";
WM_SendMessage(WM_HBKWIN,&Message); //给窗体发送消息,要重绘自己了。
OSTaskDel(OS_PRIO_SELF);
break;
}
}
break;
背景窗体接受到这个消息执行下面一段代码
void _cbBkWindow(WM_MESSAGE *pMsg)
{
int i, NCode, Id, Value;
WM_HWIN hDlg;
hDlg = pMsg->hWin;
switch(pMsg->MsgId)
{
case wm_mypaint:
In_Menue();
GUI_Delay(100);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc); /* Id of widget */
NCode = pMsg->Data.v; /* Notification code */
switch (NCode)
{
case WM_NOTIFICATION_CLICKED:
switch (Id)
{
case GUI_ID_BUTTON0:
out_MainMeue();//释放资源
OSTaskCreate((void (*) (void *))MainTask,
(void *) 0,
(OS_STK *) &APP_MainTaskStk[TemP_Task_STK_SIZE - 1],
(INT8U) Main_Menue_Task_PRIO);
break;
case GUI_ID_CLOSE:
GUI_DispStringAt("hehe",0,0);
break;
case GUI_ID_OK:
GUI_EndDialog(hDlg,0);
break;
}
} break;
default:
WM_DefaultProc(pMsg);
}
}
离开桌面时候,下面是释放桌面控件资源的
void out_MainMeue() //释放主窗体的资源
{
int i;
for(i=0;i<5;i++)
WM_DeleteWindow(Hbtn[i]);
}
下面是桌面控件初始化
void In_Menue()
{
int i;
Hbtn[0] = BUTTON_Create(20,20,80,80, GUI_ID_BUTTON0, WM_CF_SHOW);
Hbtn[1] = BUTTON_Create(120,20,80,80, GUI_ID_BUTTON1, WM_CF_SHOW);
Hbtn[2] = BUTTON_Create(220,20,80,80, GUI_ID_BUTTON2, WM_CF_SHOW);
Hbtn[3] = BUTTON_Create(20,140,80,80, GUI_ID_BUTTON3, WM_CF_SHOW);
Hbtn[4] = BUTTON_Create(120,140,80,80, GUI_ID_BUTTON4, WM_CF_SHOW);
for (i = 0;i < 5;i++)
{
// BUTTON_SetTextAlign(Hbtn[i],GUI_TA_BOTTOM | GUI_TA_LEFT);
BUTTON_SetFont(Hbtn[i],&GUI_FontHZ_MicrosoftFont_13);
BUTTON_SetTextColor(Hbtn[i],0,GUI_BLACK);
BUTTON_SetBkColor (Hbtn[i],0,GUI_RED);
BUTTON_SetBkColor (Hbtn[i],1,GUI_GRAY);
}
/* Set the button text */
WM_SetDesktopColor(GUI_BLUE);
BUTTON_SetText(Hbtn[0]," 温度监控");
BUTTON_SetText(Hbtn[1]," 湿度监控");
BUTTON_SetText(Hbtn[2]," 光照监控");
BUTTON_SetText(Hbtn[3]," 参数设置");
BUTTON_SetText(Hbtn[4]," 系统设置");
}
主界面就5个button,现在问题是,我点击QUIT后,成功跳转的主窗体,而且也删除了当前任务,但是桌面上那5个button按钮点击没有反应,。不知为何,希望大神们,帮小弟一把。毕业设计焦虑中啊。。、、
-
-
楼主能不分享一下代码学习一下吗,刚学ucgui太需要例程了。
lz有没有解决这个问题?我也在搞ucgui能不能加QQ交流一下