|

楼主 |
发表于 2024-9-19 16:34:44
|
显示全部楼层
static const GUI_WIDGET_CREATE_INFO _aDialogCreate1[] = {
{ WINDOW_CreateIndirect, "Window", ID_WINDOW_0, 0, 0, 480, 272, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button1", ID_BUTTON_0, 18, 87, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button2", ID_BUTTON_1, 130, 87, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button3", ID_BUTTON_2, 245, 87, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button4", ID_BUTTON_3, 361, 87, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button5", ID_BUTTON_4, 18, 161, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button6", ID_BUTTON_5, 130, 161, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button7", ID_BUTTON_6, 245, 161, 88, 44, 0, 0x0, 0 },
{ BUTTON_CreateIndirect, "Button8", ID_BUTTON_7, 361, 161, 88, 44, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_0, 48, 239, 80, 26, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_0, 370, 2, 112, 20, 0, 0x0, 0 },
{ TEXT_CreateIndirect, "Text", ID_TEXT_1, 368, 24, 112, 20, 0, 0x0, 0 },
{ EDIT_CreateIndirect, "Edit", ID_EDIT_1, 348, 239, 80, 26, 0, 0x64, 0 },
{ TEXT_CreateIndirect, "Frt", ID_TEXT_2, 109, 1, 237, 20, 0, 0x0, 0 },
// USER START (Optionally insert additional widgets)
// USER END
};
/*********************************************************************
*
* Static code
*
**********************************************************************
*/
// USER START (Optionally insert additional static code)
// USER END
/*********************************************************************
*
* _cbDialog
*/
static void _cbDialog1(WM_MESSAGE * pMsg) {
WM_HWIN hItem;
int NCode;
int Id;
char buf[20];
RTC_TimeTypeDef RTC_TimeStruct;
RTC_DateTypeDef RTC_DateStruct;// //显示日期
// USER START (Optionally insert additional variables)
// USER END
switch (pMsg->MsgId) {
case WM_INIT_DIALOG:
//
// Initialization of 'Edit'
//
GUI_SetFont(GUI_FONT_8X18);
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_0);
EDIT_SetText(hItem, "12345678");
//
// Initialization of 'Edit'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_EDIT_1);
EDIT_SetText(hItem, "123456.78");
//
// Initialization of 'Frist'
//
hItem = WM_GetDialogItem(pMsg->hWin, ID_TEXT_2);
TEXT_SetFont(hItem, GUI_FONT_16B_ASCII);
TEXT_SetTextAlign(hItem, GUI_TA_HCENTER | GUI_TA_VCENTER);
// USER START (Optionally insert additional code for further widget initialization)
// USER END
break;
/* 定时器消息 */
case WM_TIMER: //--------------(1)
//显示日期
HAL_RTC_GetDate(&hrtc,&RTC_DateStruct,RTC_FORMAT_BIN);//获取日期
sprintf((char*)buf,"20%02d-%02d-%02d",RTC_DateStruct.Year,RTC_DateStruct.Month,RTC_DateStruct.Date);
TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_0), (const char*)buf);
//显示时间
HAL_RTC_GetTime(&hrtc,&RTC_TimeStruct,RTC_FORMAT_BIN);//获取时间
sprintf((char*)buf,"%02d:%02d:%02d",RTC_TimeStruct.Hours,RTC_TimeStruct.Minutes,RTC_TimeStruct.Seconds);
TEXT_SetText(WM_GetDialogItem(pMsg->hWin, ID_TEXT_1), (const char*)buf);
WM_RestartTimer(pMsg->Data.v, 1000);
break;
case WM_KEY:
switch (((WM_KEY_INFO*)(pMsg->Data.p))->Key)
{
case GUI_KEY_ESCAPE:
GUI_EndDialog(pMsg->hWin, 1);
break;
case GUI_KEY_TAB:
WM_SetFocusOnNextChild(pMsg->hWin);
break;
}
break;
case WM_NOTIFY_PARENT:
Id = WM_GetId(pMsg->hWinSrc);
NCode = pMsg->Data.v;
switch(Id) {
case ID_BUTTON_0: // Notifications sent by 'Button1'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
GUI_EndDialog(pMsg->hWin, 0);
CreateSECOND();
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_1: // Notifications sent by 'Button2'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_2: // Notifications sent by 'Button3'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_3: // Notifications sent by 'Button4'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_4: // Notifications sent by 'Button5'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_5: // Notifications sent by 'Button6'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_6: // Notifications sent by 'Button7'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_BUTTON_7: // Notifications sent by 'Button8'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_EDIT_0: // Notifications sent by 'Edit'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_VALUE_CHANGED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
case ID_EDIT_1: // Notifications sent by 'Edit'
switch(NCode) {
case WM_NOTIFICATION_CLICKED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_RELEASED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
case WM_NOTIFICATION_VALUE_CHANGED:
// USER START (Optionally insert code for reacting on notification message)
// USER END
break;
// USER START (Optionally insert additional code for further notification handling)
// USER END
}
break;
// USER START (Optionally insert additional code for further Ids)
// USER END
}
break;
// USER START (Optionally insert additional message handling)
// USER END
default:
WM_DefaultProc(pMsg);
break;
}
}
/*********************************************************************
*
* Public code
*
**********************************************************************
*/
/*********************************************************************
*
* CreateWindow
*/
WM_HWIN CreateWindow(void) {
WM_HWIN hWin;
WM_HTIMER hTimer;
hWin = GUI_CreateDialogBox(_aDialogCreate1, GUI_COUNTOF(_aDialogCreate1), _cbDialog1, WM_HBKWIN, 0, 0);
WM_SetFocus(hWin);
/* 给对话框hDlg创建定时器,溢出时间是100ms */
hTimer = WM_CreateTimer(hWin, 0, 1000, 0); //--------------(2)
return hWin;
}
void MainTask1(void)
{
/* 初始化 */
//GUI_Init();
/* 窗口自动使用存储设备 */
WM_SetCreateFlags(WM_CF_MEMDEV);
// /* 创建对话框,使用GUIBulder生成的对话框创建函数 */
// GUI_SetFont(GUI_FONT_8X18);
// GUI_DispStringAt("Frist",0,0);
// GUI_DispStringAt("Button1",0,32);
CreateWindow();
while (1)
{
GUI_Delay(100);
}
} |
|