中级会员
- 积分
- 246
- 金钱
- 246
- 注册时间
- 2016-10-24
- 在线时间
- 37 小时
|
10金钱
请教一下,我现在用EMWIN能显示出时间,但是不能够实现实时刷新,请问是哪儿的问题?
还有一个问题就是怎么将函数的返回值显示出来?以下是我的程序,请问是什么地方不对啊?非常感谢!
static void _cbDialog(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_SetFont(&GUI_FontHZ16);
GUI_SetColor(GUI_BLACK);
GUI_GetTime();
sprintf((char*)ttbuf1,"%02d-%02d-%02d",calendar.w_year,calendar.w_month,calendar.w_date);
GUI_DispStringAt((const char*)ttbuf1,65,13);
sprintf((char *)ttbuf1,"%02d:%02d:%02d",calendar.hour,calendar.min,calendar.sec);
GUI_DispStringAt((const char*)ttbuf1,155,13);
WM_CreateTimer(TextDialoghWin,0,100,0);
break;
case WM_INIT_DIALOG:
hItem = pMsg->hWin;
FRAMEWIN_SetText(hItem, "Sleep condition");
FRAMEWIN_SetFont(hItem, GUI_FONT_24_ASCII);
FRAMEWIN_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "时间:");
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
TEXT_SetFont(hItem, &GUI_FontHZ16);
TEXT_SetText(hItem, "睡眠总时间:");
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWin);
NCode = pMsg->Data.v;
// switch(Id)
// {
// case ID_TEXT_7:
// {
switch(NCode)
{
case WM_PAINT:
// SLP_TIME=Getslptime();
// GUI_DispDecAt(SLP_TIME,120,47,3);
sprintf((char *)SLP_TIME,"%03d",sleeptime);
GUI_DispStringAt((const char*)SLP_TIME,120,47);
break;
}
// break;
// }
// break;
// }
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
static void _cbBkWindow(WM_MESSAGE* pMsg)
{
switch(pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_BLUE);
GUI_Clear();
break;
case WM_TIMER:
// WM_RestartTimer(pMsg->Data.v,1000);
WM_InvalidateWindow(TextDialoghWin);
WM_ShowWindow(TextDialoghWin);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
void sleep()
{
// GUI_Init();
// Getslptime();
WM_SetCallback(WM_HBKWIN,_cbBkWindow);
TextDialoghWin = GUI_CreateDialogBox(_aDialogCreate, GUI_COUNTOF(_aDialogCreate), _cbDialog, WM_HBKWIN, 0, 0);
FRAMEWIN_AddCloseButton(TextDialoghWin,FRAMEWIN_BUTTON_RIGHT,0);
FRAMEWIN_AddMaxButton(TextDialoghWin,FRAMEWIN_BUTTON_RIGHT,2);
FRAMEWIN_AddMinButton(TextDialoghWin,FRAMEWIN_BUTTON_RIGHT,2);
while(1)
{
sleeptime=Getslptime();
GUI_Exec();
// GUI_Delay(20);
delay_ms(100);
WM_InvalidateWindow(TextDialoghWin); //对话框窗口无效
}
}
|
|