初级会员
- 积分
- 103
- 金钱
- 103
- 注册时间
- 2019-9-16
- 在线时间
- 37 小时
|
1金钱
新人初学EMWIN,困难重重,请问各位大佬,如何在窗口标题栏显示时间电量或者其他信息。我的做法是利用EMwin的定时器,定时更新窗口的标题栏,发现不行,求大佬指点。
/*********************************************************************
*
* Display_Time_BatteryData
*/
int temp = 1;
static void Display_Time_BatteryData(WM_MESSAGE* pMsg)
{
char Temp_Now[5] = { 0 };
WM_HWIN hItem;
//time display
hItem = WM_GetClientWindow;//(pMsg->hWin, ID_FRAMEWIN_0);
FRAMEWIN_SetText(hItem, "text");
}
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog(WM_MESSAGE * pMsg)
{
WM_HWIN hItem;
int NCode;
int Id;
switch (pMsg->MsgId)
{
case WM_INIT_DIALOG://初始化消息ID,当窗口第一次创建时,此处的代码被运行一次,后面不会再运行。
// Initialization of 'Demo' 初始化窗口
hItem = pMsg->hWin;
FRAMEWIN_SetTitleHeight(hItem, 16);
FRAMEWIN_SetTextAlign(hItem, GUI_TA_LEFT | GUI_TA_VCENTER);
FRAMEWIN_SetTextColor(hItem, GUI_MAKE_COLOR(0x004080FF));
FRAMEWIN_SetText(hItem, "BMU DEMO Time:2020/4/20 00:00:00");
FRAMEWIN_SetFont(hItem, GUI_FONT_16B_1);
FRAMEWIN_SetBarColor(hItem,1 , GUI_MAKE_COLOR(0xFF0000));
FRAMEWIN_SetSkinClassic(hItem);
FRAMEWIN_SetClientColor(hItem, GUI_GRAY_AA);
//
// Initialization of 'Battery2:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_0);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Battery3:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_1);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Battery4:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Battery5:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_3);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Battery6:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_4);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Battery8:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_5);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Battery7:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_6);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'SOC'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_7);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
TEXT_SetText(hItem, "SOC:");
//
// Initialization of 'Battery1:'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_8);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
//
// Initialization of 'Listview'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_LISTVIEW_0);
LISTVIEW_AddColumn(hItem, 120, "TIME", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddColumn(hItem, 160, "Fault Type", GUI_TA_HCENTER | GUI_TA_VCENTER);
LISTVIEW_AddRow(hItem, NULL);
LISTVIEW_SetGridVis(hItem, 1);
//
// Initialization of 'Alarm Record'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_9);
TEXT_SetFont(hItem, GUI_FONT_16B_1);
TEXT_SetText(hItem, "Alarm Record:");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_2);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_3);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_4);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_5);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_6);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_7);
EDIT_SetText(hItem, "0.000V");
EDIT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
case WM_NOTIFY_PARENT: //告知父窗口,其子窗口中发生了某些改变。有动作活动的消息ID,当有窗口活动时,此处代码被运行一次,后面不会运行。
Id= WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id)
{
case ID_LISTVIEW_0: // Notifications sent by 'Listview'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_SEL_CHANGED:
break;
}
break;
case ID_EDIT_0: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_1: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_2: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_3: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_4: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_5: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_6: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
case ID_EDIT_7: // Notifications sent by 'Edit'
switch(NCode)
{
case WM_NOTIFICATION_CLICKED:
break;
case WM_NOTIFICATION_RELEASED:
break;
case WM_NOTIFICATION_VALUE_CHANGED:
break;
}
break;
}
break;
case WM_TIMER:
Display_Time_BatteryData(pMsg);
WM_RestartTimer(pMsg->Data.v, 1000);
break;
default:
WM_DefaultProc(pMsg);
break;
}
}
|
|